Skip to content

Commit 5d82a93

Browse files
committed
Test simplification
1 parent 34a67dd commit 5d82a93

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

src/nnue/features/half_ka_v2_hm.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class HalfKAv2_hm {
7676
static constexpr std::uint32_t HashValue = 0xd17b100;
7777

7878
// Number of feature dimensions
79-
static constexpr IndexType Dimensions = 6 * 2 * 3 * static_cast<IndexType>(PS_NB);
79+
static constexpr IndexType Dimensions = 6 * 4 * static_cast<IndexType>(PS_NB);
8080

8181
// Get king_index and mirror information
8282
static constexpr auto KingBuckets = []() {
@@ -121,21 +121,7 @@ class HalfKAv2_hm {
121121
for (uint8_t rook = 0; rook <= 2; ++rook)
122122
for (uint8_t knight = 0; knight <= 2; ++knight)
123123
for (uint8_t cannon = 0; cannon <= 2; ++cannon)
124-
v[rook][knight][cannon] = [&] {
125-
if (rook != 0)
126-
if (knight > 0 && cannon > 0)
127-
return 0;
128-
else if (rook == 2 || knight + cannon > 1)
129-
return 1;
130-
else
131-
return 2;
132-
else if (knight > 0 && cannon > 0)
133-
return 3;
134-
else if (knight + cannon > 1)
135-
return 4;
136-
else
137-
return 5;
138-
}();
124+
v[rook][knight][cannon] = bool(rook) * 2 + bool(knight + cannon);
139125
return v;
140126
}();
141127

src/nnue/nnue_accumulator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void AccumulatorStack::forward_update_incremental(
144144
auto [king_bucket, mirror] =
145145
FeatureSet::KingBuckets[ksq][oksq][FeatureSet::requires_mid_mirror(pos, Perspective)];
146146
auto attack_bucket = FeatureSet::make_attack_bucket(pos, Perspective);
147-
auto bucket = king_bucket * 6 + attack_bucket;
147+
auto bucket = king_bucket * 4 + attack_bucket;
148148

149149
for (std::size_t next = begin + 1; next < size; next++)
150150
{
@@ -188,7 +188,7 @@ void AccumulatorStack::backward_update_incremental(
188188
auto [king_bucket, mirror] =
189189
FeatureSet::KingBuckets[ksq][oksq][FeatureSet::requires_mid_mirror(pos, Perspective)];
190190
auto attack_bucket = FeatureSet::make_attack_bucket(pos, Perspective);
191-
auto bucket = king_bucket * 6 + attack_bucket;
191+
auto bucket = king_bucket * 4 + attack_bucket;
192192

193193
for (std::int64_t next = std::int64_t(size) - 2; next >= std::int64_t(end); next--)
194194
update_accumulator_incremental<Perspective, false>(
@@ -388,7 +388,7 @@ void update_accumulator_refresh_cache(const FeatureTransformer<Dimensions>& feat
388388
auto [king_bucket, mirror] =
389389
FeatureSet::KingBuckets[ksq][oksq][FeatureSet::requires_mid_mirror(pos, Perspective)];
390390
auto attack_bucket = FeatureSet::make_attack_bucket(pos, Perspective);
391-
auto bucket = king_bucket * 6 + attack_bucket;
391+
auto bucket = king_bucket * 4 + attack_bucket;
392392

393393
auto cache_index = AccumulatorCaches::KingCacheMaps[ksq];
394394
if (cache_index < 3 && mirror)
@@ -398,7 +398,7 @@ void update_accumulator_refresh_cache(const FeatureTransformer<Dimensions>& feat
398398
cache_index += 3;
399399
}
400400

401-
auto& entry = cache[cache_index * 6 + attack_bucket][Perspective];
401+
auto& entry = cache[cache_index * 4 + attack_bucket][Perspective];
402402
FeatureSet::IndexList removed, added;
403403

404404
for (Color c : {WHITE, BLACK})

src/nnue/nnue_accumulator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct AccumulatorCaches {
108108

109109
std::array<Entry, COLOR_NB>& operator[](int index) { return entries[index]; }
110110

111-
std::array<std::array<Entry, COLOR_NB>, (9 + 6) * 2 * 3> entries;
111+
std::array<std::array<Entry, COLOR_NB>, (9 + 6) * 4> entries;
112112
};
113113

114114
template<typename Networks>

src/nnue/nnue_architecture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Stockfish::Eval::NNUE {
3838
using FeatureSet = Features::HalfKAv2_hm;
3939

4040
// Number of input feature dimensions after conversion
41-
constexpr IndexType TransformedFeatureDimensionsBig = 2048;
41+
constexpr IndexType TransformedFeatureDimensionsBig = 2560;
4242
constexpr int L2Big = 15;
4343
constexpr int L3Big = 32;
4444

0 commit comments

Comments
 (0)