UserWarning when using 'same' padding

Hello, I tried to use a 4x4 convolution with ‘same’ padding like this:

conv = nn.Conv2d(
                 in_channels = in_channels,
                 out_channels = out_channels,
                 kernel_size = 4,
                 stride =  1,
                 padding =  'same',
                 bias = False
                              )

I don’t get any errors, and it seems that it works fine since the input and output tensors do have the size…

But I get this UserWarning which I am curious to know what exactly does it mean and wither I should be aware of any problems

UserWarning: Using padding=‘same’ with even kernel lengths and odd dilation may require a zero-padded copy of the input be created (Triggered internally at /pytorch/aten/src/ATen/native/Convolution.cpp:660.)

Thank you.

1 Like

If I understand the warning correctly, it would point to an additional copy of the input tensor (which could downgrade the performance) due to the used setup. If you don’t see any slowdowns in your code (as it might not be triggered or might not even be the bottleneck), I would guess you could ignore it.

1 Like