From c08a3fa7616efb157fc84f1a357f3ac5349e8a33 Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Fri, 4 Apr 2025 10:06:54 +0200
Subject: [PATCH] Fixed Windows build

---
 .../cpu/operator/AvgPoolingImpl_kernels.hpp      |  4 ++--
 .../cpu/operator/BatchNormImpl_kernels.hpp       |  4 ++--
 .../cpu/operator/ConvDepthWiseImpl_kernels.hpp   | 16 ++++++++--------
 .../backend/cpu/operator/ConvImpl_kernels.hpp    | 16 ++++++++--------
 .../GlobalAveragePoolingImpl_kernels.hpp         |  4 ++--
 .../cpu/operator/MaxPoolingImpl_kernels.hpp      |  4 ++--
 .../backend/cpu/operator/SoftmaxImpl_kernels.hpp |  4 ++--
 7 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/include/aidge/backend/cpu/operator/AvgPoolingImpl_kernels.hpp b/include/aidge/backend/cpu/operator/AvgPoolingImpl_kernels.hpp
index 0d73cb91..e7bc3a2b 100644
--- a/include/aidge/backend/cpu/operator/AvgPoolingImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/AvgPoolingImpl_kernels.hpp
@@ -79,8 +79,8 @@ void AvgPoolingImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& strideD
 #ifdef _OPENMP
     #pragma omp parallel for collapse(2) if (dims[0] * dims[1] > 32)
 #endif
-    for (std::size_t batch = 0; batch < dims[0]; ++batch) {
-        for (std::size_t ch = 0; ch < dims[1]; ++ch) {
+    for (int batch = 0; batch < static_cast<int>(dims[0]); ++batch) {
+        for (int ch = 0; ch < static_cast<int>(dims[1]); ++ch) {
             const std::size_t oIndex = (ch + batch * dims[1]) * oxSize * oySize;
             const std::size_t iIndex = (ch + batch * dims[1]) * dims[2] * dims[3];
 
diff --git a/include/aidge/backend/cpu/operator/BatchNormImpl_kernels.hpp b/include/aidge/backend/cpu/operator/BatchNormImpl_kernels.hpp
index 7bb7971e..105a3300 100644
--- a/include/aidge/backend/cpu/operator/BatchNormImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/BatchNormImpl_kernels.hpp
@@ -56,8 +56,8 @@ void BatchNormImpl2D_cpu_forward_kernel(float epsilon, float momentum, const std
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (nbBatch * nbChannels > 32)
 #endif
-        for (std::size_t batch = 0; batch < nbBatch; ++batch) {
-            for (std::size_t ch = 0; ch < nbChannels; ++ch) {
+        for (int batch = 0; batch < static_cast<int>(nbBatch); ++batch) {
+            for (int ch = 0; ch < static_cast<int>(nbChannels); ++ch) {
                 const std::size_t ioIndex = (ch + batch*nbChannels) * featureMapSize;
                 std::fill(output + ioIndex, output + ioIndex + featureMapSize, shift[ch]);
                 const P var = std::sqrt(batchVar[ch] + static_cast<P>(epsilon));
diff --git a/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp b/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp
index b16a819b..3019b1d2 100644
--- a/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/ConvDepthWiseImpl_kernels.hpp
@@ -68,8 +68,8 @@ void ConvDepthWiseImpl1D_cpu_forward_kernel(const std::array<DimSize_t, 1>& stri
 #ifdef _OPENMP
     #pragma omp parallel for collapse(2) if (inputDims[0] * inputDims[1] > 32)
 #endif
-    for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-        for (std::size_t ch = 0; ch < inputDims[1]; ++ch) {
+    for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
+        for (int ch = 0; ch < static_cast<int>(inputDims[1]); ++ch) {
             const std::size_t oIndex = (ch + batch*inputDims[1]) * oxSize;
             B biasVal = (biases != nullptr) ? biases[ch] : B(0);
             std::fill(output + oIndex, output+(oIndex+oxSize), biasVal);
@@ -158,8 +158,8 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& stri
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (inputDims[0] * inputDims[1] > 32)
 #endif
-        for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-            for (std::size_t ch = 0; ch < inputDims[1]; ++ch) {
+        for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
+            for (int ch = 0; ch < static_cast<int>(inputDims[1]); ++ch) {
                 B biasVal = (biases != nullptr) ? biases[ch] : B(0);
 
                 std::size_t oIndex = (ch + batch*inputDims[1]) * outChannels_s;
@@ -201,8 +201,8 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& stri
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (inputDims[0] * inputDims[1] > 32)
 #endif
-        for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-            for (std::size_t ch = 0; ch < inputDims[1]; ++ch) {
+        for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
+            for (int ch = 0; ch < static_cast<int>(inputDims[1]); ++ch) {
                 B biasVal = (biases != nullptr) ? biases[ch] : B(0);
 
                 std::size_t oIndex = (ch + batch*inputDims[1]) * outChannels_s;
@@ -226,8 +226,8 @@ void ConvDepthWiseImpl2D_cpu_forward_kernel(const std::array<DimSize_t, 2>& stri
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (inputDims[0] * inputDims[1] > 32)
 #endif
-        for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-            for (std::size_t ch = 0; ch < inputDims[1]; ++ch) {
+        for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
+            for (int ch = 0; ch < static_cast<int>(inputDims[1]); ++ch) {
                 const std::size_t oIndex = (ch + batch*inputDims[1]) * outChannels_s;
                 const std::size_t iIndex = (ch + batch*inputDims[1]) * inputDims[2] * inputDims[3];
                 const std::size_t wIndex = ch * kernelDims[0] * kernelDims[1];
diff --git a/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp b/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp
index b1cd006e..d7276160 100644
--- a/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/ConvImpl_kernels.hpp
@@ -62,8 +62,8 @@ void ConvImpl1D_cpu_forward_kernel(const array<DimSize_t, 1> &strideDim,
 #ifdef _OPENMP
     #pragma omp parallel for collapse(2) if (inputDims[0] * outChannels > 32)
 #endif
-    for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-        for (std::size_t outCh = 0; outCh < outChannels; ++outCh) {
+    for (int batch = 0; batch < static_cast<int>(inputDims[0]); ++batch) {
+        for (int outCh = 0; outCh < static_cast<int>(outChannels); ++outCh) {
             const std::size_t oIndex = (outCh + batch * outChannels) * oxSize;
             // If bias = nullptr, set B(0)
             B biasVal = (biases != nullptr) ? biases[outCh] : B(0);
@@ -484,8 +484,8 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims,
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (inputDims[0] * outChannels > 32)
 #endif
-        for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-            for (std::size_t outCh = 0; outCh < outChannels; ++outCh) {
+        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;
 
                 // If bias = nullptr, set B(0)
@@ -573,8 +573,8 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims,
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (inputDims[0] * outChannels > 32)
 #endif
-        for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-            for (std::size_t outCh = 0; outCh < outChannels; ++outCh) {
+        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;
 
                 // If bias = nullptr, set B(0)
@@ -609,8 +609,8 @@ void ConvImpl2D_cpu_forward_kernel(const array<DimSize_t, 2> &strideDims,
 #ifdef _OPENMP
         #pragma omp parallel for collapse(2) if (inputDims[0] * outChannels > 32)
 #endif
-        for (std::size_t batch = 0; batch < inputDims[0]; ++batch) {
-            for (std::size_t outCh = 0; outCh < outChannels; ++outCh) {
+        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;
 
                 // If bias = nullptr, set B(0)
diff --git a/include/aidge/backend/cpu/operator/GlobalAveragePoolingImpl_kernels.hpp b/include/aidge/backend/cpu/operator/GlobalAveragePoolingImpl_kernels.hpp
index 3915adb3..8ff1ad08 100644
--- a/include/aidge/backend/cpu/operator/GlobalAveragePoolingImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/GlobalAveragePoolingImpl_kernels.hpp
@@ -77,8 +77,8 @@ void GlobalAveragePoolingImpl_cpu_forward_kernel(const std::shared_ptr<Tensor>&
 #ifdef _OPENMP
     #pragma omp parallel for collapse(2) if (dims[0] * dims[1] > 32)
 #endif
-    for (DimSize_t batch = 0; batch < dims[0]; ++batch) {
-        for (DimSize_t channel = 0; channel < dims[1]; ++channel) {
+    for (int batch = 0; batch < static_cast<int>(dims[0]); ++batch) {
+        for (int channel = 0; channel < static_cast<int>(dims[1]); ++channel) {
             const I *filter_start = std::next(
                 input, (batch * in_batch_nb_elems) + (channel * in_channel_nb_elems));
             output[batch * out_batch_nb_elems + channel] = castFromFloat<O>(stableMean<I>(filter_start, in_channel_nb_elems));
diff --git a/include/aidge/backend/cpu/operator/MaxPoolingImpl_kernels.hpp b/include/aidge/backend/cpu/operator/MaxPoolingImpl_kernels.hpp
index 9772b0ab..b5f219f9 100644
--- a/include/aidge/backend/cpu/operator/MaxPoolingImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/MaxPoolingImpl_kernels.hpp
@@ -69,8 +69,8 @@ void MaxPoolingImpl2D_cpu_forward_kernel(
 #ifdef _OPENMP
     #pragma omp parallel for collapse(2) if (dims[0] * dims[1] > 32)
 #endif
-  for (std::size_t batch = 0; batch < dims[0]; ++batch){
-    for (std::size_t channel = 0; channel < dims[1]; ++channel){
+  for (int batch = 0; batch < static_cast<int>(dims[0]); ++batch){
+    for (int channel = 0; channel < static_cast<int>(dims[1]); ++channel){
       auto batchChannelIndex = (channel + batch * dims[1]);
       const std::size_t outputBaseIndex = batchChannelIndex * outXSize * outYSize;
       const std::size_t inputBaseIndex = batchChannelIndex * dims[2] * dims[3];
diff --git a/include/aidge/backend/cpu/operator/SoftmaxImpl_kernels.hpp b/include/aidge/backend/cpu/operator/SoftmaxImpl_kernels.hpp
index e74f3518..ab6790e2 100644
--- a/include/aidge/backend/cpu/operator/SoftmaxImpl_kernels.hpp
+++ b/include/aidge/backend/cpu/operator/SoftmaxImpl_kernels.hpp
@@ -40,8 +40,8 @@ void SoftmaxImpl_cpu_forward_kernel(std::size_t axisIdx, const std::vector<DimSi
 #ifdef _OPENMP
     #pragma omp parallel for collapse(2) if (preAxisElems * postAxisElems > 32)
 #endif
-    for (std::size_t i = 0; i < preAxisElems; ++i) {
-        for (std::size_t j = 0; j < postAxisElems; ++j) {
+    for (int i = 0; i < static_cast<int>(preAxisElems); ++i) {
+        for (int j = 0; j < static_cast<int>(postAxisElems); ++j) {
             I maxVal = input[i * inputDims[axisIdx] * postAxisElems + j];
             for (std::size_t k = 1; k < inputDims[axisIdx]; ++k) {
                 std::size_t inIdx = i * inputDims[axisIdx] * postAxisElems + k * postAxisElems + j;
-- 
GitLab