Add Support for transposed convolution with Padding Mode 'same' and 'valid'#154279
Add Support for transposed convolution with Padding Mode 'same' and 'valid'#154279Alvaro-Kothe wants to merge 9 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/154279
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Attention! native_functions.yaml was changedIf you are adding a new function or defaulted argument to native_functions.yaml, you cannot use it from pre-existing Python frontend code until our FC window passes (two weeks). Split your PR into two PRs, one which adds the new C++ functionality, and one that makes use of it from Python, and land them two weeks apart. See https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy#forwards-compatibility-fc for more info. Caused by: |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
42ce8c0 to
0bfa1b8
Compare
|
Could someone please trigger the CI? |
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
c71a0b5 to
e1bdc0c
Compare
e1bdc0c to
d6c4409
Compare
|
Hi @Skylion007, could you please take another look at this PR when you have a moment? Also, if possible, remove the Stale label. |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
d6c4409 to
7e5a0e5
Compare
|
Can somebody remove the Stale label and trigger the CI? Also, if there are any changes needed in this PR, please let me know. Soft ping to: @Skylion007, @albanD, @shoumikhin and @colesbury. Thank you in advance! |
|
Thanks for removing the stale label and triggering the CI. The build on the failing job was killed with
I think this is unrelated to the changes in this PR. |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 2 jobs have failed, first few of them are: trunk / linux-jammy-cuda12.8-py3.10-gcc11 / test (default, 5, 5, linux.g6.4xlarge.experimental.nvidia.gpu), trunk / linux-jammy-cuda12.8-py3.10-gcc11 / test (default, 3, 5, linux.g6.4xlarge.experimental.nvidia.gpu) Details for Dev Infra teamRaised by workflow job |
|
I was investigating the errors, and I can at least understand why. TracebackIt originates from the changes in Where for the failing test, as the OpInfo('nn.functional.conv_transpose1d',
# `ref` for this function is backward of
# corresponding `conv*d`
ref=partial(conv_transpose_ref, fn=torch.nn.functional.conv_transpose1d),The function defined in the ref calls for these gradient functions grad_fn_map = {torch.nn.functional.conv_transpose1d: torch.nn.grad.conv1d_input,
torch.nn.functional.conv_transpose2d: torch.nn.grad.conv2d_input,
torch.nn.functional.conv_transpose3d: torch.nn.grad.conv3d_input}Which calls for return torch.ops.aten.convolution_backward(
grad_output,
input,
weight,
None,
_single(stride),
_single(padding),
_single(dilation),
False,
[0],
groups,
(True, False, False),
)[0]Why it doesn't happen for normal convolution?It doesn't happen for normal convolution because they don't have this OpInfo('nn.functional.conv1d',
aliases=('conv1d',),
aten_name='conv1d',
dtypes=floating_and_complex_types_and(torch.int64, torch.float16, torch.bfloat16),
dtypesIfCUDA=floating_and_complex_types_and(torch.float16, torch.chalf,The Next StepsI see 3 main options:
|
|
Ho that is very interesting! Let's double check with @jbschlosser if 1) is feasible. |
|
Skipping / xfailing a particular test only for a given set of samples (AKA option 1 above) is possible, albeit somewhat involved. I think an option 4 could be to update the transposed convolution ref to handle string padding, no? |
I will look into it. I still haven't looked what What I am thinking in doing is the following in the
Is this a valid solution, or do I need to do something else? |
|
Hi @jbschlosser, Can you check the latest commit (c113a2d) and verify if it's what you had in mind? |
7438017 to
c113a2d
Compare
c113a2d to
c89127b
Compare
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
c89127b to
42e74b0
Compare
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
Adds support for `padding=torch::k{Same,Valid}` for transposed
convolutions in C++ API.
Test fails, similar to `conv3d`, on dynamo with error ``` TypeError: add(): argument 'input' (position 1) must be Tensor, not NoneType ```
|
Successfully rebased |
42e74b0 to
1abc48c
Compare
This pull request adds support for
'same'and'valid'padding modes for transposed convolutions.Implementation Details for
'same'padding:Notes:
The padding calculation is based on the JAX implementation.
For asymmetric convolutions, I slice one extra value on the left side.
'valid'padding is equivalent topadding=0.'same'padding is not supported when:stride != 1), as it is also unsupported in traditional convolutions, and I could not find any bibliographic references clarifying how it could be implemented in this context.output_padding != 0, since this seems to conflict with the intent of'same'padding.Close #80301; Close #3867
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168