diff --git a/python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py b/python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py index bf223b8d59fa58a68bea38318285b9d67b946747..aac41167399d5afb76d460b109b6e43bffe714ac 100644 --- a/python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py +++ b/python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py @@ -555,5 +555,18 @@ class TestCUDNNWithGroups_NHWC(TestWithGroups): self.op_type = "conv3d_transpose" +class TestConv3dTranspose(unittest.TestCase): + def error_weight_input(self): + array = np.array([1], dtype=np.float32) + x = paddle.to_tensor( + np.reshape(array, [1, 1, 1, 1, 1]), dtype='float32' + ) + weight = paddle.to_tensor(np.reshape(array, [1]), dtype='float32') + paddle.nn.functional.conv3d_transpose(x, weight, bias=0) + + def test_type_error(self): + self.assertRaises(ValueError, self.error_weight_input) + + if __name__ == '__main__': unittest.main() diff --git a/python/paddle/nn/functional/conv.py b/python/paddle/nn/functional/conv.py index 82d25747eadb02d746c4ddbbaf50b1bbf12f9215..350eeaa3832436f0e0986c4ab64d46a2bb5ad20d 100644 --- a/python/paddle/nn/functional/conv.py +++ b/python/paddle/nn/functional/conv.py @@ -1678,6 +1678,12 @@ def conv3d_transpose( x.shape ) ) + if len(weight.shape) != 5: + raise ValueError( + "Input weight should be 5D tensor, but received weight with the shape of {}".format( + weight.shape + ) + ) num_channels = x.shape[channel_dim] num_filters = weight.shape[1] if num_channels < 0: