Arm backend: Fuse canonical flow-offset grid sampling - #21775
Merged
YufengShi-dudu merged 1 commit intoAug 12, 2026
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21775
Note: Links to docs will display an error until the docs builds have been completed. ❌ 8 Pending, 1 Unclassified FailureAs of commit b34ec8b with merge base 8de0262 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
zingo
approved these changes
Aug 12, 2026
Recognize grid_sample calls that add a two-channel flow slice to an
align-corners base grid:
base_grid ---------\
add -> permute -> grid_sample(image, grid)
flow[:, i:i+2] ----/
Replace the complete expression with:
image, flow -> fused flow-offset custom shader
This avoids materializing the normalized sampling grid at runtime.
Require SNORM-compatible image and output quantization ranges. Vulkan's
signed normalized 8-bit image format maps both -128 and -127 to -1.0,
so only fuse tensors using the range [-127, 127]. The flow tensor keeps
the full int8 range because the shader reads it directly as a tensor.
If glslc is unavailable or compilation fails, leave the graph unchanged
for generic grid-sampler lowering.
Cover supported rewrites, invalid patterns, SNORM ranges, and compiler
fallback behavior.
Authored with Codex.
Change-Id: Ia19b4387c169bd24f8db837a5bfee7c91d4e55ce
Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
YufengShi-dudu
force-pushed
the
fuse-canonical-flow-offset-grid-sampling
branch
from
August 12, 2026 12:17
6976e03 to
b34ec8b
Compare
robell
approved these changes
Aug 12, 2026
robell
left a comment
Collaborator
There was a problem hiding this comment.
Extensive internal review.
Collaborator
Author
|
unrelated failures |
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.
Recognize grid_sample calls that add a two-channel flow slice to an align-corners base grid:
Replace the complete expression with:
This avoids materializing the normalized sampling grid at runtime.
Require SNORM-compatible image and output quantization ranges. Vulkan's signed normalized 8-bit image format maps both -128 and -127 to -1.0, so only fuse tensors using the range [-127, 127]. The flow tensor keeps the full int8 range because the shader reads it directly as a tensor.
If glslc is unavailable or compilation fails, leave the graph unchanged for generic grid-sampler lowering.
Cover supported rewrites, invalid patterns, SNORM ranges, and compiler fallback behavior.
Authored with Codex.
Change-Id: Ia19b4387c169bd24f8db837a5bfee7c91d4e55ce
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani