[ExecuTorch][WebGPU] Port index_select#21171
Open
JCNTH wants to merge 2 commits into
Open
Conversation
This PR needs a
|
This was referenced Jul 22, 2026
This was referenced Jul 22, 2026
psiddh
approved these changes
Jul 23, 2026
psiddh
left a comment
Contributor
There was a problem hiding this comment.
Approving full WebGPU stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Ports
aten.index_select.defaultas a gather along a dim, mirroring the landedflip/splitindex-transform (dual-TensorMeta, 2D-fold dispatch) + the landedindex/Index.cppint-index binding. index_select is pure data movement, so it remaps the dim coord through an int index and copies — no fp compute.Key changes:
runtime/ops/index_select/{IndexSelect.cpp, index_select.wgsl}(+ generatedindex_select_wgsl.h) — per out flat idx: unravel viaout_meta.strides,in_coord = out_coordwith the dim coord remapped byindex[out_coord[dim]], ravel viain_meta.strides,output[out] = input[in]; the index tensor is bound asarray<i32>(the int32downcast_64_bitof the int64 index, same asIndex.cpp);Params { info: vec4<u32> }carriesdim. Registeredaten.index_select.default.CMakeLists.txt—runtime/ops/index_select/IndexSelect.cppinWEBGPU_SRCS.Buffer re-derivation of the gather (Vulkan
IndexSelect.cppis texture/channel-packed only —op_registry.pytags itCHANNELS_PACKED_TEXTURE; this backend is buffer-only, so the NCHW index math is derived and CPU-de-risked, cf.split.wgsl). Index-value bounds are trusted/unclamped, matching Vulkanindex_select.glsl; a negative index is a memory-safe WGSL OOB read (no trap), same safety class as Vulkan's clampedtexelFetch. No int dtype-guard on self/out (bit-preserving);nbytesguards reject non-fp32 self/out and a non-int32 index.@exported-using-ghexport
Differential Revision: D112257660
Differential Revision: D112257660