[ET-VK] Modernize permute op with safe indexing and unified dispatch#18514
Merged
Conversation
Modernize the permute operator to follow current best practices, fixing an Adreno 740 driver crash caused by dynamic UBO indexing in the texture shader. Texture shader changes: - Replace old indexing_utils.h with indexing.glslh - Use TextureMetadata UBOs instead of push constant sizes - Use texture_pos_to_tensor4d_idx_simple() and related helpers - Replace permute_dims[out_packed_dim] with safe_idx() to avoid dynamic indexing of push constant with spec-const-derived index - Use TextureElementIndex pattern for the slow path C++ dispatch changes: - Merge add_permute_node() and add_permute_buffer_node() into a single unified function using graph.meta_ubo() and conditional logic - Remove unused channel_info computation - Move WHCNPermuteDims struct into anonymous namespace - Guard texture path with VK_CHECK_COND(permute_ndim <= 4) Differential Revision: [D98220451](https://our.internmc.facebook.com/intern/diff/D98220451/) ghstack-source-id: 357844381 Pull Request resolved: #18511
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18514
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 33 PendingAs of commit de83a9f with merge base 8d43d97 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
The Adreno 740 GPU driver crashes (SIGSEGV in vkCreateComputePipelines) when GLSL shaders dynamically index a UBO-backed ivec4/ivec3 with a specialization-constant-derived value. This was causing the skin segmentation model to crash during pipeline creation on Samsung S23. Fix all instances across 18 shader files by replacing patterns like `meta.sizes[packed_dim]` with `safe_idx(meta.sizes, packed_dim)`, which uses an if/else chain that the driver resolves at pipeline creation time. Changes: - Add safe_idx(ivec3) overload to indexing.glslh - Fix transfer_texture.glsl, slice.glslh, select.glslh (transfer ops) - Fix nchw_to_int8x4_buffer.glsl, full_texture.glsl (staging/utility) - Fix gather, split, index_tensor, where, expand, pad, repeat, arange texture shaders (1-line fixes each) - Fix softmax.glsl, reduce.glsl, reduce2d.glsl, var_texture3d.glsl (reduction shaders with multiple fixes + added indexing.glslh include) - Remove unused ShaderNameUtils.h include from Slice.cpp Differential Revision: [D98220450](https://our.internmc.facebook.com/intern/diff/D98220450/) ghstack-source-id: 357844383 Pull Request resolved: #18512
SS-JIA
approved these changes
Mar 26, 2026
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.
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #18511 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/510/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/510/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/510/orig
Differential Revision: D98220451
@diff-train-skip-merge