]> git.sesse.net Git - stockfish/commit
Simplify Square Clipped ReLU code.
authorGian-Carlo Pascutto <gcp@sjeng.org>
Mon, 14 Aug 2023 15:30:10 +0000 (17:30 +0200)
committerStéphane Nicolet <cassio@free.fr>
Tue, 22 Aug 2023 09:14:19 +0000 (11:14 +0200)
commitc6f62363a657263a567a0cc9bae09f3c4016156d
tree39f1709d09a997fece355990fa9b6935bbecc237
parent4c5919fa95d543b1cd5d0403f3a89e10a2bdd10c
Simplify Square Clipped ReLU code.

Squared numbers are never negative, so barring any wraparound there
is no need to clamp to 0. From reading the code, there's no obvious
way to get wraparound, so the entire operation can be simplified
away. Updated original truncated code comments to be sensible.

Verified by running ./stockfish bench 128 1 24 and by the following test:

STC: https://tests.stockfishchess.org/tests/view/64da4db95b17f7c21c0eabe7
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 60224 W: 15425 L: 15236 D: 29563
Ptnml(0-2): 195, 6576, 16382, 6763, 196

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

No functional change
src/nnue/layers/sqr_clipped_relu.h