Skip to content

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

Merged
metascroy merged 1 commit into
release/0.6from
cherry-pick-9729-by-pytorch_bot_bot_
Apr 2, 2025
Merged

[Bug Fix] Fix padding when running in NHWC#9816
metascroy merged 1 commit into
release/0.6from
cherry-pick-9729-by-pytorch_bot_bot_

Conversation

@pytorchbot

Copy link
Copy Markdown
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)
@pytorch-bot

pytorch-bot Bot commented Apr 1, 2025

Copy link
Copy Markdown

🔗 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
Copy Markdown
Contributor

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

@mcr229

mcr229 commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

@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

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