From 2ee083eaa7c23073ae343731562b10f0de3b4a2b Mon Sep 17 00:00:00 2001
From: cmoineau <cyril.moineau@cea.fr>
Date: Thu, 14 Mar 2024 13:46:00 +0000
Subject: [PATCH] Update Conv & ConvDW to handle noBias parameter.

---
 .../backend/cpu/operator/ConvDepthWiseImpl_forward_kernels.hpp | 2 +-
 .../aidge/backend/cpu/operator/ConvImpl_forward_kernels.hpp    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_forward_kernels.hpp b/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_forward_kernels.hpp
index 95a1aaec..801bd315 100644
--- a/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_forward_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_forward_kernels.hpp
@@ -64,7 +64,7 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const ConvDepthWise_Op<2>::Attrs &at
     for (std::size_t batch = 0; batch < dims[0]; ++batch) {
         for (std::size_t ch = 0; ch < std::get<2>(attrs); ++ch) {
             const std::size_t oIndex = (ch + batch*std::get<2>(attrs)) * oxSize * oySize;
-            B biasVal = (biases != nullptr) ? biases[ch] : B(0);
+            B biasVal = ((!std::get<4>(attrs)) && biases != nullptr) ? biases[ch] : B(0);
             std::fill(output + oIndex, output+(oIndex+oxSize*oySize), biasVal);
             const std::size_t iIndex = (ch + batch*dims[1]) * dims[2] * dims[3];
             const std::size_t wIndex = ch * std::get<3>(attrs)[0] * std::get<3>(attrs)[1];
diff --git a/include/aidge/backend/cpu/operator/ConvImpl_forward_kernels.hpp b/include/aidge/backend/cpu/operator/ConvImpl_forward_kernels.hpp
index 83607f28..00d34f65 100644
--- a/include/aidge/backend/cpu/operator/ConvImpl_forward_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/ConvImpl_forward_kernels.hpp
@@ -106,7 +106,8 @@ void ConvImpl2D_cpu_forward_kernel(const Conv_Op<2>::Attrs &attrs, const std::ar
     for (std::size_t batch = 0; batch < dims[0]; ++batch) {
         for (std::size_t outCh = 0; outCh < std::get<3>(attrs); ++outCh) {
             const std::size_t oIndex = (outCh + batch*std::get<3>(attrs)) * oxSize * oySize;
-            B biasVal = (biases != nullptr) ? biases[outCh] : B(0);
+            // If  NoBias or bias = nullptr, set B(0)
+            B biasVal = ((!std::get<5>(attrs)) && biases != nullptr) ? biases[outCh] : B(0);
             std::fill(output + oIndex, output+(oIndex+oxSize*oySize), biasVal);
             for (std::size_t inCh = 0; inCh < dims[1]; ++inCh) {
                 const std::size_t iIndex = (inCh + batch*dims[1]) * dims[2] * dims[3];
-- 
GitLab