]> 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 d5aa6fbfbd1a2d7640332e3e139aa373e57f4873..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 {
@@ -168,7 +172,7 @@ 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));
       }
     }
   };