Add Stockfish namespace.

fixes #3350 and is a small cleanup that might make it easier to use SF
in separate projects, like a NNUE trainer or similar.

closes https://github.com/official-stockfish/Stockfish/pull/3370

No functional change.
This commit is contained in:
Dieter Dobbelaere
2021-02-26 10:02:13 +01:00
committed by Joost VandeVondele
parent 9b1274aba3
commit 7ffae17f85
56 changed files with 199 additions and 57 deletions

View File

@@ -28,7 +28,7 @@
#include "../layers/affine_transform.h"
#include "../layers/clipped_relu.h"
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
// Input features used in evaluation function
using RawFeatures = Features::FeatureSet<
@@ -49,6 +49,6 @@ using OutputLayer = AffineTransform<HiddenLayer2, 1>;
using Network = Layers::OutputLayer;
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_HALFKP_256X2_32_32_H_INCLUDED

View File

@@ -29,7 +29,7 @@
#include "evaluate_nnue.h"
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
// Input feature converter
LargePagePtr<FeatureTransformer> feature_transformer;
@@ -141,4 +141,4 @@ namespace Eval::NNUE {
return ReadParameters(stream);
}
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE

View File

@@ -25,7 +25,7 @@
#include <memory>
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
// Hash value of evaluation function structure
constexpr std::uint32_t kHashValue =
@@ -54,6 +54,6 @@ namespace Eval::NNUE {
template <typename T>
using LargePagePtr = std::unique_ptr<T, LargePageDeleter<T>>;
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_EVALUATE_NNUE_H_INCLUDED

View File

@@ -24,7 +24,7 @@
#include "features_common.h"
#include <array>
namespace Eval::NNUE::Features {
namespace Stockfish::Eval::NNUE::Features {
// Class template that represents a list of values
template <typename T, T... Values>
@@ -64,6 +64,6 @@ namespace Eval::NNUE::Features {
};
} // namespace Eval::NNUE::Features
} // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURE_SET_H_INCLUDED

View File

@@ -24,7 +24,7 @@
#include "../../evaluate.h"
#include "../nnue_common.h"
namespace Eval::NNUE::Features {
namespace Stockfish::Eval::NNUE::Features {
class IndexList;
@@ -40,6 +40,6 @@ namespace Eval::NNUE::Features {
kFriend // side to move
};
} // namespace Eval::NNUE::Features
} // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURES_COMMON_H_INCLUDED

View File

@@ -21,7 +21,7 @@
#include "half_kp.h"
#include "index_list.h"
namespace Eval::NNUE::Features {
namespace Stockfish::Eval::NNUE::Features {
// Orient a square according to perspective (rotates by 180 for black)
inline Square orient(Color perspective, Square s) {
@@ -65,4 +65,4 @@ namespace Eval::NNUE::Features {
template class HalfKP<Side::kFriend>;
} // namespace Eval::NNUE::Features
} // namespace Stockfish::Eval::NNUE::Features

View File

@@ -24,7 +24,7 @@
#include "../../evaluate.h"
#include "features_common.h"
namespace Eval::NNUE::Features {
namespace Stockfish::Eval::NNUE::Features {
// Feature HalfKP: Combination of the position of own king
// and the position of pieces other than kings
@@ -54,6 +54,6 @@ namespace Eval::NNUE::Features {
IndexList* removed, IndexList* added);
};
} // namespace Eval::NNUE::Features
} // namespace Stockfish::Eval::NNUE::Features
#endif // #ifndef NNUE_FEATURES_HALF_KP_H_INCLUDED

View File

@@ -24,7 +24,7 @@
#include "../../position.h"
#include "../nnue_architecture.h"
namespace Eval::NNUE::Features {
namespace Stockfish::Eval::NNUE::Features {
// Class template used for feature index list
template <typename T, std::size_t MaxSize>
@@ -59,6 +59,6 @@ namespace Eval::NNUE::Features {
: public ValueList<IndexType, RawFeatures::kMaxActiveDimensions> {
};
} // namespace Eval::NNUE::Features
} // namespace Stockfish::Eval::NNUE::Features
#endif // NNUE_FEATURES_INDEX_LIST_H_INCLUDED

View File

@@ -24,7 +24,7 @@
#include <iostream>
#include "../nnue_common.h"
namespace Eval::NNUE::Layers {
namespace Stockfish::Eval::NNUE::Layers {
// Affine transformation layer
template <typename PreviousLayer, IndexType OutputDimensions>
@@ -459,6 +459,6 @@ namespace Eval::NNUE::Layers {
#endif
};
} // namespace Eval::NNUE::Layers
} // namespace Stockfish::Eval::NNUE::Layers
#endif // #ifndef NNUE_LAYERS_AFFINE_TRANSFORM_H_INCLUDED

View File

@@ -23,7 +23,7 @@
#include "../nnue_common.h"
namespace Eval::NNUE::Layers {
namespace Stockfish::Eval::NNUE::Layers {
// Clipped ReLU
template <typename PreviousLayer>
@@ -161,6 +161,6 @@ namespace Eval::NNUE::Layers {
PreviousLayer previous_layer_;
};
} // namespace Eval::NNUE::Layers
} // namespace Stockfish::Eval::NNUE::Layers
#endif // NNUE_LAYERS_CLIPPED_RELU_H_INCLUDED

View File

@@ -23,7 +23,7 @@
#include "../nnue_common.h"
namespace Eval::NNUE::Layers {
namespace Stockfish::Eval::NNUE::Layers {
// Input layer
template <IndexType OutputDimensions, IndexType Offset = 0>
@@ -63,6 +63,6 @@ class InputSlice {
private:
};
} // namespace Layers
} // namespace Stockfish::Eval::NNUE::Layers
#endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED

View File

@@ -23,7 +23,7 @@
#include "nnue_architecture.h"
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
// The accumulator of a StateInfo without parent is set to the INIT state
enum AccumulatorState { EMPTY, COMPUTED, INIT };
@@ -35,6 +35,6 @@ namespace Eval::NNUE {
AccumulatorState state[2];
};
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE
#endif // NNUE_ACCUMULATOR_H_INCLUDED

View File

@@ -24,7 +24,7 @@
// Defines the network structure
#include "architectures/halfkp_256x2-32-32.h"
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
static_assert(kTransformedFeatureDimensions % kMaxSimdWidth == 0, "");
static_assert(Network::kOutputDimensions == 1, "");
@@ -33,6 +33,6 @@ namespace Eval::NNUE {
// Trigger for full calculation instead of difference calculation
constexpr auto kRefreshTriggers = RawFeatures::kRefreshTriggers;
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_ARCHITECTURE_H_INCLUDED

View File

@@ -43,7 +43,7 @@
#include <arm_neon.h>
#endif
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
// Version of the evaluation file
constexpr std::uint32_t kVersion = 0x7AF32F16u;
@@ -127,6 +127,6 @@ namespace Eval::NNUE {
return result;
}
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_COMMON_H_INCLUDED

View File

@@ -27,7 +27,7 @@
#include <cstring> // std::memset()
namespace Eval::NNUE {
namespace Stockfish::Eval::NNUE {
// If vector instructions are enabled, we update and refresh the
// accumulator tile by tile such that each tile fits in the CPU's
@@ -412,6 +412,6 @@ namespace Eval::NNUE {
WeightType weights_[kHalfDimensions * kInputDimensions];
};
} // namespace Eval::NNUE
} // namespace Stockfish::Eval::NNUE
#endif // #ifndef NNUE_FEATURE_TRANSFORMER_H_INCLUDED