Commit cd32734
committed
[ExecuTorch][WebGPU] Dynamic resize hook for slice_copy (dynamic start/end)
Pull Request resolved: #20581
**Make `slice_copy` support a dynamic gather range so the RoPE-freqs slice `[input_pos : input_pos + S]` works under one dynamic graph.**
**Problem:** the static slice handler read `start` via a scalar reader that throws on a SymInt and ignored `end` (output length baked AOT). The RoPE-freqs slice uses a SymInt `input_pos` for start and a live S for the range, so the static op could neither build nor resize for it.
**Solution:** read start/end as possibly-dynamic SymInts and add a resize hook that recomputes the gather offset and live output length each step.
- Before: `start` is a static scalar (SymInt throws); `end` ignored; output length fixed at the serialized max.
- After: `start`/`end` read via a SymInt-aware reader; a hook recomputes `out[dim] = (end - start + step - 1) / step`, rewrites `out_meta`/`in_meta`/`params` UBOs + the dispatch count, and sets the output `cur_dims`.
**Implementation:**
- Hook registered on the `start`/`end` value-ids when they are SymInts and on the input tensor always (inert until resized, so a static slice is byte-identical).
- Output/input `TensorMeta` rebuilt from live dims; `dim`/`step` stay static.
- Keep the uniforms alive via `own_uniform_buffer` so the hook can rewrite them.
- Mirrors Vulkan `resize_slice_copy_node`.
**Constraints:** fp32-only; `dim`/`step` static; numerics + layout unchanged; inert on a static graph.
NOTE (stacking): this diff sits on top of the in-review `slice_copy` op (D108793168); rebase onto it once that op lands on master.
Co-authored-with: Claude Code.
ghstack-source-id: 399812835
@exported-using-ghexport
Differential Revision: [D109906092](https://our.internmc.facebook.com/intern/diff/D109906092/)1 parent f2a3486 commit cd32734
1 file changed
Lines changed: 92 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
49 | 77 | | |
50 | | - | |
| 78 | + | |
| 79 | + | |
51 | 80 | | |
| 81 | + | |
| 82 | + | |
52 | 83 | | |
53 | 84 | | |
54 | 85 | | |
| |||
63 | 94 | | |
64 | 95 | | |
65 | 96 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 97 | | |
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
77 | 105 | | |
78 | 106 | | |
79 | 107 | | |
| |||
175 | 203 | | |
176 | 204 | | |
177 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
178 | 258 | | |
179 | 259 | | |
180 | 260 | | |
181 | 261 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
186 | 266 | | |
187 | 267 | | |
188 | 268 | | |
| |||
0 commit comments