From cf7b325389f29389b2f905d8d958122f176117fa Mon Sep 17 00:00:00 2001 From: FDInSky <48318485+FDInSky@users.noreply.github.com> Date: Mon, 30 Dec 2019 11:50:45 +0800 Subject: [PATCH] fix conv2d_transpose op unittest (#21927) --- .../mkldnn/test_conv2d_transpose_mkldnn_op.py | 2 ++ .../fluid/tests/unittests/test_conv2d_transpose_op.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py index a9b26b86c23..b98610760e6 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_transpose_mkldnn_op.py @@ -60,8 +60,10 @@ class TestConv2dTransposeMKLDNNOp(TestConv2dTransposeOp): f_c = self.input_size[1] self.filter_size = [f_c, 6, 3, 3] self.groups = 1 + self.dtype = np.float32 def setUp(self): + TestConv2dTransposeOp.setUp(self) output = self.outputs['Output'] diff --git a/python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py b/python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py index 02b8aacaf22..607e97ef430 100644 --- a/python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py +++ b/python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py @@ -78,7 +78,7 @@ def conv2dtranspose_forward_naive(input_, filter_, attrs): out_h = output_size[0] + pad_h_0 + pad_h_1 out_w = output_size[1] + pad_w_0 + pad_w_1 - out = np.zeros((in_n, out_c, out_h, out_w)) + out = np.zeros((in_n, out_c, out_h, out_w), dtype=input_.dtype) for n in range(in_n): for i in range(in_h): @@ -108,7 +108,7 @@ def conv2dtranspose_forward_naive(input_, filter_, attrs): class TestConv2dTransposeOp(OpTest): def setUp(self): # init as conv transpose - self.dtype = np.float32 + self.dtype = np.float64 self.is_test = False self.use_cudnn = False self.use_mkldnn = False @@ -119,8 +119,8 @@ class TestConv2dTransposeOp(OpTest): self.init_op_type() self.init_test_case() - input_ = np.random.random(self.input_size).astype("float32") - filter_ = np.random.random(self.filter_size).astype("float32") + input_ = np.random.random(self.input_size).astype(self.dtype) + filter_ = np.random.random(self.filter_size).astype(self.dtype) self.inputs = {'Input': input_, 'Filter': filter_} self.attrs = { @@ -138,7 +138,7 @@ class TestConv2dTransposeOp(OpTest): self.attrs['output_size'] = self.output_size output = conv2dtranspose_forward_naive(input_, filter_, - self.attrs).astype('float32') + self.attrs).astype(self.dtype) self.outputs = {'Output': output} -- GitLab