From b9b5fa3abdccf83e77015908085eabfa7b033859 Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Mon, 7 Apr 2025 15:06:50 +0200 Subject: [PATCH] Fixed wrong offsets --- .../cpu/operator/ConvDepthWiseImpl_kernels.hpp | 4 ++-- .../aidge/backend/cpu/operator/ConvImpl_kernels.hpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp b/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp index 3019b1d2..aac83b1b 100644 --- a/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp +++ b/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp @@ -210,8 +210,8 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& stri const std::size_t wIndex = ch; if (strideDims[0] == 1 && strideDims[1] == 1) { - for (std::size_t i = iIndex; i < iIndex + oxSize*oySize; ++i) { - output[oIndex + i] = biasVal + weights[wIndex] * input[i]; + for (std::size_t i = 0; i < oxSize*oySize; ++i) { + output[oIndex + i] = biasVal + weights[wIndex] * input[iIndex + i]; } } else { for (std::size_t ox = 0; ox < oxSize; ++ox, oIndex+=oySize, iIndex+=strideDims[0]*inputDims[3]) { diff --git a/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp b/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp index d7276160..fc3904ad 100644 --- a/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp +++ b/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp @@ -486,13 +486,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims, #endif for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) { for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) { - std::size_t oIndex = (outCh + batch*inputDims[1]) * outChannels_s; + std::size_t oIndex = (outCh + batch*outChannels) * outChannels_s; // If bias = nullptr, set B(0) B biasVal = (biases != nullptr) ? biases[outCh] : B(0); std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal); for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) { - oIndex = (outCh + batch*inputDims[1]) * outChannels_s; + oIndex = (outCh + batch*outChannels) * outChannels_s; std::size_t iIndex = (inCh + batch * inputDims[1]) * inputDims[2] * inputDims[3]; const std::size_t wIndex = @@ -575,13 +575,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims, #endif for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) { for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) { - std::size_t oIndex = (outCh + batch*inputDims[1]) * outChannels_s; + std::size_t oIndex = (outCh + batch*outChannels) * outChannels_s; // If bias = nullptr, set B(0) B biasVal = (biases != nullptr) ? biases[outCh] : B(0); std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal); for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) { - oIndex = (outCh + batch*inputDims[1]) * outChannels_s; + oIndex = (outCh + batch*outChannels) * outChannels_s; std::size_t iIndex = (inCh + batch * inputDims[1]) * inputDims[2] * inputDims[3]; const std::size_t wIndex = (inCh + outCh * inputDims[1]); @@ -611,13 +611,13 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims, #endif for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) { for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) { - std::size_t oIndex = (outCh + batch*inputDims[1]) * outChannels_s; + std::size_t oIndex = (outCh + batch*outChannels) * outChannels_s; // If bias = nullptr, set B(0) B biasVal = (biases != nullptr) ? biases[outCh] : B(0); std::fill(output + oIndex, output + oIndex + outChannels_s, biasVal); for (std::size_t inCh = 0; inCh < inputDims[1]; ++inCh) { - oIndex = (outCh + batch*inputDims[1]) * outChannels_s; + oIndex = (outCh + batch*outChannels) * outChannels_s; std::size_t iIndex_channel = (inCh + batch * inputDims[1]) * inputDims[2] * inputDims[3]; -- GitLab