diff --git a/include/aidge/backend/cpu/data/TensorImpl.hpp b/include/aidge/backend/cpu/data/TensorImpl.hpp index ff19a492f640719b4d068c67a6ef2101c02b723e..88f329c1d79c08f718f56d10287b06289fd60634 100644 --- a/include/aidge/backend/cpu/data/TensorImpl.hpp +++ b/include/aidge/backend/cpu/data/TensorImpl.hpp @@ -21,6 +21,7 @@ public: /// @param i_FirstDataCoordinates Logical coordinates of the data at null natural /// coordinates /// @param i_Dimensions Tensor dimensions + /// @sa Coord_t TensorImpl_cpu( DataType const i_DataType, std::vector<Coord_t> const &i_FirstDataCoordinates, @@ -97,11 +98,7 @@ public: if (ptr) { ptr->cloneProperties(*this); - NbElts_t n = std::accumulate( - std::begin(getDimensions()), - std::end(getDimensions()), - 1, - std::multiplies<NbElts_t>()); + NbElts_t n = getNbElts(); ptr->copy(getDataAddress(), n); } return detail::pimpl::ImplPtr_t(ptr); diff --git a/unit_tests/data/Test_TensorImpl.cpp b/unit_tests/data/Test_TensorImpl.cpp index 203d4dc93f948b34dfb8f014111c82690a3ef5f8..e2a8840b4a9179c316d3fd2eb06197c25c6bb09d 100644 --- a/unit_tests/data/Test_TensorImpl.cpp +++ b/unit_tests/data/Test_TensorImpl.cpp @@ -24,7 +24,6 @@ template<typename Data_T> bool MakeRainbow(Tensor &i_Tensor) { NbElts_t N = i_Tensor.size(); Data_T *data = reinterpret_cast<Data_T *>(i_Tensor.getImpl().rawPtr()); - Data_T *end = data + N; for (std::size_t i = 0; i < N; ++i, ++data) { *data = i; @@ -189,12 +188,11 @@ TEST_CASE("Tensor extract") { SECTION("shallow extract") { - // Tensor Rainbow; - // Rainbow.resize({2, 4, 5}); - // Rainbow.setDatatype(DataType::UInt16); - // Rainbow.setBackend("cpu"); - // MakeRainbow<std::uint16_t>(Rainbow); - + Tensor Rainbow; + Rainbow.resize({2, 4, 5}); + Rainbow.setDatatype(DataType::UInt16); + Rainbow.setBackend("cpu"); + MakeRainbow<std::uint16_t>(Rainbow); // Tensor view(Rainbow, {2, 2, 3}, {0, 1, 1}); // for (Coord_t a = 0; a < view.dims()[0]; ++a) // {