Skip to content

[ExecuTorch][WebGPU] Add logical_and op (aten.logical_and.default)#21221

Open
JCNTH wants to merge 2 commits into
gh/JCNTH/181/basefrom
gh/JCNTH/181/head
Open

[ExecuTorch][WebGPU] Add logical_and op (aten.logical_and.default)#21221
JCNTH wants to merge 2 commits into
gh/JCNTH/181/basefrom
gh/JCNTH/181/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Adds the elementwise bool aten.logical_and.default to the WebGPU delegate. Vulkan maps this op to its bitwise_and handler (BinaryOp.cpp:161), valid for canonical 0/1 bool bytes; this port mirrors that. Both operands and the output are 1-byte bool tensors packed 4/word into array<u32>, so a word-wise AND is exactly a per-byte AND.

Key changes:

  • runtime/ops/logical_and/logical_and.wgsl — one thread per packed word, t_out[w] = t_a[w] & t_b[w] (2D-folded dispatch).
  • runtime/ops/logical_and/LogicalAnd.cpp — handler binds out (rw) + a/b (ro) + params (uniform); fail-loud guards on bool dtype, null buffer, and same-shape; resize hook re-applies num_words + dispatch.
  • CMakeLists.txt — register the op source.

Same-shape only (numel % 4 == 0 for the packed bool bindings), matching the backend's other bool ops.

Co-authored-with: Claude Code.
@exported-using-ghexport

Differential Revision: D112257653

Differential Revision: D112257653

[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/21221

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

❌ 3 New Failures, 1 Unrelated Failure

As of commit df77bb2 with merge base 4a26c64 (image):

NEW FAILURES - The following jobs have failed:

  • pull / unittest / macos / macos-job (gh)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/Users/ec2-user/runner/_work/executorch/executorch/test-infra/.github/actions/check-disk-space'. Did you forget to run actions/checkout before running your local action?
  • pull / unittest-buck / macos / macos-job (gh)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/Users/ec2-user/runner/_work/executorch/executorch/test-infra/.github/actions/check-disk-space'. Did you forget to run actions/checkout before running your local action?
  • pull / unittest-editable / macos / macos-job (gh)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/Users/ec2-user/runner/_work/executorch/executorch/test-infra/.github/actions/check-disk-space'. Did you forget to run actions/checkout before running your local action?

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

This was referenced Jul 22, 2026
This was referenced Jul 22, 2026
@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
@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.

@JCNTH
JCNTH requested a review from psiddh July 23, 2026 02:00

@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

[ghstack-poisoned]
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants