Accept integral Double select scalars (#21387) - #21387
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21387
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@JCNTH has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113588820. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR improves WebGPU runtime compatibility with Vulkan-serialized graphs by allowing aten.select_copy.int to consume Double scalar values when they are exactly integral and within int64_t range, matching Vulkan’s scalar deduplication behavior while still rejecting fractional/non-finite/out-of-range and symbolic values.
Changes:
- Extend WebGPU select scalar parsing to accept
Doublevalues only when they are integral and safely convertible toint64_t. - Add WebGPU native regression tests covering successful execution for integral
Doubledim/index, boundary cases, and expected build-time rejections (fractional, NaN/Inf, out-of-range, SymInt).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backends/webgpu/runtime/ops/select/Select.cpp | Accept integral Double scalars for select dim/index with validated conversion; keep SymInt/dynamic rejection behavior. |
| backends/webgpu/test/test_webgpu_native.cpp | Add regression + negative tests for Vulkan-serialized select graphs where integer args alias cached Double scalars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary: **Loads existing Vulkan-serialized select graphs whose integer arguments alias Double constants.** Problem: Vulkan serialization deduplicates equal scalar values, so an integer select dimension or index can reference a previously emitted Double. WebGPU rejected those graphs even though Vulkan accepts the scalar representation. Solution: - Before: `aten.select_copy.int` accepted only serialized Int values. - After: it also accepts exactly integral Double values in the `int64_t` range and rejects fractional, non-finite, out-of-range, and symbolic values. Implementation: - `Select.cpp` — validates Double range and integrality before conversion. - `test_webgpu_native.cpp` — adds direct VK00 success, boundary, and rejection coverage. - Mirrors Vulkan `ComputeGraph::extract_scalar<int64_t>` scalar acceptance while retaining stricter checked conversion. Constraints: The shader, dispatch, resize behavior, and SymInt policy are unchanged. Co-authored-with: Claude Code. Differential Revision: D113588820
SS-JIA
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary:
Loads existing Vulkan-serialized select graphs whose integer arguments alias Double constants.
Problem: Vulkan serialization deduplicates equal scalar values, so an integer select dimension or index can reference a previously emitted Double. WebGPU rejected those graphs even though Vulkan accepts the scalar representation.
Solution:
aten.select_copy.intaccepted only serialized Int values.int64_trange and rejects fractional, non-finite, out-of-range, and symbolic values.Implementation:
Select.cpp— validates Double range and integrality before conversion.test_webgpu_native.cpp— adds direct VK00 success, boundary, and rejection coverage.ComputeGraph::extract_scalar<int64_t>scalar acceptance while retaining stricter checked conversion.Constraints: The shader, dispatch, resize behavior, and SymInt policy are unchanged.
Co-authored-with: Claude Code.
Differential Revision: D113588820