-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Fix constant_pad_nd_mps bug when pad is empty #161149
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161149
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f74b50d with merge base 39862ac ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
|
Thank you for the fix. It would be nice to add a unit test, but could be done in separate PR |
|
To add the ciflow label This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot merge -f "Seems fine to me, will add fix in separate PR" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Fixes #161066 This PR adds a simple testcase for constant_pad_nd on MPS as mentioned in #161149 (comment) Pull Request resolved: #161259 Approved by: https://github.com/malfet Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
Fixes pytorch#161066 There is a size check here, which causes the error. https://github.com/pytorch/pytorch/blob/8ce81bcee1da294a34af0a90dc16483055e8c5a4/aten/src/ATen/native/mps/operations/Pad.mm#L39-L40 If the argument `pad` is empty, it will return the cloned tensor on CPU. https://github.com/pytorch/pytorch/blob/8ce81bcee1da294a34af0a90dc16483055e8c5a4/aten/src/ATen/native/PadNd.cpp#L43-L64 Therefore, this PR fixes the empty padding argument error by checking the size first and returning a cloned tensor immediately if the padding size is 0. Pull Request resolved: pytorch#161149 Approved by: https://github.com/malfet
Fixes pytorch#161066 This PR adds a simple testcase for constant_pad_nd on MPS as mentioned in pytorch#161149 (comment) Pull Request resolved: pytorch#161259 Approved by: https://github.com/malfet Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
Fixes #161066
There is a size check here, which causes the error.
pytorch/aten/src/ATen/native/mps/operations/Pad.mm
Lines 39 to 40 in 8ce81bc
If the argument
padis empty, it will return the cloned tensor on CPU.pytorch/aten/src/ATen/native/PadNd.cpp
Lines 43 to 64 in 8ce81bc
Therefore, this PR fixes the empty padding argument error by checking the size first and returning a cloned tensor immediately if the padding size is 0.