diff --git a/include/aidge/backend/TensorImpl.hpp b/include/aidge/backend/TensorImpl.hpp index 08a1d19bbc64fa393218abd246cf853d9ac5f527..565bcc358250312150281dba6ab26de97a7e0cac 100644 --- a/include/aidge/backend/TensorImpl.hpp +++ b/include/aidge/backend/TensorImpl.hpp @@ -169,7 +169,7 @@ public: && "Coordinates dimensions does not fit the dimensions of the tensor"); flatIdx += (coordIdx[i] * mvLayout[i]); } - return flatIdx; + return flatIdx / mScalarSize; } private: diff --git a/include/aidge/data/Tensor.hpp b/include/aidge/data/Tensor.hpp index 1b628cf2a0b942ee94e237014c2f96940c9c8735..07684241ee9a8336692fc0da911a56b31457903a 100644 --- a/include/aidge/data/Tensor.hpp +++ b/include/aidge/data/Tensor.hpp @@ -441,7 +441,7 @@ public: template<typename expectedType> expectedType &get(std::vector<Coord_t> const &coordIdx) { - return get<expectedType>(getIdx(coordIdx) / GetScalarSize()); + return get<expectedType>(getIdx(coordIdx)); } /// @brief Set teh value of an element identified by its index @@ -477,6 +477,7 @@ public: private: /// @brief Get the linear index of the first Byte_t of the data at given coordinates /// @param coordIdx coordinates of the desired data + /// @note The index is expressed in number of elements /// @return Linear index of the first Byte_t of the data at given coordinates std::size_t getIdx(std::vector<Coord_t> const &coordIdx) const noexcept;