Skip to content

Commit

Permalink
bench 8812336
Browse files Browse the repository at this point in the history
  • Loading branch information
rn5f107s2 committed Oct 6, 2024
1 parent 59d7cc5 commit f8843d4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OBJ_DIR=build
MOLY_DIR=src
CXX=clang++

DEFAULT_NET_NAME=params.bin
DEFAULT_NET_NAME=raw.bin
DEFAULT_WDL_HEAD_NAME=net.nnue

DEFAULT_EXE = $(OBJ_DIR)/Molybdenum
Expand Down
Binary file added src/Nets/raw.bin
Binary file not shown.
7 changes: 6 additions & 1 deletion src/nnue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void Net::loadDefaultNet() {

bias1 = defaultWeights.bias1;
weights2 = defaultWeights.weights2;
biasS = defaultWeights.biasS;
weightsS = defaultWeights.weightsS;
bias2 = defaultWeights.bias2;
weights3 = defaultWeights.weights3;
bias3 = defaultWeights.bias3;
Expand Down Expand Up @@ -80,7 +82,7 @@ void Net::initAccumulator(std::array<u64, 13> &bitboards) {
}

int Net::calculate(Color c) {
float out = bias3[0];
float out = bias3[0] + biasS[0];
std::array<float, L2_SIZE> l1Out = bias1;
std::array<float, L3_SIZE> l2Out = bias2;

Expand Down Expand Up @@ -125,6 +127,9 @@ int Net::calculate(Color c) {
l1Out[7] += screlu(float(accumulator[!c][n]) / 255.0f) * weights1[n + L1_SIZE];
}

for (int n = 0; n < L2_SIZE; n++)
out += l1Out[n] * weightsS[n];

for (int n = 0; n < L2_SIZE; n++)
for (int m = 0; m < L3_SIZE; m++)
l2Out[m] += screlu(l1Out[n]) * weights2[n * L3_SIZE + m];
Expand Down
6 changes: 5 additions & 1 deletion src/nnue.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct Weights {
std::array<float, L1_SIZE> bias0{};
std::array<float, L1_SIZE * L2_SIZE * 2> weights1{};
std::array<float, L2_SIZE> bias1{};
std::array<float, L2_SIZE * OUT_SIZE> weightsS{};
std::array<float, OUT_SIZE> biasS{};
std::array<float, L2_SIZE * L3_SIZE> weights2{};
std::array<float, L3_SIZE> bias2{};
std::array<float, L3_SIZE * OUT_SIZE> weights3{};
Expand All @@ -39,8 +41,10 @@ class Net {
public:
std::array<int16_t , L1_SIZE * INPUT_SIZE> weights0{};
std::array<int16_t, L1_SIZE> bias0{};
std::array<float, 64 * 4 * 2> weights1{};
std::array<float, 32 * 8 * 2> weights1{};
std::array<float, L2_SIZE> bias1{};
std::array<float, L2_SIZE * OUT_SIZE> weightsS{};
std::array<float, OUT_SIZE> biasS{};
std::array<float, L2_SIZE * L3_SIZE> weights2{};
std::array<float, L3_SIZE> bias2{};
std::array<float, L3_SIZE * OUT_SIZE> weights3{};
Expand Down

0 comments on commit f8843d4

Please sign in to comment.