refactor: rename op tests and update benchmark entrypoint

Co-authored-by: wawahejun <hejunlbbc@gmail.com>
This commit is contained in:
yutianyu 2026-05-04 23:35:28 +08:00
parent a2cda3fda7
commit 346fd7db12
7 changed files with 5 additions and 9 deletions

View File

@ -32,7 +32,7 @@
- `ops/<算子名>/nvidia/`
- `python/operator_runtime/ops/<算子名>.py`
- `tests/cases/<算子名>.py`
- `tests/ops/test_<算子名>.py`
- `tests/op_tests/test_<算子名>.py`
- `tests/bench/<算子名>.py`
如果后续要支持 TileLang 或 MetaX再分别补 `tilelang/``metax/`
@ -112,7 +112,7 @@ Python 入口放在 `python/operator_runtime/ops/<算子名>.py`。
## Step 7补正确性测试
`tests/ops/test_<算子名>.py` 主要负责三件事:
`tests/op_tests/test_<算子名>.py` 主要负责三件事:
1. 正确性对比
2. API contract 检查
@ -191,7 +191,7 @@ API contract 测试主要覆盖 shape 不匹配、dtype 不匹配、非 contiguo
2. `python/operator_runtime/ops/<算子名>.py` 已补齐。
3. 两个 `__init__.py` 已导出新接口。
4. `tests/cases/<算子名>.py` 已补数据。
5. `tests/ops/test_<算子名>.py` 已补测试。
5. `tests/op_tests/test_<算子名>.py` 已补测试。
6. `tests/bench/<算子名>.py` 已补 benchmark。
7. 新增 `.cu` 后已经重新执行过 `cmake ..`
8. 至少完成一次单算子验证。

View File

@ -16,7 +16,7 @@ if str(ROOT) not in sys.path:
def _discover_ops() -> tuple[str, ...]:
ops_dir = ROOT / "tests" / "ops"
ops_dir = ROOT / "tests" / "op_tests"
bench_dir = ROOT / "tests" / "bench"
names: set[str] = set()
@ -58,8 +58,6 @@ def _format_bench_table(rows) -> str:
"runtime_ms",
"torch_ms",
"speedup",
"GB/s",
"GFLOP/s",
]
body = []
for row in rows:
@ -74,8 +72,6 @@ def _format_bench_table(rows) -> str:
f"{row.runtime_ms:.4f}",
torch_ms,
speedup,
f"{row.gbytes_per_sec:.2f}",
f"{row.gflops_per_sec:.2f}",
]
)
@ -129,7 +125,7 @@ def main() -> int:
for op in selected_ops:
if args.mode in ("test", "all"):
ok, detail = _run_pytest(f"tests/ops/test_{op}.py", args.backend)
ok, detail = _run_pytest(f"tests/op_tests/test_{op}.py", args.backend)
rows.append(["test", op, args.backend, "ok" if ok else "fail", detail])
failed = failed or not ok
if args.mode in ("bench", "all"):