[ExecuTorch][WebGPU] Convert remaining native tests to GTest by JulianCloudNTH · Pull Request #20706 · pytorch/executorch · GitHub
Skip to content

[ExecuTorch][WebGPU] Convert remaining native tests to GTest#20706

Open
JulianCloudNTH wants to merge 4 commits into
gh/JulianCloudNTH/85/basefrom
gh/JulianCloudNTH/85/head
Open

[ExecuTorch][WebGPU] Convert remaining native tests to GTest#20706
JulianCloudNTH wants to merge 4 commits into
gh/JulianCloudNTH/85/basefrom
gh/JulianCloudNTH/85/head

Conversation

@JulianCloudNTH

@JulianCloudNTH JulianCloudNTH commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Convert the remaining hand-rolled int main() + printf/bool ok native tests to GTest so the whole backends/webgpu/test/ suite is uniform, filterable via --gtest_filter, and self-reporting (extends the GTest conversion already applied to test_dynamic_shape). The five converted files are a harness-only change — every test case, tensor shape, tolerance, artifact filename, and skip condition is preserved 1:1, only the pass/fail reporting mechanism changes — and this diff additionally wires the already-GTest webgpu_dynamic_shape_test into the CI runner so the dynamic-shape suite actually executes.

Key changes:

  • test/test_webgpu_native.cpp, test/native/test_dispatch_order.cpp, test/native/test_index.cpp, test/native/test_scratch_buffer.cpp, test/native/test_update_cache.cppmain+printf/bool ok accumulator → TEST() cases using EXPECT_*/ASSERT_*; each keeps a custom main() that brings up the WebGPU device once then RUN_ALL_TESTS() (device-absent still SKIPs by returning 0). test_index/test_webgpu_native use inclusive EXPECT_LE(err, tol) to match the original err > tol fail gate exactly.
  • CMakeLists.txt — move every native-test target into the if(TARGET GTest::gtest) block, linking GTest::gtest.
  • scripts/test_webgpu_native_ci.sh — add -DEXECUTORCH_BUILD_TESTS=ON to the native-test configure so the now-gtest-gated targets are defined, and wire webgpu_dynamic_shape_test into the runner: export its .ptes + goldens via export_dynamic_shape_cases, add it to the built/run target list behind the same --target help probe, and run it guarded (mirroring the index test).
  • test/test_build_webgpu.sh — add -DEXECUTORCH_BUILD_TESTS=ON so the local build script (which builds the now-gtest-gated targets unconditionally) still finds them.
    @exported-using-ghexport

Differential Revision: D110536636

Differential Revision: D110536636

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@JulianCloudNTH

Copy link
Copy Markdown
Contributor Author

@claude Review thoroughly. Check for stale code / bugs.

@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown

[ghstack-poisoned]
JulianCloudNTH added a commit that referenced this pull request Jul 3, 2026
Pull Request resolved: #20706

Convert the remaining hand-rolled `int main()` + printf/`bool ok` native tests to GTest so the whole `backends/webgpu/test/` suite is uniform, filterable via `--gtest_filter`, and self-reporting (extends the GTest conversion already applied to `test_dynamic_shape`). The five converted files are a harness-only change — every test case, tensor shape, tolerance, artifact filename, and skip condition is preserved 1:1, only the pass/fail reporting mechanism changes — and this diff additionally wires the already-GTest `webgpu_dynamic_shape_test` into the CI runner so the dynamic-shape suite actually executes.

Key changes:
- `test/test_webgpu_native.cpp`, `test/native/test_dispatch_order.cpp`, `test/native/test_index.cpp`, `test/native/test_scratch_buffer.cpp`, `test/native/test_update_cache.cpp` — `main`+`printf`/`bool ok` accumulator → `TEST()` cases using `EXPECT_*`/`ASSERT_*`; each keeps a custom `main()` that brings up the WebGPU device once then `RUN_ALL_TESTS()` (device-absent still SKIPs by returning 0). `test_index`/`test_webgpu_native` use inclusive `EXPECT_LE(err, tol)` to match the original `err > tol` fail gate exactly.
- `CMakeLists.txt` — move every native-test target into the `if(TARGET GTest::gtest)` block, linking `GTest::gtest`.
- `scripts/test_webgpu_native_ci.sh` — add `-DEXECUTORCH_BUILD_TESTS=ON` to the native-test configure so the now-gtest-gated targets are defined, and wire `webgpu_dynamic_shape_test` into the runner: export its `.pte`s + goldens via `export_dynamic_shape_cases`, add it to the built/run target list behind the same `--target help` probe, and run it guarded (mirroring the `index` test).
- `test/test_build_webgpu.sh` — add `-DEXECUTORCH_BUILD_TESTS=ON` so the local build script (which builds the now-gtest-gated targets unconditionally) still finds them.
ghstack-source-id: 399790083
@exported-using-ghexport

Differential Revision: [D110536636](https://our.internmc.facebook.com/intern/diff/D110536636/)
[ghstack-poisoned]
JulianCloudNTH added a commit that referenced this pull request Jul 3, 2026
Pull Request resolved: #20706

Convert the remaining hand-rolled `int main()` + printf/`bool ok` native tests to GTest so the whole `backends/webgpu/test/` suite is uniform, filterable via `--gtest_filter`, and self-reporting (extends the GTest conversion already applied to `test_dynamic_shape`). The five converted files are a harness-only change — every test case, tensor shape, tolerance, artifact filename, and skip condition is preserved 1:1, only the pass/fail reporting mechanism changes — and this diff additionally wires the already-GTest `webgpu_dynamic_shape_test` into the CI runner so the dynamic-shape suite actually executes.

Key changes:
- `test/test_webgpu_native.cpp`, `test/native/test_dispatch_order.cpp`, `test/native/test_index.cpp`, `test/native/test_scratch_buffer.cpp`, `test/native/test_update_cache.cpp` — `main`+`printf`/`bool ok` accumulator → `TEST()` cases using `EXPECT_*`/`ASSERT_*`; each keeps a custom `main()` that brings up the WebGPU device once then `RUN_ALL_TESTS()` (device-absent still SKIPs by returning 0). `test_index`/`test_webgpu_native` use inclusive `EXPECT_LE(err, tol)` to match the original `err > tol` fail gate exactly.
- `CMakeLists.txt` — move every native-test target into the `if(TARGET GTest::gtest)` block, linking `GTest::gtest`.
- `scripts/test_webgpu_native_ci.sh` — add `-DEXECUTORCH_BUILD_TESTS=ON` to the native-test configure so the now-gtest-gated targets are defined, and wire `webgpu_dynamic_shape_test` into the runner: export its `.pte`s + goldens via `export_dynamic_shape_cases`, add it to the built/run target list behind the same `--target help` probe, and run it guarded (mirroring the `index` test).
- `test/test_build_webgpu.sh` — add `-DEXECUTORCH_BUILD_TESTS=ON` so the local build script (which builds the now-gtest-gated targets unconditionally) still finds them.
ghstack-source-id: 399809713
@exported-using-ghexport

Differential Revision: [D110536636](https://our.internmc.facebook.com/intern/diff/D110536636/)
@JulianCloudNTH JulianCloudNTH requested a review from psiddh July 3, 2026 21:27
[ghstack-poisoned]
JulianCloudNTH added a commit that referenced this pull request Jul 3, 2026
Pull Request resolved: #20706

Convert the remaining hand-rolled `int main()` + printf/`bool ok` native tests to GTest so the whole `backends/webgpu/test/` suite is uniform, filterable via `--gtest_filter`, and self-reporting (extends the GTest conversion already applied to `test_dynamic_shape`). The five converted files are a harness-only change — every test case, tensor shape, tolerance, artifact filename, and skip condition is preserved 1:1, only the pass/fail reporting mechanism changes — and this diff additionally wires the already-GTest `webgpu_dynamic_shape_test` into the CI runner so the dynamic-shape suite actually executes.

Key changes:
- `test/test_webgpu_native.cpp`, `test/native/test_dispatch_order.cpp`, `test/native/test_index.cpp`, `test/native/test_scratch_buffer.cpp`, `test/native/test_update_cache.cpp` — `main`+`printf`/`bool ok` accumulator → `TEST()` cases using `EXPECT_*`/`ASSERT_*`; each keeps a custom `main()` that brings up the WebGPU device once then `RUN_ALL_TESTS()` (device-absent still SKIPs by returning 0). `test_index`/`test_webgpu_native` use inclusive `EXPECT_LE(err, tol)` to match the original `err > tol` fail gate exactly.
- `CMakeLists.txt` — move every native-test target into the `if(TARGET GTest::gtest)` block, linking `GTest::gtest`.
- `scripts/test_webgpu_native_ci.sh` — add `-DEXECUTORCH_BUILD_TESTS=ON` to the native-test configure so the now-gtest-gated targets are defined, and wire `webgpu_dynamic_shape_test` into the runner: export its `.pte`s + goldens via `export_dynamic_shape_cases`, add it to the built/run target list behind the same `--target help` probe, and run it guarded (mirroring the `index` test).
- `test/test_build_webgpu.sh` — add `-DEXECUTORCH_BUILD_TESTS=ON` so the local build script (which builds the now-gtest-gated targets unconditionally) still finds them.
ghstack-source-id: 399812941
@exported-using-ghexport

Differential Revision: [D110536636](https://our.internmc.facebook.com/intern/diff/D110536636/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants