]> git.sesse.net Git - stockfish/blobdiff - src/nnue/layers/sqr_clipped_relu.h
Sparse impl of affine_transform_non_ssse3()
[stockfish] / src / nnue / layers / sqr_clipped_relu.h
index 503b283b25e53b7ef1590b526c50d21b0582a224..a3d2059b4de1fc0d0086b48352a41e5731bf3ab9 100644 (file)
@@ -96,9 +96,9 @@ namespace Stockfish::Eval::NNUE::Layers {
 
       for (IndexType i = Start; i < InputDimensions; ++i) {
         output[i] = static_cast<OutputType>(
-            // really should be /127 but we need to make it fast
-            // needs to be accounted for in the trainer
-            std::min(127ll, (((long long)input[i] * input[i]) >> (2 * WeightScaleBits)) / 128));
+            // Really should be /127 but we need to make it fast so we right shift
+            // by an extra 7 bits instead. Needs to be accounted for in the trainer.
+            std::min(127ll, ((long long)input[i] * input[i]) >> (2 * WeightScaleBits + 7)));
       }
     }
   };