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 OutDims, IndexType Offset = 0>
32 // Need to maintain alignment
33 static_assert(Offset % MaxSimdWidth == 0, "");
36 using OutputType = TransformedFeatureType;
38 // Output dimensionality
39 static constexpr IndexType OutputDimensions = OutDims;
41 // Size of forward propagation buffer used from the input layer to this layer
42 static constexpr std::size_t BufferSize = 0;
44 // Hash value embedded in the evaluation file
45 static constexpr std::uint32_t get_hash_value() {
46 std::uint32_t hashValue = 0xEC42E90Du;
47 hashValue ^= OutputDimensions ^ (Offset << 10);
51 // Read network parameters
52 bool read_parameters(std::istream& /*stream*/) {
56 // Write network parameters
57 bool write_parameters(std::ostream& /*stream*/) const {
61 // Forward propagation
62 const OutputType* propagate(
63 const TransformedFeatureType* transformedFeatures,
64 char* /*buffer*/) const {
65 return transformedFeatures + Offset;
71 } // namespace Stockfish::Eval::NNUE::Layers
73 #endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED