diff options
| author | tslil <tslil@posteo.de> | 2026-09-20 08:28:09 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-09-20 08:29:22 +0100 |
| commit | 6a2197328065fe38ac62d9e76e3e943fd297e73c (patch) | |
| tree | cac839be5aadeeadb8ae2b383dc5992738652ab5 /include/nn.c | |
| parent | 9f5f953a95c8617cd2fdd24f7402af632c1b07c2 (diff) | |
try combining loops
Diffstat (limited to 'include/nn.c')
| -rw-r--r-- | include/nn.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/nn.c b/include/nn.c index 9f15ec2..926fcf7 100644 --- a/include/nn.c +++ b/include/nn.c @@ -127,11 +127,12 @@ float eval_net(const float *board, const unsigned int n_inp, const float *w, for (unsigned int d1 = 0; d1 < n_dense; d1++) dense1[d1] += b * wrow[d1]; } - for (unsigned int d1 = 0; d1 < n_dense; d1++) - dense1[d1] = fast_silu(dense1[d1]); float z = logit_b; - for (unsigned int d1 = 0; d1 < n_dense; d1++) + for (unsigned int d1 = 0; d1 < n_dense; d1++) { + const float h = dense1[d1]; + dense1[d1] = fast_silu(h); z += dense1[d1] * logit_w[d1]; + } return parity * fast_tanh(z); } |
