-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (44 loc) · 1.71 KB
/
Copy pathMakefile
File metadata and controls
54 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
.PHONY: run check fp model artifact golden golden-check verify test
SQLITE3 ?= sqlite3
CC ?= cc
ORACLE_CFLAGS := -std=c11 -O2 -fwrapv \
-Wno-unused-function -Wno-unused-variable \
-DMGPT_NO_TRAIN -DMGPT_NO_MAIN -DMGPT_PACKED_F12 \
-DMGPT_OBSERVE_LOGITS -I reference
run:
$(SQLITE3) :memory: < microgpt.sql
check:
@set -eu; out=$$(mktemp); \
trap 'rm -f "$$out"' EXIT; \
$(SQLITE3) :memory: < microgpt.sql > "$$out"; \
diff -u expected_output.txt "$$out"; \
echo 'CHECK_RESULT=PASS (standalone output matches expected_output.txt)'
fp:
bash tests/fp_test.sh
model:
bash tools/rebuild_model.sh
artifact:
bash tests/artifact_test.sh
golden:
@set -eu; work=$$(mktemp -d); \
trap 'rm -rf "$$work"' EXIT; \
$(CC) $(ORACLE_CFLAGS) reference/dump_main.c -o "$$work/dump"; \
"$$work/dump" --vectors > "$$work/vectors.txt"; \
"$$work/dump" --weights model/uniform-f12.mgw > "$$work/weights.txt"; \
"$$work/dump" --trace model/uniform-f12.mgw > "$$work/trace.txt"; \
cp "$$work/vectors.txt" reference/vectors.txt; \
cp "$$work/weights.txt" reference/weights.txt; \
cp "$$work/trace.txt" reference/trace.txt
golden-check:
@set -eu; work=$$(mktemp -d); \
trap 'rm -rf "$$work"' EXIT; \
$(CC) $(ORACLE_CFLAGS) reference/dump_main.c -o "$$work/dump"; \
"$$work/dump" --vectors > "$$work/vectors.txt"; \
"$$work/dump" --weights model/uniform-f12.mgw > "$$work/weights.txt"; \
"$$work/dump" --trace model/uniform-f12.mgw > "$$work/trace.txt"; \
cmp reference/vectors.txt "$$work/vectors.txt"; \
cmp reference/weights.txt "$$work/weights.txt"; \
cmp reference/trace.txt "$$work/trace.txt"; \
echo 'GOLDEN_RESULT=PASS (all oracle artifacts reproduce byte-identically)'
verify: check fp model artifact golden-check
test: verify