Skip to content

Conversation

@pytorchbot
Copy link
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #16420 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/391/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/391/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/390/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/391/orig
Differential Revision: D89935219
@diff-train-skip-merge

ssjia added 2 commits January 5, 2026 10:53
…exels

Pull Request resolved: #16419

When the packed dimension size is not a multiple of 4, texture-backed
tensors have padding elements in the last texel. For division operations,
these padding regions contain 0/0 = NaN, which propagates through
subsequent reduction operations and corrupts results.

This fix adds conditional padding masking logic to binary_op shaders:
- Introduced MASK_PADDING codegen variable to binary_op.yaml
- Enabled MASK_PADDING=1 for binary_div and binary_floor_divide ops
- Added GLSL preprocessor macro definition in binary_op.glsl
- Implemented padding masking logic using modulo arithmetic to correctly
  identify last texels in batch concatenation scenarios
- Padding elements are explicitly zeroed out to prevent NaN propagation

The implementation follows GLSL best practices by using Python
preprocessing only for macro definition, keeping core shader logic
as pure GLSL with standard #ifdef directives.
ghstack-source-id: 331920706

Differential Revision: [D89935220](https://our.internmc.facebook.com/intern/diff/D89935220/)
Pull Request resolved: #16420

Batch normalization is typically used with 4D tensors (batch, channels, height, width) in convolutional neural networks. This change adds input validation to ensure batch norm is only lowered to the Vulkan backend when the input tensor is 4-dimensional. For other input shapes, the operator will fall back to other backends.

The implementation follows the same pattern as the convolution operator, using an `are_node_inputs_supported_fn` callback to validate input shapes during graph partitioning. This prevents potential issues with batch norm on unsupported tensor shapes and makes the operator requirements explicit.
ghstack-source-id: 331920708
@exported-using-ghexport

Differential Revision: [D89935219](https://our.internmc.facebook.com/intern/diff/D89935219/)
@pytorchbot pytorchbot requested a review from SS-JIA as a code owner January 5, 2026 21:12
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 5, 2026

🔗 Helpful Links

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

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:

❌ 2 New Failures, 24 Pending

As of commit aac499f with merge base c730feb (image):

NEW FAILURES - The following jobs have failed:

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

@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 Jan 5, 2026
Base automatically changed from gh/SS-JIA/390/orig to main January 5, 2026 22:08
@SS-JIA SS-JIA merged commit 4bf3869 into main Jan 5, 2026
161 of 165 checks passed
@SS-JIA SS-JIA deleted the gh/SS-JIA/391/orig branch January 5, 2026 22:09
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.

3 participants