Skip to content

Commit 9777bef

Browse files
committed
[ExecuTorch][WebGPU] Flatten landed-op test dirs to test/ops/test_<op>.py
Pull Request resolved: #20435 Pure test-file relocation: moves the already-landed ops' tests from nested `test/ops/<op>/test_<op>.py` to flat `test/ops/test_<op>.py`, matching the ExecuTorch convention (XNNPACK uses flat `test/ops/test_<op>.py`; Vulkan uses flat `test/test_*.py`) and completing the flatten applied to the new ops in the stack below. Drops the per-op `__init__.py`; the parent `test/ops/__init__.py` is kept. Ops: `add`, `rms_norm`, `sdpa` (`test_sdpa` + `test_update_cache`), `dispatch_order`, `quantized_linear`, `embedding_q4gsw`, `rope`, `prepack`. No behavior change — the test modules and their export/golden functions are unchanged; only their path moves. Every reference to the old paths is updated: the `cases.py` op-test imports (`add`, `rms_norm`), `test/TARGETS` (`test_add` srcs), `test/ops/test_dispatch_order.py`'s internal `rms_norm` import, and the build/CI scripts that import the per-op export functions (`test/test_build_webgpu.sh`, `scripts/test_webgpu_native_ci.sh`). Nothing required the per-op subdirectory: the codegen framework imports only `cases.py`, the one buck target uses a literal path, and the native-golden scripts import the modules by path — each resolves identically at the flat path. ghstack-source-id: 397534695 @exported-using-ghexport @diff-train-skip-merge Differential Revision: [D109349894](https://our.internmc.facebook.com/intern/diff/D109349894/)
1 parent 178b4d9 commit 9777bef

21 files changed

Lines changed: 29 additions & 55 deletions

backends/webgpu/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,10 @@ backends/webgpu/
140140
├── test_webgpu_native.cpp # C++ native test runner
141141
├── test_wgsl_codegen.py # Shader codegen check
142142
├── native/ # C++ operator tests
143-
└── ops/ # Python export tests
144-
├── add/
145-
│ └── test_add.py # add export tests
146-
└── rms_norm/
147-
└── test_rms_norm.py # rms_norm export tests
143+
└── ops/ # Python op test suites (flat: test_<op>.py)
144+
├── test_add.py
145+
├── test_rms_norm.py
146+
└── ... # one test_<op>.py per op
148147
```
149148

150149
## Requirements

backends/webgpu/scripts/test_webgpu_native_ci.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,36 +65,36 @@ PREPACK_TIED_MODEL="/tmp/webgpu_prepack_tied_const.pte"
6565
PREPACK_TIED_GOLDEN="/tmp/webgpu_prepack_tied_const_golden.bin"
6666

6767
$PYTHON_EXECUTABLE -c "
68-
from executorch.backends.webgpu.test.ops.quantized_linear.test_quantized_linear import export_all_quantized_linear_models
68+
from executorch.backends.webgpu.test.ops.test_quantized_linear import export_all_quantized_linear_models
6969
export_all_quantized_linear_models('/tmp')
7070
" || echo "WARN: q4gsw export failed; required configs will FAIL in webgpu_native_test"
7171

7272
$PYTHON_EXECUTABLE -c "
73-
from executorch.backends.webgpu.test.ops.embedding_q4gsw.test_embedding_q4gsw import export_embedding_q4gsw_model
73+
from executorch.backends.webgpu.test.ops.test_embedding_q4gsw import export_embedding_q4gsw_model
7474
export_embedding_q4gsw_model('${EMBEDDING_MODEL}', '${EMBEDDING_GOLDEN}', '${EMBEDDING_INDICES}')
7575
export_embedding_q4gsw_model('${EMBEDDING_LLAMA1B_MODEL}', '${EMBEDDING_LLAMA1B_GOLDEN}', '${EMBEDDING_LLAMA1B_INDICES}', 'llama1b')
7676
" || echo "WARN: embedding_q4gsw export failed; embedding configs will FAIL in webgpu_native_test"
7777

7878
$PYTHON_EXECUTABLE -c "
79-
from executorch.backends.webgpu.test.ops.rope.test_rope import export_rope_model
79+
from executorch.backends.webgpu.test.ops.test_rope import export_rope_model
8080
export_rope_model('${ROPE_MODEL}', '${ROPE_XQ_GOLDEN}', '${ROPE_XK_GOLDEN}')
8181
export_rope_model('${ROPE_DECODE_MODEL}', '${ROPE_DECODE_XQ_GOLDEN}', '${ROPE_DECODE_XK_GOLDEN}', 'decode')
8282
" || echo "WARN: rope export failed; apply_rotary_emb configs will FAIL in webgpu_native_test"
8383

8484
$PYTHON_EXECUTABLE -c "
85-
from executorch.backends.webgpu.test.ops.prepack.test_prepack import export_prepack_model, export_prepack_two_const_model, export_prepack_tied_const_model
85+
from executorch.backends.webgpu.test.ops.test_prepack import export_prepack_model, export_prepack_two_const_model, export_prepack_tied_const_model
8686
export_prepack_model('${PREPACK_MODEL}', '${PREPACK_GOLDEN}')
8787
export_prepack_two_const_model('${PREPACK2_MODEL}', '${PREPACK2_GOLDEN}')
8888
export_prepack_tied_const_model('${PREPACK_TIED_MODEL}', '${PREPACK_TIED_GOLDEN}')
8989
" || echo "WARN: prepack export failed; prepack configs will FAIL in webgpu_native_test"
9090

9191
$PYTHON_EXECUTABLE -c "
92-
from executorch.backends.webgpu.test.ops.dispatch_order.test_dispatch_order import export_dispatch_order_cases
92+
from executorch.backends.webgpu.test.ops.test_dispatch_order import export_dispatch_order_cases
9393
export_dispatch_order_cases('${DISPATCH_ORDER_DIR}')
9494
" || { echo "WARN: dispatch_order export failed; skipping dispatch_order native test"; DISPATCH_ORDER_OK=0; }
9595

9696
$PYTHON_EXECUTABLE -c "
97-
from executorch.backends.webgpu.test.ops.sdpa.test_update_cache import (
97+
from executorch.backends.webgpu.test.ops.test_update_cache import (
9898
export_update_cache_cases,
9999
export_update_cache_replay,
100100
export_update_cache_negative,
@@ -107,7 +107,7 @@ export_update_cache_negative('${UPDATE_CACHE_DIR}')
107107
# Non-fatal: a failed sdpa export makes the required 4k/8k configs hard-fail in
108108
# webgpu_native_test below (precise per-config error), so don't exit/mask here.
109109
$PYTHON_EXECUTABLE -c "
110-
from executorch.backends.webgpu.test.ops.sdpa.test_sdpa import (
110+
from executorch.backends.webgpu.test.ops.test_sdpa import (
111111
export_all_sdpa_models,
112112
export_replay_sequences,
113113
export_dynamic_decode,

backends/webgpu/test/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ oncall("executorch")
77
python_unittest(
88
name = "test_add",
99
srcs = [
10-
"ops/add/test_add.py",
10+
"ops/test_add.py",
1111
],
1212
deps = [
1313
"//caffe2:torch",

backends/webgpu/test/op_tests/cases.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,11 @@
2525
WebGPUTestSuite,
2626
XS,
2727
)
28-
from executorch.backends.webgpu.test.ops.add.test_add import (
28+
from executorch.backends.webgpu.test.ops.test_add import (
2929
AddChainedModule,
3030
AddModule,
3131
AddSelfModule,
3232
)
33-
from executorch.backends.webgpu.test.ops.rms_norm.test_rms_norm import (
34-
_CASES,
35-
_linspace_weight,
36-
_ramp,
37-
RmsNormModule,
38-
)
3933
from executorch.backends.webgpu.test.ops.test_cat import (
4034
CatModule,
4135
CONFIGS as _CAT_CONFIGS,
@@ -48,6 +42,12 @@
4842
CONFIGS as _PERMUTE_CONFIGS,
4943
PermuteModule,
5044
)
45+
from executorch.backends.webgpu.test.ops.test_rms_norm import (
46+
_CASES,
47+
_linspace_weight,
48+
_ramp,
49+
RmsNormModule,
50+
)
5151
from executorch.backends.webgpu.test.ops.test_select import (
5252
CONFIGS as _SELECT_CONFIGS,
5353
SelectModule,
@@ -92,7 +92,7 @@ def _add_factory(variant: str = "regular") -> torch.nn.Module:
9292
@register_op_test("add")
9393
def _add_suite() -> WebGPUTestSuite:
9494
# Same-shape numeric coverage only: broadcast adds stay export-smoke in
95-
# ops/add/test_add.py because the kernel can't broadcast.
95+
# ops/test_add.py because the kernel can't broadcast.
9696
return WebGPUTestSuite(
9797
module_factory=_add_factory,
9898
cases=[

backends/webgpu/test/ops/dispatch_order/__init__.py

Whitespace-only changes.

backends/webgpu/test/ops/embedding_q4gsw/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

backends/webgpu/test/ops/prepack/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

backends/webgpu/test/ops/quantized_linear/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

backends/webgpu/test/ops/rms_norm/__init__.py

Whitespace-only changes.

backends/webgpu/test/ops/rope/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)