-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (95 loc) · 6.38 KB
/
Copy pathMakefile
File metadata and controls
124 lines (95 loc) · 6.38 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
116
117
118
119
120
121
122
123
124
# ScratchV developer makefile
.POSIX:
.PHONY: quick-start install test bench bench-cnn clean lint
# ── Beginner quick-start ─────────────────────────────────────────────────────
quick-start:
@echo "╔══════════════════════════════════════════╗"
@echo "║ ⚡ ScratchV — 快速上手 ║"
@echo "╠══════════════════════════════════════════╣"
@echo "║ ║"
@echo "║ 1. 创建虚拟环境 ║"
@echo "║ python3 -m venv .venv ║"
@echo "║ source .venv/bin/activate ║"
@echo "║ ║"
@echo "║ 2. 安装 ScratchV ║"
@echo "║ pip install -e . ║"
@echo "║ ║"
@echo "║ 3. 运行测试 (确认环境正确) ║"
@echo "║ make test ║"
@echo "║ ║"
@echo "║ 4. 编译你的第一个 AI 模型 ║"
@echo "║ make bench-cnn ║"
@echo "║ ║"
@echo "║ 5. 打开交互式课程 (浏览器) ║"
@echo "║ xdg-open docs/topics/html/index.html ║"
@echo "║ ║"
@echo "║ 📖 详细教程: docs/00-环境搭建指南.md ║"
@echo "╚══════════════════════════════════════════╝"
# ── Installation ──────────────────────────────────────────────────────────
install:
pip install -e .
pip install -e ".[all]" 2>/dev/null || pip install -e .
# ── 课题功能测试 ──────────────────────────────────────────────────────────
test:
python3 -m pytest tests/ -v --tb=short
# ── 模型性能基准 ──────────────────────────────────────────────────────────
bench:
python3 -m pytest benchmarks/test_benchmark.py -v --tb=short
python3 benchmarks/bench_runner.py benchmarks/cases \
--output-json benchmark_reports/dsl_bench.json \
--output-html benchmark_reports/dsl_bench.html
# ── CNN RISC-V 编译 + 估算 ────────────────────────────────────────────────
bench-cnn:
python3 scratchv/standalone/onnx_to_riscv_standalone.py models/graph/cnn.onnx \
-o /tmp/cnn_riscv.bin --estimate --report
@echo "Reports: benchmark_reports/"
# ── CNN RISC-V 编译 + TinyFive 仿真验证 ───────────────────────────────────
bench-tinyfive:
python3 scratchv/standalone/onnx_to_riscv_standalone.py models/graph/cnn.onnx \
-o /tmp/cnn_riscv.bin --estimate --tinyfive --tinyfive-max-instr 200000
@echo "TinyFive simulation complete."
# ── CI Benchmark (LLVM + TinyFive + 可视化仪表盘) ──────────────────────────
bench-ci:
@mkdir -p benchmark_reports
python3 scratchv/ci/ci_benchmark.py \
--model-registry ci_models.json \
--output-dir benchmark_reports/ \
--html dashboard.html \
--json-out ci_data.json \
--md github_summary.md \
--embed-json \
--skip-cache
@echo ""
@echo "Dashboard: benchmark_reports/dashboard.html"
@echo "JSON data: benchmark_reports/ci_data.json"
@echo "GitHub summary: benchmark_reports/github_summary.md"
# ── ONNX 模型拆分 ────────────────────────────────────────────────────────
split-models:
python3 scripts/split_cnn_to_single_ops.py
@echo "Single-op models: models/single_op/"
# ── 单算子 Benchmark ─────────────────────────────────────────────────────
bench-single-ops: split-models
python3 scripts/bench_single_ops.py
@echo "Single-op benchmark: benchmark_reports/single_op_bench.json"
# ── Dashboard (仅指令集维度 + 算子粒度) ──────────────────────────────────
bench-dashboard:
python3 scratchv/ci/dashboard.py --run -o benchmark_reports/dashboard.html
@echo "Dashboard: benchmark_reports/dashboard.html"
# ── 优化历史页面 ─────────────────────────────────────────────────────────
bench-history:
python3 scratchv/ci/history_page.py -o benchmark_reports/history.html
@echo "History page: benchmark_reports/history.html"
# ── 全量报告 (dashboard + history) ───────────────────────────────────────
bench-reports: bench-dashboard bench-history
@echo "All reports generated in benchmark_reports/"
# ── Clean ─────────────────────────────────────────────────────────────────
clean:
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null
find . -type f -name '*.pyc' -delete
rm -rf .pytest_cache scratchv.egg-info scratchv_dag.egg-info dist build
rm -f output.s output.ll
rm -rf benchmark_reports
# ── Lint (development only) ───────────────────────────────────────────────
lint:
-python3 -m flake8 scratchv/ scratchv_dag/ tests/ 2>/dev/null || echo "pip install flake8"
-python3 -m mypy scratchv/ scratchv_dag/ --ignore-missing-imports 2>/dev/null || echo "pip install mypy"