Skip to content

[Bug Fix] Fix padding when running in NHWC #9816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

pytorchbot
Copy link
Collaborator

Summary

There is a bug when there is a constant_pad between two convolutions. In order to minimize permutes associated with memory format changes, we sometimes compute ops in NHWC. This is the case for ConstantPad when it is between two convs:

    a = conv(a)
    a = constant_pad(a, paddings=[1, 2, 3, 4])
    a = conv(a)

in this case we need to make sure the paddings given to constant_pad are also permuted to nhwc.

Test plan

python install_executorch.py --editable

python -m unittest backends.xnnpack.test.ops.test_static_constant_pad.TestStaticConstantPad.test_fp32_static_constant_pad_nhwc

### Summary
There is a bug when there is a constant_pad between two convolutions. In
order to minimize permutes associated with memory format changes, we
sometimes compute ops in NHWC. This is the case for ConstantPad when it
is between two convs:

```
    a = conv(a)
    a = constant_pad(a, paddings=[1, 2, 3, 4])
    a = conv(a)
```

in this case we need to make sure the paddings given to constant_pad are
also permuted to nhwc.

### Test plan
python install_executorch.py --editable

python -m unittest
backends.xnnpack.test.ops.test_static_constant_pad.TestStaticConstantPad.test_fp32_static_constant_pad_nhwc

(cherry picked from commit 7d35c68)
Copy link

pytorch-bot bot commented Apr 1, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 2b3b637 with merge base 771588a (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 Apr 1, 2025
@metascroy
Copy link
Contributor

@mcr229 @digantdesai do you know why there is a failing arm unit test here?

@mcr229
Copy link
Contributor

mcr229 commented Apr 2, 2025

@mcr229 @digantdesai do you know why there is a failing arm unit test here?

I feel like it might be flaky test. Since it seems like tolerance just isn't met. Let me try rerunning

@metascroy metascroy merged commit 8f16ab6 into release/0.6 Apr 2, 2025
163 checks passed
@metascroy metascroy deleted the cherry-pick-9729-by-pytorch_bot_bot_ branch April 2, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk 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.

4 participants