Hello,
I’ve got an error in a convolution using the options padding='same' and padding_mode='reflect'.
Given a kernel of size 3, stride=1, and dilation=1, I was expecting those two convolutions to be equivalent:
conv1 = torch.nn.Conv2d(2, 2, 3, padding = 'same', padding_mode = 'reflect')

conv2 = torch.nn.Conv2d(2, 2, 3, padding = 1, padding_mode = 'reflect')

but the former one raise an error, while the latter work as intended:
>>> a = torch.randn(1,2,4,4)
>>> conv = torch.nn.Conv2d(2, 2, 3, padding = 'same', padding_mode = 'reflect')
>>> conv(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 399, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 392, in _conv_forward
    return F.conv2d(F.pad(input, self._reversed_padding_repeated_twice, mode=self.padding_mode),
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/functional.py", line 4012, in _pad
    assert len(pad) == 4, "4D tensors expect 4 values for padding"

Concerning the mode same the documentation for Conv2D only states:

padding='same' pads the input so the output has the shape as the input. However, this mode doesn’t support any stride values other than 1.

Could you explain me why this error is triggered? Am I missing something in the documentation?
Best regards,
Thomas