diff --git a/python/paddle/fluid/tests/unittests/test_conv2d_transpose_layer.py b/python/paddle/fluid/tests/unittests/test_conv2d_transpose_layer.py index f51baf50ec898a7364be24806138f92ea2f32c05..83d2734318961e531148f4ef604294ba3c00f1ae 100644 --- a/python/paddle/fluid/tests/unittests/test_conv2d_transpose_layer.py +++ b/python/paddle/fluid/tests/unittests/test_conv2d_transpose_layer.py @@ -219,6 +219,7 @@ def add_cases(suite): suite.addTest( Conv2DTransposeTestCase( methodName='runTest', padding="valid")) + suite.addTest(Conv2DTransposeTestCase(methodName='runTest', padding="same")) suite.addTest( Conv2DTransposeTestCase( methodName='runTest', filter_size=1, padding=(2, 3))) diff --git a/python/paddle/nn/layer/conv.py b/python/paddle/nn/layer/conv.py index 279f0648db18498de3d182fc0e8905c841f5cd80..da76f0f11e52cb8bff6fe418cf4cd6e9b964c220 100644 --- a/python/paddle/nn/layer/conv.py +++ b/python/paddle/nn/layer/conv.py @@ -100,14 +100,12 @@ class _ConvNd(layers.Layer): self._padding_mode = padding_mode self.output_padding = output_padding if dims != 1: - self._padding, self._padding_algorithm = _update_padding_nd( + self._updated_padding, self._padding_algorithm = _update_padding_nd( padding, channel_last, dims) if transposed: filter_shape = [self._in_channels, out_channels // groups ] + self._kernel_size - self._padding, self._padding_algorithm = _update_padding_nd( - padding, channel_last, dims) else: if in_channels % groups != 0: raise ValueError("in_channels must be divisible by groups.") @@ -118,7 +116,8 @@ class _ConvNd(layers.Layer): self._reversed_padding_repeated_twice = _reverse_repeat_list( _paired_padding, 2) - self._padding, _ = _update_padding_nd(0, channel_last, dims) + self._updated_padding, self._padding_algorithm = _update_padding_nd( + 0, channel_last, dims) filter_shape = [out_channels, in_channels // groups ] + self._kernel_size @@ -634,7 +633,7 @@ class Conv2D(_ConvNd): self.weight, bias=self.bias, stride=self._stride, - padding=self._padding, + padding=self._updated_padding, padding_algorithm=self._padding_algorithm, dilation=self._dilation, groups=self._groups, @@ -951,7 +950,7 @@ class Conv3D(_ConvNd): self.weight, bias=self.bias, stride=self._stride, - padding=self._padding, + padding=self._updated_padding, padding_algorithm=self._padding_algorithm, dilation=self._dilation, groups=self._groups,