mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-26 12:06:22 +08:00
Refactor Network Usage
Continuing from PR #4968, this update improves how Stockfish handles network usage, making it easier to manage and modify networks in the future. With the introduction of a dedicated Network class, creating networks has become straightforward. See uci.cpp: ```cpp NN::NetworkBig({EvalFileDefaultNameBig, "None", ""}, NN::embeddedNNUEBig) ``` The new `Network` encapsulates all network-related logic, significantly reducing the complexity previously required to support multiple network types, such as the distinction between small and big networks #4915. Non-Regression STC: https://tests.stockfishchess.org/tests/view/65edd26c0ec64f0526c43584 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 33760 W: 8887 L: 8661 D: 16212 Ptnml(0-2): 143, 3795, 8808, 3961, 173 Non-Regression SMP STC: https://tests.stockfishchess.org/tests/view/65ed71970ec64f0526c42fdd LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 59088 W: 15121 L: 14931 D: 29036 Ptnml(0-2): 110, 6640, 15829, 6880, 85 Compiled with `make -j profile-build` ``` bash ./bench_parallel.sh ./stockfish ./stockfish-nnue 13 50 sf_base = 1568540 +/- 7637 (95%) sf_test = 1573129 +/- 7301 (95%) diff = 4589 +/- 8720 (95%) speedup = 0.29260% +/- 0.556% (95%) ``` Compiled with `make -j build` ``` bash ./bench_parallel.sh ./stockfish ./stockfish-nnue 13 50 sf_base = 1472653 +/- 7293 (95%) sf_test = 1491928 +/- 7661 (95%) diff = 19275 +/- 7154 (95%) speedup = 1.30886% +/- 0.486% (95%) ``` closes https://github.com/official-stockfish/Stockfish/pull/5100 No functional change
This commit is contained in:
@@ -20,51 +20,33 @@
|
||||
#define EVALUATE_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace Stockfish {
|
||||
|
||||
class Position;
|
||||
class OptionsMap;
|
||||
|
||||
namespace Eval {
|
||||
|
||||
constexpr inline int SmallNetThreshold = 1139, PsqtOnlyThreshold = 2500;
|
||||
|
||||
std::string trace(Position& pos);
|
||||
|
||||
int simple_eval(const Position& pos, Color c);
|
||||
Value evaluate(const Position& pos, int optimism);
|
||||
|
||||
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
|
||||
// for the build process (profile-build and fishtest) to work. Do not change the
|
||||
// name of the macro, as it is used in the Makefile.
|
||||
// name of the macro or the location where this macro is defined, as it is used
|
||||
// in the Makefile/Fishtest.
|
||||
#define EvalFileDefaultNameBig "nn-1ceb1ade0001.nnue"
|
||||
#define EvalFileDefaultNameSmall "nn-baff1ede1f90.nnue"
|
||||
|
||||
struct EvalFile {
|
||||
// UCI option name
|
||||
std::string optionName;
|
||||
// Default net name, will use one of the macros above
|
||||
std::string defaultName;
|
||||
// Selected net name, either via uci option or default
|
||||
std::string current;
|
||||
// Net description extracted from the net file
|
||||
std::string netDescription;
|
||||
};
|
||||
|
||||
namespace NNUE {
|
||||
struct Networks;
|
||||
}
|
||||
|
||||
enum NetSize : int;
|
||||
std::string trace(Position& pos, const Eval::NNUE::Networks& networks);
|
||||
|
||||
using EvalFiles = std::unordered_map<Eval::NNUE::NetSize, EvalFile>;
|
||||
int simple_eval(const Position& pos, Color c);
|
||||
Value evaluate(const NNUE::Networks& networks, const Position& pos, int optimism);
|
||||
|
||||
EvalFiles load_networks(const std::string&, const OptionsMap&, EvalFiles);
|
||||
void verify(const OptionsMap&, const EvalFiles&);
|
||||
|
||||
} // namespace NNUE
|
||||
|
||||
} // namespace Eval
|
||||
|
||||
|
||||
Reference in New Issue
Block a user