未验证 提交 f76a7c5a 编写于 作者: L LoneRanger 提交者: GitHub

Fix Python IndexError of case18: paddle.nn.functional.conv3d_transpose (#50001)

上级 1451fa51
......@@ -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()
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册