Line data Source code
1 : #pragma once
2 :
3 : #include "definition.hpp"
4 :
5 : #ifdef WITH_NNUE
6 :
7 : #include "dynamicConfig.hpp"
8 : #include "logging.hpp"
9 : #include "nnueImpl.hpp"
10 :
11 : // Internal wrapper to the NNUE things
12 : namespace NNUEWrapper {
13 :
14 : using nnueNType = float; // type of data inside the binary net (currently floats)
15 : inline constexpr bool quantization = true; // only for input layer
16 :
17 22 : inline void init() {
18 : bool loadOk = false;
19 22 : const bool shallLoadNNUE = !DynamicConfig::NNUEFile.empty() && DynamicConfig::NNUEFile != "none";
20 : if (shallLoadNNUE) {
21 22 : Logging::LogIt(Logging::logInfoPrio) << "Loading NNUE net " << DynamicConfig::NNUEFile;
22 22 : loadOk = nnue::NNUEWeights<nnueNType, quantization>::load(DynamicConfig::NNUEFile, nnue::NNUEEval<nnueNType, quantization>::weights);
23 : }
24 : else {
25 0 : Logging::LogIt(Logging::logInfoPrio) << "No NNUE net given";
26 : }
27 :
28 22 : if (loadOk) {
29 22 : DynamicConfig::useNNUE = true;
30 : }
31 : else {
32 0 : if (shallLoadNNUE) Logging::LogIt(Logging::logInfoPrio) << "Fail to load NNUE net(s), using standard evaluation instead";
33 : else
34 0 : Logging::LogIt(Logging::logInfoPrio) << "Using standard evaluation";
35 0 : DynamicConfig::useNNUE = false;
36 : }
37 22 : }
38 :
39 : } // namespace NNUEWrapper
40 :
41 : using NNUEEvaluator = nnue::NNUEEval<NNUEWrapper::nnueNType, NNUEWrapper::quantization>;
42 :
43 : #ifdef WITH_DATA2BIN
44 : #include "learn/convert.hpp"
45 : #endif
46 :
47 : #endif // WITH_NNUE
|