2 Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3 Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
5 Stockfish is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 Stockfish is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 // NNUE evaluation function layer InputSlice definition
21 #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
22 #define NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
24 #include "../nnue_common.h"
26 namespace Stockfish::Eval::NNUE::Layers {
29 template <IndexType OutputDimensions, IndexType Offset = 0>
32 // Need to maintain alignment
33 static_assert(Offset % kMaxSimdWidth == 0, "");
36 using OutputType = TransformedFeatureType;
38 // Output dimensionality
39 static constexpr IndexType kOutputDimensions = OutputDimensions;
41 // Size of forward propagation buffer used from the input layer to this layer
42 static constexpr std::size_t kBufferSize = 0;
44 // Hash value embedded in the evaluation file
45 static constexpr std::uint32_t GetHashValue() {
46 std::uint32_t hash_value = 0xEC42E90Du;
47 hash_value ^= kOutputDimensions ^ (Offset << 10);
51 // Read network parameters
52 bool ReadParameters(std::istream& /*stream*/) {
56 // Forward propagation
57 const OutputType* Propagate(
58 const TransformedFeatureType* transformed_features,
59 char* /*buffer*/) const {
60 return transformed_features + Offset;
66 } // namespace Stockfish::Eval::NNUE::Layers
68 #endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED