-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (99 loc) · 3.46 KB
/
Makefile
File metadata and controls
115 lines (99 loc) · 3.46 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
.PHONY: save demo_deps demo_models demo_profile demo_doc demo_readme demo demo_clean ci_bench ci_guard ci_policy_gate enrich_demo ci_enrich_smoke
SIZES ?= 224 320 640
RUNS ?= 300
BATCH ?= 1
WARMUP ?= 10
INTRA ?= 1
INTER ?= 1
CI ?= 0
# 문서에 보여줄 최신 결과(최근 N개 파일 기준으로 latest 테이블 생성)
RECENT ?= 30
BENCH_DOC ?= BENCHMARKS.md
BASE_RESULT ?=
NEW_RESULT ?=
BASE_ACCURACY_JSON ?=
NEW_ACCURACY_JSON ?=
ENRICH_OUT_DIR ?= results_enriched
save:
git add -A
git commit -m "Auto-save $$(date -u +%Y-%m-%dT%H:%M:%SZ)" || true
git push
demo_deps:
poetry install
poetry run python -m pip install -U pip
poetry run python -m pip install torch onnxscript
demo_models: demo_deps
mkdir -p models
@set -e; \
for s in $(SIZES); do \
echo "==> Generating toy model: $${s}x$${s}"; \
poetry run python scripts/make_toy_model.py --height $$s --width $$s --out models/toy$${s}.onnx; \
done
demo_profile: demo_models
mkdir -p reports
@set -e; \
ts=$$(date -u +%Y%m%d-%H%M%S); \
for s in $(SIZES); do \
echo "==> Profiling: models/toy$${s}.onnx"; \
poetry run edgebench profile models/toy$${s}.onnx \
--warmup $(WARMUP) \
--runs $(RUNS) \
--batch $(BATCH) \
--height $$s --width $$s \
--intra-threads $(INTRA) \
--inter-threads $(INTER) \
-o reports/toy$${s}__onnxruntime_cpu__b$(BATCH)__h$${s}w$${s}__r$(RUNS)__t$(INTRA)x$(INTER)__$${ts}.json; \
done
@echo "Done. Reports saved under ./reports/"
# BENCHMARKS.md 생성:
# 1) Latest: 최근 N개 파일만 고려하고, (모델/해상도별) 최신 1개만 남김
# 2) History: 전체 raw를 시간순으로 남김
demo_doc:
@echo "==> Writing benchmark doc: $(BENCH_DOC)"
@echo "# Benchmarks" > $(BENCH_DOC)
@echo "" >> $(BENCH_DOC)
@echo "> Auto-generated by \`make demo\` / CI" >> $(BENCH_DOC)
@echo "" >> $(BENCH_DOC)
poetry run edgebench summarize "reports/*.json" --mode latest --sort p99 --recent $(RECENT) >> $(BENCH_DOC)
@echo "" >> $(BENCH_DOC)
poetry run edgebench summarize "reports/*.json" --mode history --sort time >> $(BENCH_DOC)
@echo "" >> $(BENCH_DOC)
@echo "Saved: $(BENCH_DOC)"
demo_readme: demo_doc
@echo "==> Updating README.md Benchmarks block"
poetry run python scripts/update_readme.py --readme README.md --bench $(BENCH_DOC)
demo: demo_profile demo_readme
@echo "✅ demo complete (updated $(BENCH_DOC) + README)"
demo_clean:
rm -rf models reports $(BENCH_DOC)
ci_bench: demo_profile demo_doc
@echo "✅ ci_bench complete (reports + $(BENCH_DOC), no README update)"
ci_guard:
@echo "==> Regression guard (mean, +15% allowed)"
poetry run python scripts/check_regression.py \
--baseline benchmarks/baseline_codespaces_cpu.json \
--reports "reports/*.json" \
--metric mean \
--max-regress-pct 15 \
--allow-missing-keys
ci_policy_gate:
@echo "==> Compare policy gate (same_precision, multi-size)"
@set -e; \
for s in $(SIZES); do \
echo "==> Policy gate for toy$${s}.onnx"; \
poetry run python scripts/check_compare_policy.py \
--pattern "results/*.json" \
--selection-mode same_precision \
--model toy$${s}.onnx \
--fail-on-same-precision-regression \
--fail-on-severe-tradeoff; \
done
enrich_demo:
poetry run python scripts/run_enriched_accuracy_demo.py \
--base-result "$(BASE_RESULT)" \
--base-accuracy-json "$(BASE_ACCURACY_JSON)" \
--new-result "$(NEW_RESULT)" \
--new-accuracy-json "$(NEW_ACCURACY_JSON)" \
--out-dir "$(ENRICH_OUT_DIR)"
ci_enrich_smoke:
poetry run pytest tests/test_run_enriched_accuracy_demo.py -q