Skip to content

[ExecuTorch][WebGPU] Port flip#21166

Open
JCNTH wants to merge 1 commit into
gh/JCNTH/126/basefrom
gh/JCNTH/126/head
Open

[ExecuTorch][WebGPU] Port flip#21166
JCNTH wants to merge 1 commit into
gh/JCNTH/126/basefrom
gh/JCNTH/126/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Ports aten.flip.default as a per-element index-transform, mirroring the landed permute op (same dual-TensorMeta + 5-binding bind group). flip is pure data movement, so it reverses the coord along each flagged dim and copies — no fp compute.

Key changes:

  • runtime/ops/flip/{Flip.cpp, flip.wgsl} (+ generated flip_wgsl.h) — per out flat idx: unravel via out_meta.strides, in_coord = select(coord, sizes[d]-1-coord, flip[d]==1), ravel via in_meta.strides, output[out] = input[in]; Params { flip: vec4<u32> } bitmap built from the normalized dims arg; registered aten.flip.default.
  • CMakeLists.txtruntime/ops/flip/Flip.cpp in WEBGPU_SRCS.

Matches Vulkan impl/Flip.cpp (create_whcn_bitmap normalizes/flags dims; reversal size-1-coord). No int dtype-guard (unlike clamp/minimum which do fp arithmetic): flip is bit-preserving movement, so any 4-byte dtype is correct; the nbytes != numel*4 guard rejects int64/fp16. 2D-folded dispatch lifts the 65535 cap. out is the last arg (this backend's convention).

Differential Revision: D112257643

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21166

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (1 Unrelated Failure)

As of commit 2c8f8af with merge base 266e0dc (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 22, 2026
This was referenced Jul 22, 2026
This was referenced Jul 22, 2026
@JCNTH
JCNTH requested a review from psiddh July 23, 2026 02:09

@psiddh psiddh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving full WebGPU stack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants