From 22c6276ae9caa37580c0cdb2492d01a05355aada Mon Sep 17 00:00:00 2001 From: ls232920 <laurent.soulier@cea.fr> Date: Fri, 6 Oct 2023 09:31:14 +0000 Subject: [PATCH] [MAJ] getIdx returns an index in number of elements --- include/aidge/backend/TensorImpl.hpp | 2 +- include/aidge/data/Tensor.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/aidge/backend/TensorImpl.hpp b/include/aidge/backend/TensorImpl.hpp index 08a1d19bb..565bcc358 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 1b628cf2a..07684241e 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; -- GitLab