From 346fd7db12502defbed88b7e723d96f9ff0d1fda Mon Sep 17 00:00:00 2001 From: yutianyu Date: Mon, 4 May 2026 23:35:28 +0800 Subject: [PATCH] refactor: rename op tests and update benchmark entrypoint Co-authored-by: wawahejun --- docs/how-to-add-an-operator.md | 6 +++--- tests/{ops => op_tests}/__init__.py | 0 tests/{ops => op_tests}/test_copy.py | 0 tests/{ops => op_tests}/test_reduce_sum.py | 0 tests/{ops => op_tests}/test_softmax.py | 0 tests/{ops => op_tests}/test_vector_add.py | 0 tests/run_ops.py | 8 ++------ 7 files changed, 5 insertions(+), 9 deletions(-) rename tests/{ops => op_tests}/__init__.py (100%) rename tests/{ops => op_tests}/test_copy.py (100%) rename tests/{ops => op_tests}/test_reduce_sum.py (100%) rename tests/{ops => op_tests}/test_softmax.py (100%) rename tests/{ops => op_tests}/test_vector_add.py (100%) diff --git a/docs/how-to-add-an-operator.md b/docs/how-to-add-an-operator.md index ed7e787..f608913 100644 --- a/docs/how-to-add-an-operator.md +++ b/docs/how-to-add-an-operator.md @@ -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. 至少完成一次单算子验证。 diff --git a/tests/ops/__init__.py b/tests/op_tests/__init__.py similarity index 100% rename from tests/ops/__init__.py rename to tests/op_tests/__init__.py diff --git a/tests/ops/test_copy.py b/tests/op_tests/test_copy.py similarity index 100% rename from tests/ops/test_copy.py rename to tests/op_tests/test_copy.py diff --git a/tests/ops/test_reduce_sum.py b/tests/op_tests/test_reduce_sum.py similarity index 100% rename from tests/ops/test_reduce_sum.py rename to tests/op_tests/test_reduce_sum.py diff --git a/tests/ops/test_softmax.py b/tests/op_tests/test_softmax.py similarity index 100% rename from tests/ops/test_softmax.py rename to tests/op_tests/test_softmax.py diff --git a/tests/ops/test_vector_add.py b/tests/op_tests/test_vector_add.py similarity index 100% rename from tests/ops/test_vector_add.py rename to tests/op_tests/test_vector_add.py diff --git a/tests/run_ops.py b/tests/run_ops.py index 62369b6..0439d50 100644 --- a/tests/run_ops.py +++ b/tests/run_ops.py @@ -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"):