From 09da24f531995ff7e763dbf073f4057c856893f1 Mon Sep 17 00:00:00 2001 From: zhupengyang <1165938320@qq.com> Date: Thu, 16 Jan 2020 07:23:49 +0000 Subject: [PATCH 1/2] all cases use large shape and skip special cases enhanced ops: elementwise_add, elementwise_sub test=develop --- .../paddle/fluid/tests/unittests/op_test.py | 1 - .../unittests/test_elementwise_add_op.py | 134 ++++++++++-------- .../unittests/test_elementwise_sub_op.py | 46 +++--- .../white_list/check_shape_white_list.py | 10 +- 4 files changed, 98 insertions(+), 93 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index 4e0fe464cd741..406fdb672d498 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -232,7 +232,6 @@ def is_empty_grad_op(op_type): cls.op_type) if not get_numeric_gradient.is_large_shape \ - and cls.op_type not in check_shape_white_list.NOT_CHECK_OP_LIST \ and cls.op_type not in check_shape_white_list.NEED_TO_FIX_OP_LIST: raise AssertionError( "Input's shape should be large than or equal to 100 for " + diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py index 7cda45609c648..73857b9e6d7a3 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py @@ -16,7 +16,7 @@ import unittest import numpy as np import paddle.fluid.core as core -from op_test import OpTest +from op_test import OpTest, skip_check_grad_ci import paddle.fluid as fluid from paddle.fluid import compiler, Program, program_guard @@ -99,6 +99,8 @@ def test_check_output(self): place, atol=1e-3, check_dygraph=(self.use_mkldnn == False)) +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1) to test broadcast.") class TestElementwiseAddOp_scalar(TestElementwiseAddOp): def init_input_output(self): self.x = np.random.rand(2, 3, 4).astype(self.dtype) @@ -106,6 +108,8 @@ def init_input_output(self): self.out = self.x + self.y +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1) to test broadcast.") class TestFP16ElementwiseAddOp_scalar(TestFP16ElementwiseAddOp): def init_input_output(self): self.x = np.random.rand(2, 3, 4).astype(self.dtype) @@ -113,6 +117,8 @@ def init_input_output(self): self.out = self.x + self.y +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1,1) to test broadcast.") class TestElementwiseAddOp_scalar2(TestElementwiseAddOp): def init_input_output(self): self.x = np.random.rand(2, 3, 4).astype(self.dtype) @@ -120,6 +126,8 @@ def init_input_output(self): self.out = self.x + self.y +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1,1) to test broadcast.") class TestFP16ElementwiseAddOp_scalar2(TestFP16ElementwiseAddOp): def init_input_output(self): self.x = np.random.rand(2, 3, 4).astype(self.dtype) @@ -129,23 +137,23 @@ def init_input_output(self): class TestElementwiseAddOp_Vector(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.random((32, )).astype(self.dtype) - self.y = np.random.random((32, )).astype(self.dtype) + self.x = np.random.random((100, )).astype(self.dtype) + self.y = np.random.random((100, )).astype(self.dtype) self.out = np.add(self.x, self.y) class TestFP16ElementwiseAddOp_Vector(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.random((32, )).astype(self.dtype) - self.y = np.random.random((32, )).astype(self.dtype) + self.x = np.random.random((100, )).astype(self.dtype) + self.y = np.random.random((100, )).astype(self.dtype) self.out = np.add(self.x, self.y) class TestElementwiseAddOp_broadcast_0(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(2).astype(self.dtype) - self.out = self.x + self.y.reshape(2, 1, 1) + self.x = np.random.rand(100, 2, 3).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(100, 1, 1) def init_axis(self): self.axis = 0 @@ -153,9 +161,9 @@ def init_axis(self): class TestFP16ElementwiseAddOp_broadcast_0(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(2).astype(self.dtype) - self.out = self.x + self.y.reshape(2, 1, 1) + self.x = np.random.rand(100, 2, 3).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(100, 1, 1) def init_axis(self): self.axis = 0 @@ -163,9 +171,9 @@ def init_axis(self): class TestElementwiseAddOp_broadcast_1(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(3).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 1) + self.x = np.random.rand(2, 100, 3).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 100, 1) def init_axis(self): self.axis = 1 @@ -173,9 +181,9 @@ def init_axis(self): class TestFP16ElementwiseAddOp_broadcast_1(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(3).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 1) + self.x = np.random.rand(2, 100, 3).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 100, 1) def init_axis(self): self.axis = 1 @@ -183,23 +191,23 @@ def init_axis(self): class TestElementwiseAddOp_broadcast_2(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 1, 4) + self.x = np.random.rand(2, 3, 100).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 1, 100) class TestFP16ElementwiseAddOp_broadcast_2(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 1, 4) + self.x = np.random.rand(2, 3, 100).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 1, 100) class TestElementwiseAddOp_broadcast_3(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(3, 4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 4, 1) + self.x = np.random.rand(2, 10, 12, 3).astype(self.dtype) + self.y = np.random.rand(10, 12).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 10, 12, 1) def init_axis(self): self.axis = 1 @@ -207,9 +215,9 @@ def init_axis(self): class TestFP16ElementwiseAddOp_broadcast_3(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(3, 4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 4, 1) + self.x = np.random.rand(2, 10, 12, 3).astype(self.dtype) + self.y = np.random.rand(10, 12).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 10, 12, 1) def init_axis(self): self.axis = 1 @@ -217,9 +225,9 @@ def init_axis(self): class TestElementwiseAddOp_broadcast_4(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(2, 1).astype(self.dtype) - self.out = self.x + self.y.reshape(2, 1, 1, 1) + self.x = np.random.rand(100, 2, 3, 4).astype(self.dtype) + self.y = np.random.rand(100, 1).astype(self.dtype) + self.out = self.x + self.y.reshape(100, 1, 1, 1) def init_axis(self): self.axis = 0 @@ -227,9 +235,9 @@ def init_axis(self): class TestFP16ElementwiseAddOp_broadcast_4(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(2, 1).astype(self.dtype) - self.out = self.x + self.y.reshape(2, 1, 1, 1) + self.x = np.random.rand(100, 2, 3, 4).astype(self.dtype) + self.y = np.random.rand(100, 1).astype(self.dtype) + self.out = self.x + self.y.reshape(100, 1, 1, 1) def init_axis(self): self.axis = 0 @@ -237,37 +245,37 @@ def init_axis(self): class TestElementwiseAddOp_broadcast_5(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(2, 1, 4).astype(self.dtype) + self.x = np.random.rand(10, 3, 12).astype(self.dtype) + self.y = np.random.rand(10, 1, 12).astype(self.dtype) self.out = self.x + self.y class TestFP16ElementwiseAddOp_broadcast_5(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(2, 1, 4).astype(self.dtype) + self.x = np.random.rand(10, 3, 12).astype(self.dtype) + self.y = np.random.rand(10, 1, 12).astype(self.dtype) self.out = self.x + self.y class TestElementwiseAddOp_broadcast_6(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(2, 3, 1, 5).astype(self.dtype) + self.x = np.random.rand(2, 12, 3, 5).astype(self.dtype) + self.y = np.random.rand(2, 12, 1, 5).astype(self.dtype) self.out = self.x + self.y class TestFP16ElementwiseAddOp_broadcast_6(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(2, 3, 1, 5).astype(self.dtype) + self.x = np.random.rand(2, 12, 3, 5).astype(self.dtype) + self.y = np.random.rand(2, 12, 1, 5).astype(self.dtype) self.out = self.x + self.y class TestElementwiseAddOp_rowwise_add_0(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(3, 4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 4) + self.x = np.random.rand(2, 10, 12).astype(self.dtype) + self.y = np.random.rand(10, 12).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 10, 12) def init_axis(self): self.axis = 1 @@ -275,17 +283,19 @@ def init_axis(self): class TestFP16ElementwiseAddOp_rowwise_add_0(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(3, 4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 4) + self.x = np.random.rand(2, 10, 12).astype(self.dtype) + self.y = np.random.rand(10, 12).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 10, 12) def init_axis(self): self.axis = 1 +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1) to test broadcast.") class TestElementwiseAddOp_rowwise_add_1(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 1).astype(self.dtype) + self.x = np.random.rand(100, 1).astype(self.dtype) self.y = np.random.rand(1).astype(self.dtype) self.out = self.x + self.y.reshape(1, 1) @@ -293,9 +303,11 @@ def init_axis(self): self.axis = 1 +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1) to test broadcast.") class TestFP16ElementwiseAddOp_rowwise_add_1(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 1).astype(self.dtype) + self.x = np.random.rand(100, 1).astype(self.dtype) self.y = np.random.rand(1).astype(self.dtype) self.out = self.x + self.y.reshape(1, 1) @@ -305,8 +317,8 @@ def init_axis(self): class TestElementwiseAddOp_channelwise_add(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(3, 20, 20).astype(self.dtype) - self.y = np.random.rand(3, 1, 1).astype(self.dtype) + self.x = np.random.rand(100, 2, 3).astype(self.dtype) + self.y = np.random.rand(100, 1, 1).astype(self.dtype) self.out = self.x + self.y def init_axis(self): @@ -315,8 +327,8 @@ def init_axis(self): class TestFP16ElementwiseAddOp_channelwise_add(TestFP16ElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(3, 10, 20).astype(self.dtype) - self.y = np.random.rand(3, 1, 1).astype(self.dtype) + self.x = np.random.rand(100, 2, 3).astype(self.dtype) + self.y = np.random.rand(100, 1, 1).astype(self.dtype) self.out = self.x + self.y def init_axis(self): @@ -325,8 +337,8 @@ def init_axis(self): class TestElementwiseAddOp_commonuse_add1(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) - self.y = np.random.rand(1, 1, 4).astype(self.dtype) + self.x = np.random.rand(2, 3, 100).astype(self.dtype) + self.y = np.random.rand(1, 1, 100).astype(self.dtype) self.out = self.x + self.y def init_axis(self): @@ -335,8 +347,8 @@ def init_axis(self): class TestElementwiseAddOp_commonuse_add2(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 1, 5).astype(self.dtype) - self.y = np.random.rand(2, 1, 4, 1).astype(self.dtype) + self.x = np.random.rand(10, 3, 1, 4).astype(self.dtype) + self.y = np.random.rand(10, 1, 12, 1).astype(self.dtype) self.out = self.x + self.y def init_axis(self): @@ -345,8 +357,8 @@ def init_axis(self): class TestElementwiseAddOp_xsize_lessthan_ysize_add(TestElementwiseAddOp): def init_input_output(self): - self.x = np.random.rand(4, 5).astype(self.dtype) - self.y = np.random.rand(2, 3, 4, 5).astype(self.dtype) + self.x = np.random.rand(10, 12).astype(self.dtype) + self.y = np.random.rand(2, 3, 10, 12).astype(self.dtype) self.out = self.x + self.y def init_axis(self): diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py index a2e2168f336da..6434807c55110 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py @@ -15,7 +15,7 @@ from __future__ import print_function import unittest import numpy as np -from op_test import OpTest +from op_test import OpTest, skip_check_grad_ci class TestElementwiseOp(OpTest): @@ -42,6 +42,8 @@ def test_check_grad_ingore_y(self): ['X'], 'Out', max_relative_error=0.005, no_grad_set=set('Y')) +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1) to test broadcast.") class TestElementwiseSubOp_scalar(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" @@ -66,13 +68,13 @@ class TestElementwiseSubOp_broadcast_0(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 13, 4).astype(np.float64), - 'Y': np.random.rand(2).astype(np.float64) + 'X': np.random.rand(100, 3, 2).astype(np.float64), + 'Y': np.random.rand(100).astype(np.float64) } self.attrs = {'axis': 0} self.outputs = { - 'Out': self.inputs['X'] - self.inputs['Y'].reshape(2, 1, 1) + 'Out': self.inputs['X'] - self.inputs['Y'].reshape(100, 1, 1) } @@ -80,13 +82,13 @@ class TestElementwiseSubOp_broadcast_1(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float64), - 'Y': np.random.rand(3).astype(np.float64) + 'X': np.random.rand(2, 100, 3).astype(np.float64), + 'Y': np.random.rand(100).astype(np.float64) } self.attrs = {'axis': 1} self.outputs = { - 'Out': self.inputs['X'] - self.inputs['Y'].reshape(1, 3, 1) + 'Out': self.inputs['X'] - self.inputs['Y'].reshape(1, 100, 1) } @@ -94,12 +96,12 @@ class TestElementwiseSubOp_broadcast_2(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float64), - 'Y': np.random.rand(4).astype(np.float64) + 'X': np.random.rand(2, 3, 100).astype(np.float64), + 'Y': np.random.rand(100).astype(np.float64) } self.outputs = { - 'Out': self.inputs['X'] - self.inputs['Y'].reshape(1, 1, 4) + 'Out': self.inputs['X'] - self.inputs['Y'].reshape(1, 1, 100) } @@ -107,13 +109,13 @@ class TestElementwiseSubOp_broadcast_3(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4, 5).astype(np.float64), - 'Y': np.random.rand(3, 4).astype(np.float64) + 'X': np.random.rand(2, 10, 12, 3).astype(np.float64), + 'Y': np.random.rand(10, 12).astype(np.float64) } self.attrs = {'axis': 1} self.outputs = { - 'Out': self.inputs['X'] - self.inputs['Y'].reshape(1, 3, 4, 1) + 'Out': self.inputs['X'] - self.inputs['Y'].reshape(1, 10, 12, 1) } @@ -121,8 +123,8 @@ class TestElementwiseSubOp_broadcast_4(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4, 5).astype(np.float64), - 'Y': np.random.rand(2, 3, 1, 5).astype(np.float64) + 'X': np.random.rand(2, 5, 3, 12).astype(np.float64), + 'Y': np.random.rand(2, 5, 1, 12).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -131,8 +133,8 @@ class TestElementwiseSubOp_commonuse_1(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float64), - 'Y': np.random.rand(1, 1, 4).astype(np.float64) + 'X': np.random.rand(2, 3, 100).astype(np.float64), + 'Y': np.random.rand(1, 1, 100).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -141,8 +143,8 @@ class TestElementwiseSubOp_commonuse_2(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 1, 5).astype(np.float64), - 'Y': np.random.rand(2, 1, 4, 1).astype(np.float64) + 'X': np.random.rand(10, 3, 1, 4).astype(np.float64), + 'Y': np.random.rand(10, 1, 12, 1).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -151,14 +153,14 @@ class TestElementwiseSubOp_xsize_lessthan_ysize(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(4, 5).astype(np.float64), - 'Y': np.random.rand(2, 3, 4, 5).astype(np.float64) + 'X': np.random.rand(10, 12).astype(np.float64), + 'Y': np.random.rand(2, 3, 10, 12).astype(np.float64) } self.attrs = {'axis': 2} self.outputs = { - 'Out': self.inputs['X'].reshape(1, 1, 4, 5) - self.inputs['Y'] + 'Out': self.inputs['X'].reshape(1, 1, 10, 12) - self.inputs['Y'] } diff --git a/python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py b/python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py index 143c12047d0ee..4ed37162de808 100644 --- a/python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py +++ b/python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py @@ -12,21 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -NOT_CHECK_OP_LIST = [ - # The increment's input must be 1-d and only has one data - 'increment', - # elementwise ops have cases(y_shape: (1) or (1,1)) to test broadcast - 'elementwise_add', - 'elementwise_sub', +NEED_TO_FIX_OP_LIST = [ 'elementwise_mul', 'elementwise_div', 'elementwise_max', 'elementwise_min', 'elementwise_pow', 'fused_elemwise_activation', -] - -NEED_TO_FIX_OP_LIST = [ 'bilinear_tensor_product', 'conv2d_transpose', 'deformable_conv', From c2b7ad6c718e517d6f1c0e23452c20e01c1cbf17 Mon Sep 17 00:00:00 2001 From: zhupengyang <1165938320@qq.com> Date: Thu, 16 Jan 2020 11:40:24 +0000 Subject: [PATCH 2/2] use large shape for elt-add in mkldnn cases test=develop --- .../mkldnn/test_elementwise_add_mkldnn_op.py | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py index c3a42656b71d0..e2e932a8a5c06 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_elementwise_add_mkldnn_op.py @@ -16,7 +16,7 @@ import unittest import numpy as np import paddle.fluid.core as core -from paddle.fluid.tests.unittests.op_test import OpTest +from paddle.fluid.tests.unittests.op_test import OpTest, skip_check_grad_ci from paddle.fluid.tests.unittests.test_elementwise_add_op import * ''' Some tests differ from the tests defined in test_elementwise_add_op.py @@ -35,6 +35,8 @@ def init_kernel_type(self): self.use_mkldnn = True +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1) to test broadcast.") class TestMKLDNNElementwiseAddOp_scalar(TestElementwiseAddOp_scalar): def init_input_output(self): self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) @@ -45,6 +47,8 @@ def init_kernel_type(self): self.use_mkldnn = True +@skip_check_grad_ci( + reason="[skip shape check] Use y_shape(1,1) to test broadcast.") class TestMKLDNNElementwiseAddOp_scalar2(TestElementwiseAddOp_scalar2): def init_input_output(self): self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) @@ -62,9 +66,9 @@ def init_kernel_type(self): class TesMKLDNNtElementwiseAddOp_broadcast_0(TestElementwiseAddOp_broadcast_0): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(2).astype(self.dtype) - self.out = self.x + self.y.reshape(2, 1, 1, 1) + self.x = np.random.rand(100, 2, 3, 4).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(100, 1, 1, 1) def init_kernel_type(self): self.use_mkldnn = True @@ -72,9 +76,9 @@ def init_kernel_type(self): class TestMKLDNNElementwiseAddOp_broadcast_1(TestElementwiseAddOp_broadcast_1): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(3).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 1, 1) + self.x = np.random.rand(2, 100, 3, 4).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 100, 1, 1) def init_kernel_type(self): self.use_mkldnn = True @@ -82,9 +86,9 @@ def init_kernel_type(self): class TestMKLDNNElementwiseAddOp_broadcast_2(TestElementwiseAddOp_broadcast_2): def init_input_output(self): - self.x = np.random.rand(2, 2, 3, 4).astype(self.dtype) - self.y = np.random.rand(4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 1, 1, 4) + self.x = np.random.rand(2, 2, 3, 100).astype(self.dtype) + self.y = np.random.rand(100).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 1, 1, 100) def init_kernel_type(self): self.use_mkldnn = True @@ -103,9 +107,9 @@ def init_kernel_type(self): class TestMKLDNNElementwiseAddOp_rowwise_add_0( TestElementwiseAddOp_rowwise_add_0): def init_input_output(self): - self.x = np.random.rand(2, 3, 4, 5).astype(self.dtype) - self.y = np.random.rand(3, 4).astype(self.dtype) - self.out = self.x + self.y.reshape(1, 3, 4, 1) + self.x = np.random.rand(2, 10, 12, 3).astype(self.dtype) + self.y = np.random.rand(10, 12).astype(self.dtype) + self.out = self.x + self.y.reshape(1, 10, 12, 1) def init_kernel_type(self): self.use_mkldnn = True @@ -120,8 +124,8 @@ def init_kernel_type(self): class TestMKLDNNElementwiseAddOp_channelwise_add( TestElementwiseAddOp_channelwise_add): def init_input_output(self): - self.x = np.random.rand(3, 5, 20, 20).astype(self.dtype) - self.y = np.random.rand(3, 1, 1, 1).astype(self.dtype) + self.x = np.random.rand(100, 2, 3, 3).astype(self.dtype) + self.y = np.random.rand(100, 1, 1, 1).astype(self.dtype) self.out = self.x + self.y def init_kernel_type(self):