Skip to content

Commit

Permalink
Fix Python IndexError of case18: paddle.nn.functional.conv3d_transpose (
Browse files Browse the repository at this point in the history
  • Loading branch information
longranger2 authored Feb 2, 2023
1 parent 1451fa5 commit f76a7c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,18 @@ def init_op_type(self):
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()
6 changes: 6 additions & 0 deletions python/paddle/nn/functional/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f76a7c5

Please sign in to comment.