]> git.sesse.net Git - stockfish/commit - src/nnue/nnue_feature_transformer.h
Assume network file is in little-endian byte order
authorsyzygy1 <3028851+syzygy1@users.noreply.github.com>
Sat, 15 Aug 2020 14:50:39 +0000 (16:50 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 16 Aug 2020 19:10:26 +0000 (21:10 +0200)
commit72dc7a5c54554a8c7c4bf68aa7de2d4de05f3294
tree3e781fd947633d895f1db34daf9e779acbe3b20a
parent8cf43c6317665295eece747ed1589ee33a435d2c
Assume network file is in little-endian byte order

This patch fixes the byte order when reading 16- and 32-bit values from the network file on a big-endian machine.

Bytes are ordered in read_le() using unsigned arithmetic, which doesn't need tricks to determine the endianness of the machine. Unfortunately the compiler doesn't seem to be able to optimise the ordering operation, but reading in the weights is not a time-critical operation and the extra time it takes should not be noticeable.

Big endian systems are still untested with NNUE.

fixes #3007

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

No functional change.
src/nnue/evaluate_nnue.cpp
src/nnue/layers/affine_transform.h
src/nnue/nnue_common.h
src/nnue/nnue_feature_transformer.h