Skip to content

Circular padding in Conv2d applies padding across the wrong dimension (regression from 1.4) #37844

@aman-tiwari

Description

@aman-tiwari

🐛 Bug

If you specify different padding for the H and W dimensions, padding_mode='circular' applies it across the wrong one - e.g, with padding (0, 1), it will pad across the H dimension, even though it should apply it on the W one.

To Reproduce

In [1]: circular = nn.Conv2d(6, 1, (3, 3), padding=(0, 1), padding_mode='circular')

In [2]: circular(torch.zeros(1, 6, 20, 10)).shape
Out[2]: torch.Size([1, 1, 20, 8])

In [3]: normal = nn.Conv2d(6, 1, (3, 3), padding=(0, 1))

In [4]: normal(torch.zeros(1, 6, 20, 10)).shape
Out[4]: torch.Size([1, 1, 18, 10])

Note how the non-circular padding mode one is correctly padding across the W dim, not H.

Expected behavior

It pads the right dimension.

Environment

Collecting environment information...
PyTorch version: 1.5.0
Is debug build: No
CUDA used to build PyTorch: None

OS: Microsoft Windows 10 Enterprise
GCC version: Could not collect
CMake version: version 3.14.5

Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy==1.16.5
[pip] numpy-quaternion==2020.4.24.9.29.7
[pip] torch==1.5.0
[pip] torchsummary==1.5.1
[conda] blas                      1.0                         mkl    conda-forge
[conda] cpuonly                   1.0                           0    pytorch
[conda] libblas                   3.8.0                    14_mkl    conda-forge
[conda] libcblas                  3.8.0                    14_mkl    conda-forge
[conda] liblapack                 3.8.0                    14_mkl    conda-forge
[conda] mkl                       2019.4                      245
[conda] mkl-service               2.3.0            py36hfa6e2cd_0    conda-forge
[conda] numpy                     1.16.5           py36hc71023c_0    conda-forge
[conda] pytorch                   1.5.0               py3.6_cpu_0  [cpuonly]  pytorch
[conda] torchsummary              1.5.1                    pypi_0    pypi

cc @ezyang @gchanan @zou3519

Metadata

Metadata

Assignees

Labels

high prioritymodule: convolutionProblems related to convolutions (THNN, THCUNN, CuDNN)module: regressionIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions