Skip to content
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

Fixed nn.functional.pad constant mode #249

Merged
merged 3 commits into from
Nov 10, 2021

Conversation

vfdev-5
Copy link
Contributor

@vfdev-5 vfdev-5 commented Nov 8, 2021

Description:

  • Fixed nn.functional.pad constant mode
  • Updated tests

The issue was with the fact that UNARY_POINTWISE does not properly handle bdim > 0. The fix is to use a macro which explicitly calls moveBatchDimToFront.

Related to #240

Description:
- Fixed nn.functional.pad constant mode
- Updated tests
@vfdev-5
Copy link
Contributor Author

vfdev-5 commented Nov 10, 2021

@zou3519 please review this PR as well. Thanks

@Chillee
Copy link
Contributor

Chillee commented Nov 10, 2021

Sorry, I don't understand why UNARY_POINTWISE doesn't support bdim > 0 🤔

Oh, is it specifically that for constant_pad_nd it screws up the padding argument?

But LGTM and passes the tests :)

@Chillee Chillee self-requested a review November 10, 2021 17:29
@zou3519
Copy link
Contributor

zou3519 commented Nov 10, 2021

Sorry, I don't understand why UNARY_POINTWISE doesn't support bdim > 0 🤔

Oh, is it specifically that for constant_pad_nd it screws up the padding argument?

yes. The padding argument is a list of pads for the last dimensions. For example, constant_pad_nd(x: Tensor[2, 3], pad=[2, 3, 4, 5]) would pad dimension 0 using (2, 3) and dimension 1 using (4, 5).

Now, if your batch dimension is in the middle (e.g. constant_pad_nd(x: Tensor[2, B, 3], pad=[2, 3, 4, 5])) then we need to first move it to the front so it doesn't get padded by mistake

@zou3519 zou3519 merged commit 3f8ce15 into pytorch:main Nov 10, 2021
@vfdev-5 vfdev-5 deleted the fixed-pad-constant branch November 11, 2021 14:52
zou3519 pushed a commit to zou3519/pytorch that referenced this pull request Jul 20, 2022
)

* Fixed nn.functional.pad constant mode
Description:
- Fixed nn.functional.pad constant mode
- Updated tests

* Fixed issues with unexpected failures for fft tests

* Update BatchRulesModules.cpp
bigfootjon pushed a commit to pytorch/pytorch that referenced this pull request Jul 21, 2022
)

* Fixed nn.functional.pad constant mode
Description:
- Fixed nn.functional.pad constant mode
- Updated tests

* Fixed issues with unexpected failures for fft tests

* Update BatchRulesModules.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants