From c4f8f3bddc7795ad952c2fc544880a2b00a54280 Mon Sep 17 00:00:00 2001 From: zhupengyang Date: Mon, 16 Dec 2019 19:24:04 +0800 Subject: [PATCH] use large input shape for accuracy test (#21758) - ngarph: elementwise_sub, elementwise_mul - mkldnn: transpose, sum - others: scatter_nd test=develop --- .../tests/unittests/mkldnn/test_sum_mkldnn_op.py | 6 +++--- .../unittests/mkldnn/test_transpose_mkldnn_op.py | 4 ++-- .../fluid/tests/unittests/test_elementwise_mul_op.py | 12 ++++++------ .../fluid/tests/unittests/test_elementwise_sub_op.py | 8 ++++---- .../fluid/tests/unittests/test_scatter_nd_op.py | 7 ++++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/mkldnn/test_sum_mkldnn_op.py b/python/paddle/fluid/tests/unittests/mkldnn/test_sum_mkldnn_op.py index 30d9f720f9..f019cd3a40 100644 --- a/python/paddle/fluid/tests/unittests/mkldnn/test_sum_mkldnn_op.py +++ b/python/paddle/fluid/tests/unittests/mkldnn/test_sum_mkldnn_op.py @@ -25,9 +25,9 @@ class TestMKLDNN(TestSumOp): self.op_type = "sum" self.init_kernel_type() self.use_mkldnn = True - x0 = np.random.random((3, 4)).astype(self.dtype) - x1 = np.random.random((3, 4)).astype(self.dtype) - x2 = np.random.random((3, 4)).astype(self.dtype) + x0 = np.random.random((25, 4)).astype(self.dtype) + x1 = np.random.random((25, 4)).astype(self.dtype) + x2 = np.random.random((25, 4)).astype(self.dtype) self.inputs = {"X": [("x0", x0), ("x1", x1), ("x2", x2)]} y = x0 + x1 + x2 self.outputs = {'Out': y} 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 84ea2eb6a4..d0fe1f94c6 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 @@ -48,13 +48,13 @@ class TestTransposeMKLDNN(TestTransposeOp): self.check_grad(['X'], 'Out', check_dygraph=False) def initTestCase(self): - self.shape = (3, 4) + self.shape = (30, 4) self.axis = (1, 0) class TestCase0MKLDNN(TestTransposeMKLDNN): def initTestCase(self): - self.shape = (3, ) + self.shape = (100, ) self.axis = (0, ) diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py index 71967a51bd..89cfc33b84 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py @@ -83,7 +83,7 @@ class TestElementwiseMulOp_scalar(ElementwiseMulOp): def setUp(self): self.op_type = "elementwise_mul" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float32), + 'X': np.random.rand(10, 3, 4).astype(np.float32), 'Y': np.random.rand(1).astype(np.float32) } self.outputs = {'Out': self.inputs['X'] * self.inputs['Y']} @@ -94,8 +94,8 @@ class TestElementwiseMulOp_Vector(ElementwiseMulOp): def setUp(self): self.op_type = "elementwise_mul" self.inputs = { - 'X': np.random.random((32, )).astype("float64"), - 'Y': np.random.random((32, )).astype("float64") + 'X': np.random.random((100, )).astype("float64"), + 'Y': np.random.random((100, )).astype("float64") } self.outputs = {'Out': np.multiply(self.inputs['X'], self.inputs['Y'])} self.init_kernel_type() @@ -103,7 +103,7 @@ class TestElementwiseMulOp_Vector(ElementwiseMulOp): class TestElementwiseMulOp_broadcast_0(ElementwiseMulOp): def init_input_output(self): - self.x = np.random.rand(2, 3, 4).astype(self.dtype) + self.x = np.random.rand(2, 13, 4).astype(self.dtype) self.y = np.random.rand(2).astype(self.dtype) self.out = self.x * self.y.reshape(2, 1, 1) @@ -115,7 +115,7 @@ class TestElementwiseMulOp_broadcast_1(ElementwiseMulOp): def setUp(self): self.op_type = "elementwise_mul" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float64), + 'X': np.random.rand(10, 3, 4).astype(np.float64), 'Y': np.random.rand(3).astype(np.float64) } @@ -130,7 +130,7 @@ class TestElementwiseMulOp_broadcast_2(ElementwiseMulOp): def setUp(self): self.op_type = "elementwise_mul" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float64), + 'X': np.random.rand(10, 3, 4).astype(np.float64), 'Y': np.random.rand(4).astype(np.float64) } 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 5a5e47f163..e602718b87 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py @@ -46,7 +46,7 @@ class TestElementwiseSubOp_scalar(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float32), + 'X': np.random.rand(10, 3, 4).astype(np.float32), 'Y': np.random.rand(1).astype(np.float32) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -56,8 +56,8 @@ class TestElementwiseSubOp_Vector(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.random((32, )).astype("float32"), - 'Y': np.random.random((32, )).astype("float32") + 'X': np.random.random((100, )).astype("float32"), + 'Y': np.random.random((100, )).astype("float32") } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -66,7 +66,7 @@ class TestElementwiseSubOp_broadcast_0(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float32), + 'X': np.random.rand(2, 13, 4).astype(np.float32), 'Y': np.random.rand(2).astype(np.float32) } diff --git a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py index fee3073169..5772ba86fb 100644 --- a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py +++ b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py @@ -65,9 +65,10 @@ class TestScatterNdAddSimpleOp(OpTest): def setUp(self): self.op_type = "scatter_nd_add" - ref_np = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]).astype("float32") - index_np = np.array([[1], [2], [3], [5], [1]]).astype("int32") - updates_np = np.array([9, 10, 11, 12, 13]).astype("float32") + #ref_np = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]).astype("float32") + ref_np = np.random.random([100]).astype("float32") + index_np = np.random.randint(0, 100, [100, 1]).astype("int32") + updates_np = np.random.random([100]).astype("float32") expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np) #expect_np = [ 0. 23. 12. 14. 4. 17. 6. 7. 8.] -- GitLab