From 2b619493e26ecc9835ac6c814cedd30cfa8731d7 Mon Sep 17 00:00:00 2001 From: zhupengyang <1165938320@qq.com> Date: Tue, 14 Jan 2020 17:45:21 +0800 Subject: [PATCH] all cases use large shape (#22241) enhanced ops: concat, nearest_interp, deformable_conv_v1, sequence_conv, transpose2, conv2d --- .../unittests/mkldnn/test_conv2d_mkldnn_op.py | 12 +++++++++-- .../mkldnn/test_transpose_mkldnn_op.py | 4 ++-- .../unittests/sequence/test_sequence_conv.py | 6 +++--- .../fluid/tests/unittests/test_concat_op.py | 12 +++++------ .../unittests/test_deformable_conv_v1_op.py | 20 +++++++++++++++++-- .../tests/unittests/test_nearest_interp_op.py | 2 +- 6 files changed, 40 insertions(+), 16 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_mkldnn_op.py index 82fb2ca0c40..e070f5fbbe0 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_conv2d_mkldnn_op.py @@ -156,6 +156,14 @@ class TestWithStride(TestConv2dMKLDNNOp): class TestWithGroup(TestConv2dMKLDNNOp): + def init_test_case(self): + self.pad = [0, 0] + self.stride = [1, 1] + self.input_size = [2, 6, 5, 5] # NCHW + assert np.mod(self.input_size[1], self.groups) == 0 + f_c = self.input_size[1] // self.groups + self.filter_size = [6, f_c, 3, 3] + def init_group(self): self.groups = 3 @@ -163,13 +171,13 @@ class TestWithGroup(TestConv2dMKLDNNOp): class TestWith1x1(TestConv2dMKLDNNOp): def init_test_case(self): TestConv2dMKLDNNOp.init_test_case(self) - self.filter_size = [6, 3, 1, 1] + self.filter_size = [40, 3, 1, 1] class TestWithInput1x1Filter1x1(TestConv2dMKLDNNOp): def init_test_case(self): TestConv2dMKLDNNOp.init_test_case(self) - self.input_size = [2, 3, 1, 1] # NCHW + self.input_size = [2, 60, 1, 1] # NCHW assert np.mod(self.input_size[1], self.groups) == 0 f_c = self.input_size[1] // self.groups self.filter_size = [6, f_c, 1, 1] diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_transpose_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_transpose_mkldnn_op.py index d0fe1f94c67..0d670898dd7 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_transpose_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_transpose_mkldnn_op.py @@ -60,13 +60,13 @@ class TestCase0MKLDNN(TestTransposeMKLDNN): class TestCase1a(TestTransposeMKLDNN): def initTestCase(self): - self.shape = (3, 4, 5) + self.shape = (3, 4, 10) self.axis = (0, 2, 1) class TestCase1b(TestTransposeMKLDNN): def initTestCase(self): - self.shape = (3, 4, 5) + self.shape = (3, 4, 10) self.axis = (2, 1, 0) diff --git a/python/paddle/fluid/tests/unittests/sequence/test_sequence_conv.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_conv.py index f578f3bdfb3..ed804d701a8 100644 --- a/python/paddle/fluid/tests/unittests/sequence/test_sequence_conv.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_conv.py @@ -194,7 +194,7 @@ class TestSeqProjectCase1(TestSeqProject): self.padding_trainable = True self.context_stride = 1 - self.input_size = [self.input_row, 23] + self.input_size = [self.input_row, 50] offset_lod = [[0, 4, 5, 8, self.input_row]] self.lod = [[]] # convert from offset-based lod to length-based lod @@ -211,7 +211,7 @@ class TestSeqProjectCase2Len0(TestSeqProject): self.padding_trainable = True self.context_stride = 1 - self.input_size = [self.input_row, 23] + self.input_size = [self.input_row, 50] offset_lod = [[0, 0, 4, 5, 5, 8, self.input_row, self.input_row]] self.lod = [[]] # convert from offset-based lod to length-based lod @@ -228,7 +228,7 @@ class TestSeqProjectCase3(TestSeqProject): self.padding_trainable = True self.context_stride = 1 - self.input_size = [self.input_row, 23] + self.input_size = [self.input_row, 25] idx = list(range(self.input_size[0])) del idx[0] offset_lod = [[0] + np.sort(random.sample(idx, 8)).tolist() + diff --git a/python/paddle/fluid/tests/unittests/test_concat_op.py b/python/paddle/fluid/tests/unittests/test_concat_op.py index 11574637a8d..f7ac868552f 100644 --- a/python/paddle/fluid/tests/unittests/test_concat_op.py +++ b/python/paddle/fluid/tests/unittests/test_concat_op.py @@ -51,9 +51,9 @@ class TestConcatOp(OpTest): self.check_grad(['x2'], 'Out') def init_test_data(self): - self.x0 = np.random.random((2, 1, 4, 5)).astype(self.dtype) - self.x1 = np.random.random((2, 2, 4, 5)).astype(self.dtype) - self.x2 = np.random.random((2, 3, 4, 5)).astype(self.dtype) + self.x0 = np.random.random((5, 1, 4, 5)).astype(self.dtype) + self.x1 = np.random.random((5, 2, 4, 5)).astype(self.dtype) + self.x2 = np.random.random((5, 3, 4, 5)).astype(self.dtype) self.axis = 1 @@ -94,9 +94,9 @@ class TestConcatOp4(TestConcatOp): class TestConcatOp5(TestConcatOp): def init_test_data(self): - self.x0 = np.random.random((2, 1, 4, 5)).astype(self.dtype) - self.x1 = np.random.random((2, 2, 4, 5)).astype(self.dtype) - self.x2 = np.random.random((2, 3, 4, 5)).astype(self.dtype) + self.x0 = np.random.random((5, 1, 4, 5)).astype(self.dtype) + self.x1 = np.random.random((5, 2, 4, 5)).astype(self.dtype) + self.x2 = np.random.random((5, 3, 4, 5)).astype(self.dtype) self.axis = -3 diff --git a/python/paddle/fluid/tests/unittests/test_deformable_conv_v1_op.py b/python/paddle/fluid/tests/unittests/test_deformable_conv_v1_op.py index 5646f72f729..2f950b53e0c 100644 --- a/python/paddle/fluid/tests/unittests/test_deformable_conv_v1_op.py +++ b/python/paddle/fluid/tests/unittests/test_deformable_conv_v1_op.py @@ -198,7 +198,7 @@ class TestWithDilation(TestModulatedDeformableConvOp): def init_test_case(self): self.pad = [2, 2] self.stride = [1, 1] - self.input_size = [2, 3, 4, 4] # NCHW + self.input_size = [5, 3, 4, 4] # NCHW assert np.mod(self.input_size[1], self.groups) == 0 f_c = self.input_size[1] // self.groups self.filter_size = [6, f_c, 3, 3] @@ -221,7 +221,7 @@ class TestWith1x1(TestModulatedDeformableConvOp): self.input_size = [2, 3, 5, 5] # NCHW assert np.mod(self.input_size[1], self.groups) == 0 f_c = self.input_size[1] // self.groups - self.filter_size = [6, f_c, 1, 1] + self.filter_size = [40, f_c, 1, 1] self.im2col_step = 1 self.deformable_groups = 1 offset_c = 2 * self.deformable_groups * self.filter_size[ @@ -232,6 +232,22 @@ class TestWith1x1(TestModulatedDeformableConvOp): class TestWithGroup(TestModulatedDeformableConvOp): + def init_test_case(self): + self.pad = [1, 1] + self.stride = [1, 1] + self.dilations = [1, 1] + self.input_size = [2, 8, 4, 4] # NCHW + assert np.mod(self.input_size[1], self.groups) == 0 + f_c = self.input_size[1] // self.groups + self.filter_size = [4, f_c, 3, 3] + self.im2col_step = 1 + self.deformable_groups = 1 + offset_c = 2 * self.deformable_groups * self.filter_size[ + 2] * self.filter_size[3] + self.offset_size = [ + self.input_size[0], offset_c, self.input_size[2], self.input_size[3] + ] + def init_group(self): self.groups = 2 diff --git a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py index c6e05edfaae..eda530f30df 100755 --- a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py @@ -377,7 +377,7 @@ class TestNearestInterpOp_attr_tensor(OpTest): def init_test_case(self): self.interp_method = 'nearest' - self.input_shape = [2, 3, 4, 4] + self.input_shape = [2, 5, 4, 4] self.out_h = 3 self.out_w = 3 self.scale = 0. -- GitLab