mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Represent threat weights directly as i8
LEB128 adds no additional compression and adds extra complexity to the code currently. closes https://github.com/official-stockfish/Stockfish/pull/6479 No functional change
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ namespace Eval {
|
||||
// for the build process (profile-build and fishtest) to work. Do not change the
|
||||
// name of the macro or the location where this macro is defined, as it is used
|
||||
// in the Makefile/Fishtest.
|
||||
#define EvalFileDefaultNameBig "nn-2962dca31855.nnue"
|
||||
#define EvalFileDefaultNameBig "nn-c288c895ea92.nnue"
|
||||
#define EvalFileDefaultNameSmall "nn-37f18f62d772.nnue"
|
||||
|
||||
namespace NNUE {
|
||||
|
||||
@@ -164,23 +164,13 @@ class FeatureTransformer {
|
||||
|
||||
if (UseThreats)
|
||||
{
|
||||
auto combinedWeights =
|
||||
std::make_unique<std::array<WeightType, HalfDimensions * TotalInputDimensions>>();
|
||||
read_little_endian<ThreatWeightType>(stream, threatWeights.data(),
|
||||
ThreatInputDimensions * HalfDimensions);
|
||||
read_leb_128<WeightType>(stream, weights);
|
||||
|
||||
auto combinedPsqtWeights =
|
||||
std::make_unique<std::array<PSQTWeightType, TotalInputDimensions * PSQTBuckets>>();
|
||||
|
||||
read_leb_128<WeightType>(stream, *combinedWeights);
|
||||
|
||||
std::transform(combinedWeights->begin(),
|
||||
combinedWeights->begin() + ThreatInputDimensions * HalfDimensions,
|
||||
std::begin(threatWeights),
|
||||
[](WeightType w) { return static_cast<ThreatWeightType>(w); });
|
||||
|
||||
std::copy(combinedWeights->begin() + ThreatInputDimensions * HalfDimensions,
|
||||
combinedWeights->begin()
|
||||
+ (ThreatInputDimensions + InputDimensions) * HalfDimensions,
|
||||
std::begin(weights));
|
||||
|
||||
read_leb_128<PSQTWeightType>(stream, *combinedPsqtWeights);
|
||||
|
||||
std::copy(combinedPsqtWeights->begin(),
|
||||
@@ -219,21 +209,13 @@ class FeatureTransformer {
|
||||
|
||||
if (UseThreats)
|
||||
{
|
||||
auto combinedWeights =
|
||||
std::make_unique<std::array<WeightType, HalfDimensions * TotalInputDimensions>>();
|
||||
write_little_endian<ThreatWeightType>(stream, copy->threatWeights.data(),
|
||||
ThreatInputDimensions * HalfDimensions);
|
||||
write_leb_128<WeightType>(stream, copy->weights);
|
||||
|
||||
auto combinedPsqtWeights =
|
||||
std::make_unique<std::array<PSQTWeightType, TotalInputDimensions * PSQTBuckets>>();
|
||||
|
||||
std::copy(std::begin(copy->threatWeights),
|
||||
std::begin(copy->threatWeights) + ThreatInputDimensions * HalfDimensions,
|
||||
combinedWeights->begin());
|
||||
|
||||
std::copy(std::begin(copy->weights),
|
||||
std::begin(copy->weights) + InputDimensions * HalfDimensions,
|
||||
combinedWeights->begin() + ThreatInputDimensions * HalfDimensions);
|
||||
|
||||
write_leb_128<WeightType>(stream, *combinedWeights);
|
||||
|
||||
std::copy(std::begin(copy->threatPsqtWeights),
|
||||
std::begin(copy->threatPsqtWeights) + ThreatInputDimensions * PSQTBuckets,
|
||||
combinedPsqtWeights->begin());
|
||||
|
||||
Reference in New Issue
Block a user