skip to content
==> src/logits.c <==
1/* The greedy pick and the logits digest (mesh-ref gpt2.rs `argmax`, `digest_extend`). */
2#include "mesh/ref/gpt2_logits.h"
3
4#include "mesh/ftz.h"
5
6uint32_t mesh_gpt2_argmax(const float *l, size_t n) {
7    size_t b = 0;
8    for (size_t i = 1; i < n; i++)
9        if (mesh_ftz_gt(l[i], l[b])) b = i;
10    return (uint32_t)b;
11}
12
13uint64_t mesh_gpt2_digest_extend(uint64_t h, const float *l, size_t n) {
14    for (size_t i = 0; i < n; i++) h = (h ^ mesh_ftz_bits(l[i])) * 0x00000100000001b3ull;
15    return h;
16}