Repository navigation
Commit bf2103d
Arm backend: Fuse canonical flow-offset grid sampling (pytorch#21775)
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
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils
@Sebastian-Larsson @robell @rascani
Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
Co-authored-by: Per Åstrand <per.astrand@arm.com>1 parent 8de0262 commit bf2103d
7 files changed
Lines changed: 1295 additions & 4 deletions
File tree
- backends/arm
- test/passes
- vgf
- _passes
- shaders
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
| |||
0 commit comments