1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Remove unused return type from propagate()

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
This commit is contained in:
mstembera 2023-07-24 19:02:49 -07:00 committed by Stéphane Nicolet
parent 2667316ffc
commit cb22520a9c
4 changed files with 8 additions and 17 deletions

View file

@ -171,7 +171,7 @@ namespace Stockfish::Eval::NNUE::Layers {
return hashValue; return hashValue;
} }
static IndexType get_weight_index_scrambled(IndexType i) static constexpr IndexType get_weight_index_scrambled(IndexType i)
{ {
return return
(i / 4) % (PaddedInputDimensions / 4) * OutputDimensions * 4 + (i / 4) % (PaddedInputDimensions / 4) * OutputDimensions * 4 +
@ -179,7 +179,7 @@ namespace Stockfish::Eval::NNUE::Layers {
i % 4; i % 4;
} }
static IndexType get_weight_index(IndexType i) static constexpr IndexType get_weight_index(IndexType i)
{ {
#if defined (USE_SSSE3) #if defined (USE_SSSE3)
return get_weight_index_scrambled(i); return get_weight_index_scrambled(i);
@ -207,7 +207,7 @@ namespace Stockfish::Eval::NNUE::Layers {
return !stream.fail(); return !stream.fail();
} }
// Forward propagation // Forward propagation
const OutputType* propagate( void propagate(
const InputType* input, OutputType* output) const { const InputType* input, OutputType* output) const {
#if defined (USE_AVX512) #if defined (USE_AVX512)
@ -291,8 +291,6 @@ namespace Stockfish::Eval::NNUE::Layers {
PaddedInputDimensions, PaddedInputDimensions,
OutputDimensions>(output, weights, biases, input); OutputDimensions>(output, weights, biases, input);
#endif #endif
return output;
} }
private: private:

View file

@ -102,7 +102,6 @@ namespace Stockfish::Eval::NNUE::Layers {
template <IndexType InDims, IndexType OutDims> template <IndexType InDims, IndexType OutDims>
class AffineTransformSparseInput { class AffineTransformSparseInput {
public: public:
// Input/output type
// Input/output type // Input/output type
using InputType = std::uint8_t; using InputType = std::uint8_t;
using OutputType = std::int32_t; using OutputType = std::int32_t;
@ -135,7 +134,7 @@ namespace Stockfish::Eval::NNUE::Layers {
return hashValue; return hashValue;
} }
static IndexType get_weight_index_scrambled(IndexType i) static constexpr IndexType get_weight_index_scrambled(IndexType i)
{ {
return return
(i / ChunkSize) % (PaddedInputDimensions / ChunkSize) * OutputDimensions * ChunkSize + (i / ChunkSize) % (PaddedInputDimensions / ChunkSize) * OutputDimensions * ChunkSize +
@ -143,7 +142,7 @@ namespace Stockfish::Eval::NNUE::Layers {
i % ChunkSize; i % ChunkSize;
} }
static IndexType get_weight_index(IndexType i) static constexpr IndexType get_weight_index(IndexType i)
{ {
#if defined (USE_SSSE3) #if defined (USE_SSSE3)
return get_weight_index_scrambled(i); return get_weight_index_scrambled(i);
@ -171,7 +170,7 @@ namespace Stockfish::Eval::NNUE::Layers {
return !stream.fail(); return !stream.fail();
} }
// Forward propagation // Forward propagation
const OutputType* propagate( void propagate(
const InputType* input, OutputType* output) const { const InputType* input, OutputType* output) const {
#if defined (USE_SSSE3) #if defined (USE_SSSE3)
@ -230,8 +229,6 @@ namespace Stockfish::Eval::NNUE::Layers {
PaddedInputDimensions, PaddedInputDimensions,
OutputDimensions>(output, weights, biases, input); OutputDimensions>(output, weights, biases, input);
#endif #endif
return output;
} }
private: private:

View file

@ -59,7 +59,7 @@ namespace Stockfish::Eval::NNUE::Layers {
} }
// Forward propagation // Forward propagation
const OutputType* propagate( void propagate(
const InputType* input, OutputType* output) const { const InputType* input, OutputType* output) const {
#if defined(USE_AVX2) #if defined(USE_AVX2)
@ -170,8 +170,6 @@ namespace Stockfish::Eval::NNUE::Layers {
output[i] = static_cast<OutputType>( output[i] = static_cast<OutputType>(
std::max(0, std::min(127, input[i] >> WeightScaleBits))); std::max(0, std::min(127, input[i] >> WeightScaleBits)));
} }
return output;
} }
}; };

View file

@ -59,7 +59,7 @@ namespace Stockfish::Eval::NNUE::Layers {
} }
// Forward propagation // Forward propagation
const OutputType* propagate( void propagate(
const InputType* input, OutputType* output) const { const InputType* input, OutputType* output) const {
#if defined(USE_SSE2) #if defined(USE_SSE2)
@ -110,8 +110,6 @@ namespace Stockfish::Eval::NNUE::Layers {
// needs to be accounted for in the trainer // needs to be accounted for in the trainer
std::max(0ll, std::min(127ll, (((long long)input[i] * input[i]) >> (2 * WeightScaleBits)) / 128))); std::max(0ll, std::min(127ll, (((long long)input[i] * input[i]) >> (2 * WeightScaleBits)) / 128)));
} }
return output;
} }
}; };