diff --git a/src/Makefile b/src/Makefile index ca851dba..a07e1251 100644 --- a/src/Makefile +++ b/src/Makefile @@ -903,7 +903,7 @@ icc-profile-use: learn: config-sanity $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ - EXTRACXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + EXTRACXXFLAGS=' -DEVAL_LEARN -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \ all @@ -911,7 +911,7 @@ profile-learn: net config-sanity objclean profileclean @echo "" @echo "Step 1/4. Building instrumented executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \ - LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + LEARNCXXFLAGS=' -DEVAL_LEARN -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' @echo "" @echo "Step 2/4. Running benchmark for pgo-build ..." @@ -920,7 +920,7 @@ profile-learn: net config-sanity objclean profileclean @echo "Step 3/4. Building optimized executable ..." $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \ - LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ + LEARNCXXFLAGS=' -DEVAL_LEARN -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \ LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp ' @echo "" @echo "Step 4/4. Deleting profile data ..." diff --git a/src/eval/evaluate_common.h b/src/eval/evaluate_common.h index dacbd2ba..3fb161ab 100644 --- a/src/eval/evaluate_common.h +++ b/src/eval/evaluate_common.h @@ -3,7 +3,6 @@ // A common header-like function for modern evaluation functions (EVAL_KPPT and EVAL_KPP_KKPT). -#if defined(EVAL_NNUE) || defined(EVAL_LEARN) #include // KK file name @@ -79,6 +78,4 @@ namespace Eval } -#endif // defined(EVAL_NNUE) || defined(EVAL_LEARN) - #endif // _EVALUATE_KPPT_COMMON_H_ diff --git a/src/learn/gensfen.cpp b/src/learn/gensfen.cpp index b049192e..9ae83174 100644 --- a/src/learn/gensfen.cpp +++ b/src/learn/gensfen.cpp @@ -1,45 +1,41 @@ #if defined(EVAL_LEARN) #include "../eval/evaluate_common.h" - -#include "learn.h" -#include "multi_think.h" #include "../misc.h" -#include "../thread.h" +#include "../nnue/evaluate_nnue_learner.h" #include "../position.h" +#include "../syzygy/tbprobe.h" +#include "../thread.h" #include "../tt.h" #include "../uci.h" -#include "../syzygy/tbprobe.h" +#include "learn.h" +#include "multi_think.h" #if defined(USE_BOOK) #include "../extra/book/book.h" #endif #include -#include -#include -#include -#include -#include -#include -#include +#include #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined (_OPENMP) #include #endif -#if defined(EVAL_NNUE) -#include "../nnue/evaluate_nnue_learner.h" -#include -#include -#endif - using namespace std; namespace Learner @@ -692,12 +688,10 @@ namespace Learner // performed unless each node evaluate() is called! // If the depth is 8 or more, it seems // faster not to calculate this difference. -#if defined(EVAL_NNUE) if (depth < 8) { Eval::NNUE::update_eval(pos); } -#endif // defined(EVAL_NNUE) } // Reach leaf diff --git a/src/learn/learner.cpp b/src/learn/learner.cpp index f9d188b8..358848ec 100644 --- a/src/learn/learner.cpp +++ b/src/learn/learner.cpp @@ -17,45 +17,40 @@ // → I will not be involved in the engine because it is a problem that the GUI should assist. // etc.. -#define EVAL_LEARN - #if defined(EVAL_LEARN) #include "../eval/evaluate_common.h" - +#include "../misc.h" +#include "../nnue/evaluate_nnue_learner.h" +#include "../position.h" +#include "../syzygy/tbprobe.h" +#include "../thread.h" +#include "../tt.h" +#include "../uci.h" #include "learn.h" #include "multi_think.h" -#include "../uci.h" -#include "../syzygy/tbprobe.h" -#include "../misc.h" -#include "../thread.h" -#include "../position.h" -#include "../tt.h" #include -#include -#include -#include -#include -#include -#include -#include +#include #include // std::exp(),std::pow(),std::log() #include // memcpy() -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined (_OPENMP) #include #endif -#if defined(EVAL_NNUE) -#include "../nnue/evaluate_nnue_learner.h" -#include -#include -#endif using namespace std; @@ -724,14 +719,12 @@ namespace Learner learn_sum_entropy = 0.0; #endif -#if defined(EVAL_NNUE) newbob_scale = 1.0; newbob_decay = 1.0; newbob_num_trials = 2; best_loss = std::numeric_limits::infinity(); latest_loss_sum = 0.0; latest_loss_count = 0; -#endif } virtual void thread_worker(size_t thread_id); @@ -787,7 +780,6 @@ namespace Learner atomic learn_sum_entropy; #endif -#if defined(EVAL_NNUE) shared_timed_mutex nn_mutex; double newbob_scale; double newbob_decay; @@ -796,7 +788,6 @@ namespace Learner double latest_loss_sum; uint64_t latest_loss_count; std::string best_nn_directory; -#endif uint64_t eval_save_interval; uint64_t loss_output_interval; @@ -844,13 +835,10 @@ namespace Learner // It doesn't matter if you have disabled the substitution table. TT.new_search(); - -#if defined(EVAL_NNUE) std::cout << "PROGRESS: " << now_string() << ", "; std::cout << sr.total_done << " sfens"; std::cout << ", iteration " << epoch; std::cout << ", eta = " << Eval::get_eta() << ", "; -#endif #if !defined(LOSS_FUNCTION_IS_ELMO_METHOD) double sum_error = 0; @@ -1009,10 +997,8 @@ namespace Learner #endif #if defined(LOSS_FUNCTION_IS_ELMO_METHOD) -#if defined(EVAL_NNUE) latest_loss_sum += test_sum_cross_entropy - test_sum_entropy; latest_loss_count += sr.sfen_for_mse.size(); -#endif // learn_cross_entropy may be called train cross // entropy in the world of machine learning, @@ -1074,14 +1060,10 @@ namespace Learner // display mse (this is sometimes done only for thread 0) // Immediately after being read from the file... -#if defined(EVAL_NNUE) // Lock the evaluation function so that it is not used during updating. shared_lock read_lock(nn_mutex, defer_lock); if (sr.next_update_weights <= sr.total_done || (thread_id != 0 && !read_lock.try_lock())) -#else - if (sr.next_update_weights <= sr.total_done) -#endif { if (thread_id != 0) { @@ -1105,18 +1087,6 @@ namespace Learner continue; } -#if !defined(EVAL_NNUE) - // Output the current time. Output every time. - std::cout << sr.total_done << " sfens , at " << now_string() << std::endl; - - // Reflect the gradient in the weight array at this timing. - // The calculation of the gradient is just right for - // each 1M phase in terms of mini-batch. - Eval::update_weights(epoch, freeze); - - // Display epoch and current eta for debugging. - std::cout << "epoch = " << epoch << " , eta = " << Eval::get_eta() << std::endl; -#else { // update parameters @@ -1124,7 +1094,7 @@ namespace Learner lock_guard write_lock(nn_mutex); Eval::NNUE::UpdateParameters(epoch); } -#endif + ++epoch; // However, the elapsed time during update_weights() and calc_rmse() is ignored. @@ -1156,9 +1126,7 @@ namespace Learner // loss calculation calc_loss(thread_id, done); -#if defined(EVAL_NNUE) Eval::NNUE::CheckHealth(); -#endif // Make a note of how far you have totaled. sr.last_done = sr.total_done; @@ -1216,25 +1184,6 @@ namespace Learner goto RETRY_READ; } -#if !defined(EVAL_NNUE) - if (skip_duplicated_positions_in_training) - { - const auto key = pos.key(); - - // Exclude the phase used for rmse calculation. - if (sr.is_for_rmse(key)) - goto RETRY_READ; - - // Exclude the most recently used aspect. - const auto hash_index = size_t(key & (sr.READ_SFEN_HASH_SIZE - 1)); - const auto key2 = sr.hash[hash_index]; - if (key == key2) - goto RETRY_READ; - - sr.hash[hash_index] = key; // Replace with the current key. - } -#endif - // There is a possibility that all the pieces are blocked and stuck. // Also, the declaration win phase is excluded from // learning because you cannot go to leaf with PV moves. @@ -1326,25 +1275,9 @@ namespace Learner learn_sum_entropy += learn_entropy; #endif -#if !defined(EVAL_NNUE) - // Slope - double dj_dw = calc_grad(deep_value, shallow_value, ps); - - // Add jd_dw as the gradient (∂J/∂Wj) for the - // feature vector currently appearing in the leaf node. - - // If it is not PV termination, apply a discount rate. - if (discount_rate != 0 && ply != (int)pv.size()) - dj_dw *= discount_rate; - - // Since we have reached leaf, add the gradient to the features that appear in this phase. - // Update based on gradient later. - Eval::add_grad(pos, rootColor, dj_dw, freeze); -#else const double example_weight = (discount_rate != 0 && ply != (int)pv.size()) ? discount_rate : 1.0; Eval::NNUE::AddExample(pos, rootColor, ps, example_weight); -#endif // Since the processing is completed, the counter of the processed number is incremented sr.total_done++; @@ -1425,7 +1358,6 @@ namespace Learner const std::string dir_name = std::to_string(dir_number++); Eval::save_eval(dir_name); -#if defined(EVAL_NNUE) if (newbob_decay != 1.0 && latest_loss_count > 0) { static int trials = newbob_num_trials; const double latest_loss = latest_loss_sum / latest_loss_count; @@ -1470,7 +1402,6 @@ namespace Learner return true; } } -#endif } return false; } @@ -1817,12 +1748,10 @@ namespace Learner // Optional item that does not let you learn KK/KKP/KPP/KPPP array freeze = {}; -#if defined(EVAL_NNUE) uint64_t nn_batch_size = 1000; double newbob_decay = 1.0; int newbob_num_trials = 2; string nn_options; -#endif uint64_t eval_save_interval = LEARN_EVAL_SAVE_INTERVAL; uint64_t loss_output_interval = 0; @@ -1922,12 +1851,11 @@ namespace Learner else if (option == "save_only_once") save_only_once = true; else if (option == "no_shuffle") no_shuffle = true; -#if defined(EVAL_NNUE) else if (option == "nn_batch_size") is >> nn_batch_size; else if (option == "newbob_decay") is >> newbob_decay; else if (option == "newbob_num_trials") is >> newbob_num_trials; else if (option == "nn_options") is >> nn_options; -#endif + else if (option == "eval_save_interval") is >> eval_save_interval; else if (option == "loss_output_interval") is >> loss_output_interval; else if (option == "mirror_percentage") is >> mirror_percentage; @@ -2074,23 +2002,18 @@ namespace Learner } } -#if !defined(EVAL_NNUE) - cout << "Gradient Method : " << LEARN_UPDATE << endl; -#endif cout << "Loss Function : " << LOSS_FUNCTION << endl; cout << "mini-batch size : " << mini_batch_size << endl; -#if defined(EVAL_NNUE) cout << "nn_batch_size : " << nn_batch_size << endl; cout << "nn_options : " << nn_options << endl; -#endif + cout << "learning rate : " << eta1 << " , " << eta2 << " , " << eta3 << endl; cout << "eta_epoch : " << eta1_epoch << " , " << eta2_epoch << endl; cout << "use_draw_games_in_training : " << use_draw_games_in_training << endl; cout << "use_draw_games_in_validation : " << use_draw_games_in_validation << endl; cout << "skip_duplicated_positions_in_training : " << skip_duplicated_positions_in_training << endl; -#if defined(EVAL_NNUE) if (newbob_decay != 1.0) { cout << "scheduling : newbob with decay = " << newbob_decay << ", " << newbob_num_trials << " trials" << endl; @@ -2098,7 +2021,6 @@ namespace Learner else { cout << "scheduling : default" << endl; } -#endif cout << "discount rate : " << discount_rate << endl; @@ -2133,12 +2055,6 @@ namespace Learner // Read evaluation function parameters Eval::init_NNUE(); -#if !defined(EVAL_NNUE) - cout << "init_grad.." << endl; - - // Initialize gradient array of merit function parameters - Eval::init_grad(eta1, eta1_epoch, eta2, eta2_epoch, eta3); -#else cout << "init_training.." << endl; Eval::NNUE::InitializeTraining(eta1, eta1_epoch, eta2, eta2_epoch, eta3); Eval::NNUE::SetBatchSize(nn_batch_size); @@ -2146,7 +2062,6 @@ namespace Learner if (newbob_decay != 1.0 && !Options["SkipLoadingEval"]) { learn_think.best_nn_directory = std::string(Options["EvalDir"]); } -#endif #if 0 // A test to give a gradient of 1.0 to the initial stage of Hirate. @@ -2170,11 +2085,9 @@ namespace Learner learn_think.freeze = freeze; learn_think.reduction_gameply = reduction_gameply; -#if defined(EVAL_NNUE) learn_think.newbob_scale = 1.0; learn_think.newbob_decay = newbob_decay; learn_think.newbob_num_trials = newbob_num_trials; -#endif learn_think.eval_save_interval = eval_save_interval; learn_think.loss_output_interval = loss_output_interval; @@ -2199,7 +2112,6 @@ namespace Learner // Calculate rmse once at this point (timing of 0 sfen) // sr.calc_rmse(); -#if defined(EVAL_NNUE) if (newbob_decay != 1.0) { learn_think.calc_loss(0, -1); learn_think.best_loss = learn_think.latest_loss_sum / learn_think.latest_loss_count; @@ -2207,7 +2119,6 @@ namespace Learner learn_think.latest_loss_count = 0; cout << "initial loss: " << learn_think.best_loss << endl; } -#endif // ----------------------------------- // start learning evaluation function parameters diff --git a/src/nnue/evaluate_nnue.cpp b/src/nnue/evaluate_nnue.cpp index 5c8cee71..a2845c96 100644 --- a/src/nnue/evaluate_nnue.cpp +++ b/src/nnue/evaluate_nnue.cpp @@ -184,13 +184,11 @@ namespace Eval::NNUE { Initialize(); -#if defined(EVAL_NNUE) if (Options["SkipLoadingEval"]) { std::cout << "info string SkipLoadingEval set to true, Net not loaded!" << std::endl; return true; } -#endif fileName = evalFile; diff --git a/src/nnue/evaluate_nnue_learner.cpp b/src/nnue/evaluate_nnue_learner.cpp index 13d9d578..7be06832 100644 --- a/src/nnue/evaluate_nnue_learner.cpp +++ b/src/nnue/evaluate_nnue_learner.cpp @@ -1,6 +1,6 @@ // Code for learning NNUE evaluation function -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include #include @@ -229,4 +229,4 @@ double get_eta() { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) diff --git a/src/nnue/evaluate_nnue_learner.h b/src/nnue/evaluate_nnue_learner.h index 1e4a463e..0e5fbcd2 100644 --- a/src/nnue/evaluate_nnue_learner.h +++ b/src/nnue/evaluate_nnue_learner.h @@ -3,7 +3,7 @@ #ifndef _EVALUATE_NNUE_LEARNER_H_ #define _EVALUATE_NNUE_LEARNER_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../learn/learn.h" @@ -41,6 +41,6 @@ void CheckHealth(); } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/nnue/features/castling_right.cpp b/src/nnue/features/castling_right.cpp index ee7b6576..47fbd986 100644 --- a/src/nnue/features/castling_right.cpp +++ b/src/nnue/features/castling_right.cpp @@ -1,7 +1,5 @@ //Definition of input feature quantity K of NNUE evaluation function -#if defined(EVAL_NNUE) - #include "castling_right.h" #include "index_list.h" @@ -69,5 +67,3 @@ namespace Eval { } // namespace NNUE } // namespace Eval - -#endif // defined(EVAL_NNUE) diff --git a/src/nnue/features/castling_right.h b/src/nnue/features/castling_right.h index 3af5b074..27074080 100644 --- a/src/nnue/features/castling_right.h +++ b/src/nnue/features/castling_right.h @@ -3,8 +3,6 @@ #ifndef _NNUE_FEATURES_CASTLING_RIGHT_H_ #define _NNUE_FEATURES_CASTLING_RIGHT_H_ -#if defined(EVAL_NNUE) - #include "../../evaluate.h" #include "features_common.h" @@ -43,6 +41,4 @@ namespace Eval { } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/features/enpassant.cpp b/src/nnue/features/enpassant.cpp index ea70529a..77bc936e 100644 --- a/src/nnue/features/enpassant.cpp +++ b/src/nnue/features/enpassant.cpp @@ -1,7 +1,5 @@ //Definition of input feature quantity K of NNUE evaluation function -#if defined(EVAL_NNUE) - #include "enpassant.h" #include "index_list.h" @@ -43,5 +41,3 @@ namespace Eval { } // namespace NNUE } // namespace Eval - -#endif // defined(EVAL_NNUE) diff --git a/src/nnue/features/enpassant.h b/src/nnue/features/enpassant.h index f77f9c4f..70a8eb5a 100644 --- a/src/nnue/features/enpassant.h +++ b/src/nnue/features/enpassant.h @@ -3,8 +3,6 @@ #ifndef _NNUE_FEATURES_ENPASSANT_H_ #define _NNUE_FEATURES_ENPASSANT_H_ -#if defined(EVAL_NNUE) - #include "../../evaluate.h" #include "features_common.h" @@ -43,6 +41,4 @@ namespace Eval { } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/features/half_relative_kp.cpp b/src/nnue/features/half_relative_kp.cpp index 015ecb73..597d65fb 100644 --- a/src/nnue/features/half_relative_kp.cpp +++ b/src/nnue/features/half_relative_kp.cpp @@ -1,7 +1,5 @@ //Definition of input features HalfRelativeKP of NNUE evaluation function -#if defined(EVAL_NNUE) - #include "half_relative_kp.h" #include "index_list.h" @@ -74,5 +72,3 @@ template class HalfRelativeKP; } // namespace NNUE } // namespace Eval - -#endif // defined(EVAL_NNUE) diff --git a/src/nnue/features/half_relative_kp.h b/src/nnue/features/half_relative_kp.h index 2d4182e4..1b384c14 100644 --- a/src/nnue/features/half_relative_kp.h +++ b/src/nnue/features/half_relative_kp.h @@ -3,8 +3,6 @@ #ifndef _NNUE_FEATURES_HALF_RELATIVE_KP_H_ #define _NNUE_FEATURES_HALF_RELATIVE_KP_H_ -#if defined(EVAL_NNUE) - #include "../../evaluate.h" #include "features_common.h" @@ -60,6 +58,4 @@ class HalfRelativeKP { } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/features/k.cpp b/src/nnue/features/k.cpp index 314b1338..38ec9997 100644 --- a/src/nnue/features/k.cpp +++ b/src/nnue/features/k.cpp @@ -1,7 +1,5 @@ //Definition of input feature quantity K of NNUE evaluation function -#if defined(EVAL_NNUE) - #include "k.h" #include "index_list.h" @@ -54,5 +52,3 @@ void K::AppendChangedIndices( } // namespace NNUE } // namespace Eval - -#endif // defined(EVAL_NNUE) diff --git a/src/nnue/features/k.h b/src/nnue/features/k.h index 0c394f4e..9a0be4bb 100644 --- a/src/nnue/features/k.h +++ b/src/nnue/features/k.h @@ -3,8 +3,6 @@ #ifndef _NNUE_FEATURES_K_H_ #define _NNUE_FEATURES_K_H_ -#if defined(EVAL_NNUE) - #include "../../evaluate.h" #include "features_common.h" @@ -47,6 +45,4 @@ private: } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/features/p.cpp b/src/nnue/features/p.cpp index b4a6faf9..0c1b7d50 100644 --- a/src/nnue/features/p.cpp +++ b/src/nnue/features/p.cpp @@ -1,7 +1,5 @@ //Definition of input feature P of NNUE evaluation function -#if defined(EVAL_NNUE) - #include "p.h" #include "index_list.h" @@ -52,5 +50,3 @@ void P::AppendChangedIndices( } // namespace NNUE } // namespace Eval - -#endif // defined(EVAL_NNUE) diff --git a/src/nnue/features/p.h b/src/nnue/features/p.h index b3d4191e..07d88952 100644 --- a/src/nnue/features/p.h +++ b/src/nnue/features/p.h @@ -3,8 +3,6 @@ #ifndef _NNUE_FEATURES_P_H_ #define _NNUE_FEATURES_P_H_ -#if defined(EVAL_NNUE) - #include "../../evaluate.h" #include "features_common.h" @@ -47,6 +45,4 @@ class P { } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/layers/sum.h b/src/nnue/layers/sum.h index d8c7bf93..419ced89 100644 --- a/src/nnue/layers/sum.h +++ b/src/nnue/layers/sum.h @@ -3,8 +3,6 @@ #ifndef _NNUE_LAYERS_SUM_H_ #define _NNUE_LAYERS_SUM_H_ -#if defined(EVAL_NNUE) - #include "../nnue_common.h" namespace Eval { @@ -158,6 +156,4 @@ class Sum { } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/nnue_test_command.cpp b/src/nnue/nnue_test_command.cpp index 311c5ded..b8346693 100644 --- a/src/nnue/nnue_test_command.cpp +++ b/src/nnue/nnue_test_command.cpp @@ -1,6 +1,6 @@ // USI extended command for NNUE evaluation function -#if defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE) +#if defined(ENABLE_TEST_CMD) #include "../thread.h" #include "../uci.h" @@ -198,4 +198,4 @@ void TestCommand(Position& pos, std::istream& stream) { } // namespace Eval -#endif // defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE) +#endif // defined(ENABLE_TEST_CMD) diff --git a/src/nnue/nnue_test_command.h b/src/nnue/nnue_test_command.h index 570ef01b..30854fd2 100644 --- a/src/nnue/nnue_test_command.h +++ b/src/nnue/nnue_test_command.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TEST_COMMAND_H_ #define _NNUE_TEST_COMMAND_H_ -#if defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE) +#if defined(ENABLE_TEST_CMD) namespace Eval { @@ -16,6 +16,6 @@ void TestCommand(Position& pos, std::istream& stream); } // namespace Eval -#endif // defined(ENABLE_TEST_CMD) && defined(EVAL_NNUE) +#endif // defined(ENABLE_TEST_CMD) #endif diff --git a/src/nnue/trainer/features/factorizer.h b/src/nnue/trainer/features/factorizer.h index 148ee8ec..43950de2 100644 --- a/src/nnue/trainer/features/factorizer.h +++ b/src/nnue/trainer/features/factorizer.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_FEATURES_FACTORIZER_H_ #define _NNUE_TRAINER_FEATURES_FACTORIZER_H_ -#if defined(EVAL_NNUE) - #include "../../nnue_common.h" #include "../trainer.h" @@ -105,6 +103,4 @@ constexpr std::size_t GetArrayLength(const T (&/*array*/)[N]) { } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/trainer/features/factorizer_feature_set.h b/src/nnue/trainer/features/factorizer_feature_set.h index af524719..caf6608b 100644 --- a/src/nnue/trainer/features/factorizer_feature_set.h +++ b/src/nnue/trainer/features/factorizer_feature_set.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_FEATURES_FACTORIZER_FEATURE_SET_H_ #define _NNUE_TRAINER_FEATURES_FACTORIZER_FEATURE_SET_H_ -#if defined(EVAL_NNUE) - #include "../../features/feature_set.h" #include "factorizer.h" @@ -99,6 +97,4 @@ public: } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/trainer/features/factorizer_half_kp.h b/src/nnue/trainer/features/factorizer_half_kp.h index 955894e8..70a6acca 100644 --- a/src/nnue/trainer/features/factorizer_half_kp.h +++ b/src/nnue/trainer/features/factorizer_half_kp.h @@ -3,8 +3,6 @@ #ifndef _NNUE_TRAINER_FEATURES_FACTORIZER_HALF_KP_H_ #define _NNUE_TRAINER_FEATURES_FACTORIZER_HALF_KP_H_ -#if defined(EVAL_NNUE) - #include "../../features/half_kp.h" #include "../../features/p.h" #include "../../features/half_relative_kp.h" @@ -98,6 +96,4 @@ constexpr FeatureProperties Factorizer>::kProperties[]; } // namespace Eval -#endif // defined(EVAL_NNUE) - #endif diff --git a/src/nnue/trainer/trainer.h b/src/nnue/trainer/trainer.h index 4b467041..d526557a 100644 --- a/src/nnue/trainer/trainer.h +++ b/src/nnue/trainer/trainer.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TRAINER_H_ #define _NNUE_TRAINER_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../nnue_common.h" #include "../features/index_list.h" @@ -120,6 +120,6 @@ std::shared_ptr MakeAlignedSharedPtr(ArgumentTypes&&... arguments) { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/nnue/trainer/trainer_affine_transform.h b/src/nnue/trainer/trainer_affine_transform.h index da11ca29..4b5ddee6 100644 --- a/src/nnue/trainer/trainer_affine_transform.h +++ b/src/nnue/trainer/trainer_affine_transform.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TRAINER_AFFINE_TRANSFORM_H_ #define _NNUE_TRAINER_AFFINE_TRANSFORM_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../../learn/learn.h" #include "../layers/affine_transform.h" @@ -296,6 +296,6 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/nnue/trainer/trainer_clipped_relu.h b/src/nnue/trainer/trainer_clipped_relu.h index bd59a02d..72575bf8 100644 --- a/src/nnue/trainer/trainer_clipped_relu.h +++ b/src/nnue/trainer/trainer_clipped_relu.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TRAINER_CLIPPED_RELU_H_ #define _NNUE_TRAINER_CLIPPED_RELU_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../../learn/learn.h" #include "../layers/clipped_relu.h" @@ -137,6 +137,6 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/nnue/trainer/trainer_feature_transformer.h b/src/nnue/trainer/trainer_feature_transformer.h index 97dbeff4..6b94d952 100644 --- a/src/nnue/trainer/trainer_feature_transformer.h +++ b/src/nnue/trainer/trainer_feature_transformer.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TRAINER_FEATURE_TRANSFORMER_H_ #define _NNUE_TRAINER_FEATURE_TRANSFORMER_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../../learn/learn.h" #include "../nnue_feature_transformer.h" @@ -372,6 +372,6 @@ class Trainer { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/nnue/trainer/trainer_input_slice.h b/src/nnue/trainer/trainer_input_slice.h index 7d9e76c3..b6d6635b 100644 --- a/src/nnue/trainer/trainer_input_slice.h +++ b/src/nnue/trainer/trainer_input_slice.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TRAINER_INPUT_SLICE_H_ #define _NNUE_TRAINER_INPUT_SLICE_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../../learn/learn.h" #include "../layers/input_slice.h" @@ -246,6 +246,6 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/nnue/trainer/trainer_sum.h b/src/nnue/trainer/trainer_sum.h index f7bf3b3d..0b7abe36 100644 --- a/src/nnue/trainer/trainer_sum.h +++ b/src/nnue/trainer/trainer_sum.h @@ -3,7 +3,7 @@ #ifndef _NNUE_TRAINER_SUM_H_ #define _NNUE_TRAINER_SUM_H_ -#if defined(EVAL_LEARN) && defined(EVAL_NNUE) +#if defined(EVAL_LEARN) #include "../../learn/learn.h" #include "../layers/sum.h" @@ -185,6 +185,6 @@ class Trainer> { } // namespace Eval -#endif // defined(EVAL_LEARN) && defined(EVAL_NNUE) +#endif // defined(EVAL_LEARN) #endif diff --git a/src/uci.cpp b/src/uci.cpp index d6745d19..5be2afbb 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -32,7 +32,7 @@ #include "uci.h" #include "syzygy/tbprobe.h" -#if defined(EVAL_NNUE) && defined(ENABLE_TEST_CMD) +#if defined(ENABLE_TEST_CMD) #include "nnue/nnue_test_command.h" #endif @@ -67,7 +67,7 @@ namespace Learner } #endif -#if defined(EVAL_NNUE) && defined(ENABLE_TEST_CMD) +#if defined(ENABLE_TEST_CMD) void test_cmd(Position& pos, istringstream& is) { // Initialize as it may be searched. @@ -373,7 +373,7 @@ void UCI::loop(int argc, char* argv[]) { #endif -#if defined(EVAL_NNUE) && defined(ENABLE_TEST_CMD) +#if defined(ENABLE_TEST_CMD) // test command else if (token == "test") test_cmd(pos, is); #endif diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 0007b559..4f9fab5e 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -83,7 +83,6 @@ void init(OptionsMap& o) { // The default must follow the format nn-[SHA256 first 12 digits].nnue // for the build process (profile-build and fishtest) to work. o["EvalFile"] << Option("nn-82215d0fd0df.nnue", on_eval_file); -#ifdef EVAL_NNUE // When the evaluation function is loaded at the ucinewgame timing, it is necessary to convert the new evaluation function. // I want to hit the test eval convert command, but there is no new evaluation function // It ends abnormally before executing this command. @@ -92,7 +91,6 @@ void init(OptionsMap& o) { o["SkipLoadingEval"] << Option(false); // how many moves to use a fixed move // o["BookMoves"] << Option(16, 0, 10000); -#endif #if defined(EVAL_LEARN) // When learning the evaluation function, you can change the folder to save the evaluation function. // Evalsave by default. This folder shall be prepared in advance.