diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 23bc70d0e..4bbbcaac6 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -59,15 +59,15 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks, assert(!pos.checkers()); bool smallNet = use_smallnet(pos); - auto [psqt, positional] = smallNet ? networks.small.evaluate(pos, accumulators, &caches.small) - : networks.big.evaluate(pos, accumulators, &caches.big); + auto [psqt, positional] = smallNet ? networks.small.evaluate(pos, accumulators, caches.small) + : networks.big.evaluate(pos, accumulators, caches.big); Value nnue = (125 * psqt + 131 * positional) / 128; // Re-evaluate the position when higher eval accuracy is worth the time spent if (smallNet && (std::abs(nnue) < 236)) { - std::tie(psqt, positional) = networks.big.evaluate(pos, accumulators, &caches.big); + std::tie(psqt, positional) = networks.big.evaluate(pos, accumulators, caches.big); nnue = (125 * psqt + 131 * positional) / 128; smallNet = false; } @@ -107,7 +107,7 @@ std::string Eval::trace(Position& pos, const Eval::NNUE::Networks& networks) { ss << std::showpoint << std::showpos << std::fixed << std::setprecision(2) << std::setw(15); - auto [psqt, positional] = networks.big.evaluate(pos, *accumulators, &caches->big); + auto [psqt, positional] = networks.big.evaluate(pos, *accumulators, caches->big); Value v = psqt + positional; v = pos.side_to_move() == WHITE ? v : -v; ss << "NNUE evaluation " << 0.01 * UCIEngine::to_cp(v, pos) << " (white side)\n"; diff --git a/src/nnue/network.cpp b/src/nnue/network.cpp index b91763f06..a4d464df0 100644 --- a/src/nnue/network.cpp +++ b/src/nnue/network.cpp @@ -172,7 +172,7 @@ template NetworkOutput Network::evaluate(const Position& pos, AccumulatorStack& accumulatorStack, - AccumulatorCaches::Cache* cache) const { + AccumulatorCaches::Cache& cache) const { constexpr uint64_t alignment = CacheLineSize; @@ -234,7 +234,7 @@ template NnueEvalTrace Network::trace_evaluate(const Position& pos, AccumulatorStack& accumulatorStack, - AccumulatorCaches::Cache* cache) const { + AccumulatorCaches::Cache& cache) const { constexpr uint64_t alignment = CacheLineSize; diff --git a/src/nnue/network.h b/src/nnue/network.h index c701ac6f5..ba8f469f7 100644 --- a/src/nnue/network.h +++ b/src/nnue/network.h @@ -76,13 +76,13 @@ class Network { NetworkOutput evaluate(const Position& pos, AccumulatorStack& accumulatorStack, - AccumulatorCaches::Cache* cache) const; + AccumulatorCaches::Cache& cache) const; void verify(std::string evalfilePath, const std::function&) const; NnueEvalTrace trace_evaluate(const Position& pos, AccumulatorStack& accumulatorStack, - AccumulatorCaches::Cache* cache) const; + AccumulatorCaches::Cache& cache) const; private: void load_user_net(const std::string&, const std::string&); diff --git a/src/nnue/nnue_feature_transformer.h b/src/nnue/nnue_feature_transformer.h index 5ad2d3371..1f328fff4 100644 --- a/src/nnue/nnue_feature_transformer.h +++ b/src/nnue/nnue_feature_transformer.h @@ -264,12 +264,12 @@ class FeatureTransformer { // Convert input features std::int32_t transform(const Position& pos, AccumulatorStack& accumulatorStack, - AccumulatorCaches::Cache* cache, + AccumulatorCaches::Cache& cache, OutputType* output, int bucket) const { using namespace SIMD; - accumulatorStack.evaluate(pos, *this, *cache); + accumulatorStack.evaluate(pos, *this, cache); const auto& accumulatorState = accumulatorStack.latest(); const auto& threatAccumulatorState = accumulatorStack.latest(); diff --git a/src/nnue/nnue_misc.cpp b/src/nnue/nnue_misc.cpp index 957e3453f..220140e5e 100644 --- a/src/nnue/nnue_misc.cpp +++ b/src/nnue/nnue_misc.cpp @@ -124,7 +124,7 @@ trace(Position& pos, const Eval::NNUE::Networks& networks, Eval::NNUE::Accumulat // We estimate the value of each piece by doing a differential evaluation from // the current base eval, simulating the removal of the piece from its square. - auto [psqt, positional] = networks.big.evaluate(pos, *accumulators, &caches.big); + auto [psqt, positional] = networks.big.evaluate(pos, *accumulators, caches.big); Value base = psqt + positional; base = pos.side_to_move() == WHITE ? base : -base; @@ -140,7 +140,7 @@ trace(Position& pos, const Eval::NNUE::Networks& networks, Eval::NNUE::Accumulat pos.remove_piece(sq); accumulators->reset(); - std::tie(psqt, positional) = networks.big.evaluate(pos, *accumulators, &caches.big); + std::tie(psqt, positional) = networks.big.evaluate(pos, *accumulators, caches.big); Value eval = psqt + positional; eval = pos.side_to_move() == WHITE ? eval : -eval; v = base - eval; @@ -157,7 +157,7 @@ trace(Position& pos, const Eval::NNUE::Networks& networks, Eval::NNUE::Accumulat ss << '\n'; accumulators->reset(); - auto t = networks.big.trace_evaluate(pos, *accumulators, &caches.big); + auto t = networks.big.trace_evaluate(pos, *accumulators, caches.big); ss << " NNUE network contributions " << (pos.side_to_move() == WHITE ? "(White to move)" : "(Black to move)") << std::endl