]> git.sesse.net Git - stockfish/commitdiff
Remove unused return type from propagate()
authormstembera <MissingEmail@email>
Tue, 25 Jul 2023 02:02:49 +0000 (19:02 -0700)
committerStéphane Nicolet <cassio@free.fr>
Fri, 28 Jul 2023 21:24:42 +0000 (23:24 +0200)
Also make two get_weight_index() static methods constexpr, for
consistency with the other static get_hash_value() method right above.
Tested for speed by user Torom (thanks).

closes https://github.com/official-stockfish/Stockfish/pull/4708

No functional change

src/nnue/layers/affine_transform.h
src/nnue/layers/affine_transform_sparse_input.h
src/nnue/layers/clipped_relu.h
src/nnue/layers/sqr_clipped_relu.h

index b0169306cb7c275f75a5f72e43c57f7f8299b08f..c936a83ed66278057934bde9f189b9938a07f49c 100644 (file)
@@ -171,7 +171,7 @@ namespace Stockfish::Eval::NNUE::Layers {
       return hashValue;
     }
 
-    static IndexType get_weight_index_scrambled(IndexType i)
+    static constexpr IndexType get_weight_index_scrambled(IndexType i)
     {
       return
         (i / 4) % (PaddedInputDimensions / 4) * OutputDimensions * 4 +
@@ -179,7 +179,7 @@ namespace Stockfish::Eval::NNUE::Layers {
         i % 4;
     }
 
-    static IndexType get_weight_index(IndexType i)
+    static constexpr IndexType get_weight_index(IndexType i)
     {
 #if defined (USE_SSSE3)
       return get_weight_index_scrambled(i);
@@ -207,7 +207,7 @@ namespace Stockfish::Eval::NNUE::Layers {
       return !stream.fail();
     }
     // Forward propagation
-    const OutputType* propagate(
+    void propagate(
         const InputType* input, OutputType* output) const {
 
 #if defined (USE_AVX512)
@@ -291,8 +291,6 @@ namespace Stockfish::Eval::NNUE::Layers {
         PaddedInputDimensions,
         OutputDimensions>(output, weights, biases, input);
 #endif
-
-      return output;
     }
 
    private:
index a5bea08e74b3fbaea0431a5daf2329d83288e605..134b7d13e191ab8a148b4d458c24d9100540e877 100644 (file)
@@ -102,7 +102,6 @@ namespace Stockfish::Eval::NNUE::Layers {
   template <IndexType InDims, IndexType OutDims>
   class AffineTransformSparseInput {
    public:
-    // Input/output type
     // Input/output type
     using InputType = std::uint8_t;
     using OutputType = std::int32_t;
@@ -135,7 +134,7 @@ namespace Stockfish::Eval::NNUE::Layers {
       return hashValue;
     }
 
-    static IndexType get_weight_index_scrambled(IndexType i)
+    static constexpr IndexType get_weight_index_scrambled(IndexType i)
     {
       return
         (i / ChunkSize) % (PaddedInputDimensions / ChunkSize) * OutputDimensions * ChunkSize +
@@ -143,7 +142,7 @@ namespace Stockfish::Eval::NNUE::Layers {
         i % ChunkSize;
     }
 
-    static IndexType get_weight_index(IndexType i)
+    static constexpr IndexType get_weight_index(IndexType i)
     {
 #if defined (USE_SSSE3)
       return get_weight_index_scrambled(i);
@@ -171,7 +170,7 @@ namespace Stockfish::Eval::NNUE::Layers {
       return !stream.fail();
     }
     // Forward propagation
-    const OutputType* propagate(
+    void propagate(
         const InputType* input, OutputType* output) const {
 
 #if defined (USE_SSSE3)
@@ -230,8 +229,6 @@ namespace Stockfish::Eval::NNUE::Layers {
         PaddedInputDimensions,
         OutputDimensions>(output, weights, biases, input);
 #endif
-
-      return output;
     }
 
    private:
index 51e562dad34ae4d820c459035213be51b167d25f..d5aa6fbfbd1a2d7640332e3e139aa373e57f4873 100644 (file)
@@ -59,7 +59,7 @@ namespace Stockfish::Eval::NNUE::Layers {
     }
 
     // Forward propagation
-    const OutputType* propagate(
+    void propagate(
         const InputType* input, OutputType* output) const {
 
   #if defined(USE_AVX2)
@@ -170,8 +170,6 @@ namespace Stockfish::Eval::NNUE::Layers {
         output[i] = static_cast<OutputType>(
             std::max(0, std::min(127, input[i] >> WeightScaleBits)));
       }
-
-      return output;
     }
   };
 
index 3fbb243cfd6c38371183e8ebec459f822fa01cb6..69bd51471d7fac875d6f7453f8f6b1f0cce3be9f 100644 (file)
@@ -59,7 +59,7 @@ namespace Stockfish::Eval::NNUE::Layers {
     }
 
     // Forward propagation
-    const OutputType* propagate(
+    void propagate(
         const InputType* input, OutputType* output) const {
 
   #if defined(USE_SSE2)
@@ -110,8 +110,6 @@ namespace Stockfish::Eval::NNUE::Layers {
             // needs to be accounted for in the trainer
             std::max(0ll, std::min(127ll, (((long long)input[i] * input[i]) >> (2 * WeightScaleBits)) / 128)));
       }
-
-      return output;
     }
   };