Skip to content

Conversation

@alexandresablayrolles
Copy link
Contributor

Fixes #442.
TL;DR: F.pad has an unintuitive syntax (we need to indicated padding from last dimensions to first dimensions).
This PR fixes that in unfold2d and adds tests with non-symmetric pad/dilation/kernel_size/stride.

@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 Jun 27, 2022
@facebook-github-bot
Copy link
Contributor

@alexandresablayrolles has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

W + 2 * padding[1] - (kernel_size[1] + (kernel_size[1] - 1) * (dilation[1] - 1))
) // stride[1] + 1
input = F.pad(input, (padding[0], padding[0], padding[1], padding[1]))
# F.pad's first argument is the padding of the *last* dimension
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃

@karthikprasad
Copy link
Contributor

Please fix lint before merging.

@ffuuugor
Copy link
Contributor

Looks great, thanks for the fix!

Can we also add more inputs to test_conv2d (original grad sample test) so it would have caught the issue - I think it's a gap that we don't check the layer with 2d inputs for kernel/padding/stride/dilation

@facebook-github-bot
Copy link
Contributor

@alexandresablayrolles has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@alexandresablayrolles has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@karthikprasad karthikprasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM. Please isort before merging.

@facebook-github-bot
Copy link
Contributor

@alexandresablayrolles has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@alexandresablayrolles has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@karthikprasad karthikprasad deleted the fix_unfold2d branch August 10, 2022 19:02
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.

setStorage Runtime error from opacus.utils.tensor_utils.unfold2d

5 participants