==> tests/shape.c <==1/* gpt2.rs's layout_covers_the_checkpoint, and the tensor names, offsets and counts against a golden
2 * digest from the Rust. */
3#include "mesh/ref/gpt2_shape.h"
4
5#include <stdint.h>
6#include <stdio.h>
7
8int main(void) {
9 mesh_gpt2_layout l;
10 mesh_gpt2_layout_init(&l);
11 int failures = l.total != 124439808;
12 uint64_t h = 0xcbf29ce484222325ull;
13 size_t at = 0, i = 0;
14 char name[32];
15 size_t off, n;
16 for (; mesh_gpt2_tensor(&l, i, name, &off, &n); i++) {
17 if (off != at) failures++;
18 at += n;
19 for (const char *c = name; *c; c++) h = (h ^ (uint8_t)*c) * 0x100000001b3ull;
20 h = (h ^ off) * 0x100000001b3ull;
21 h = (h ^ n) * 0x100000001b3ull;
22 }
23 if (i != MESH_GPT2_TENSORS || at != l.total || h != 0x3ec233629c7428b2ull) {
24 fprintf(stderr, "%zu tensors, %zu floats, digest %#018llx\n", i, at, (unsigned long long)h);
25 failures++;
26 }
27 return failures != 0;
28}