]> git.sesse.net Git - stockfish/blobdiff - src/nnue/layers/clipped_relu.h
Sparse impl of affine_transform_non_ssse3()
[stockfish] / src / nnue / layers / clipped_relu.h
index 51e562dad34ae4d820c459035213be51b167d25f..aab824b357266079c4d7bce15fe4c86b8d684c9b 100644 (file)
 #ifndef NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED
 #define NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED
 
+#include <algorithm>
+#include <cstdint>
+#include <iosfwd>
+
 #include "../nnue_common.h"
 
 namespace Stockfish::Eval::NNUE::Layers {
@@ -59,7 +63,7 @@ namespace Stockfish::Eval::NNUE::Layers {
     }
 
     // Forward propagation
-    const OutputType* propagate(
+    void propagate(
         const InputType* input, OutputType* output) const {
 
   #if defined(USE_AVX2)
@@ -168,10 +172,8 @@ namespace Stockfish::Eval::NNUE::Layers {
 
       for (IndexType i = Start; i < InputDimensions; ++i) {
         output[i] = static_cast<OutputType>(
-            std::max(0, std::min(127, input[i] >> WeightScaleBits)));
+            std::clamp(input[i] >> WeightScaleBits, 0, 127));
       }
-
-      return output;
     }
   };