]> git.sesse.net Git - stockfish/blob - src/nnue/layers/input_slice.h
Update copyright years
[stockfish] / src / nnue / layers / input_slice.h
1 /*
2   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3   Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
4
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.
9
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.
14
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/>.
17 */
18
19 // NNUE evaluation function layer InputSlice definition
20
21 #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
22 #define NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
23
24 #include "../nnue_common.h"
25
26 namespace Eval::NNUE::Layers {
27
28 // Input layer
29 template <IndexType OutputDimensions, IndexType Offset = 0>
30 class InputSlice {
31  public:
32   // Need to maintain alignment
33   static_assert(Offset % kMaxSimdWidth == 0, "");
34
35   // Output type
36   using OutputType = TransformedFeatureType;
37
38   // Output dimensionality
39   static constexpr IndexType kOutputDimensions = OutputDimensions;
40
41   // Size of forward propagation buffer used from the input layer to this layer
42   static constexpr std::size_t kBufferSize = 0;
43
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);
48     return hash_value;
49   }
50
51   // Read network parameters
52   bool ReadParameters(std::istream& /*stream*/) {
53     return true;
54   }
55
56   // Forward propagation
57   const OutputType* Propagate(
58       const TransformedFeatureType* transformed_features,
59       char* /*buffer*/) const {
60     return transformed_features + Offset;
61   }
62
63  private:
64 };
65
66 }  // namespace Layers
67
68 #endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED