From 595e9c5a5f9d57502a82ec3393b174cf60dfd990 Mon Sep 17 00:00:00 2001 From: wawltor Date: Thu, 9 Apr 2020 22:29:52 +0800 Subject: [PATCH] Fix the test case bug for matmul, test=develop (#23674) Fix the bug of matmul test_case --- .../fluid/tests/unittests/test_matmul_op.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_matmul_op.py b/python/paddle/fluid/tests/unittests/test_matmul_op.py index 28c8fd9e38..b4d975fb5e 100644 --- a/python/paddle/fluid/tests/unittests/test_matmul_op.py +++ b/python/paddle/fluid/tests/unittests/test_matmul_op.py @@ -246,26 +246,26 @@ for dim in [4]: class API_TestMm(unittest.TestCase): def test_out(self): with fluid.program_guard(fluid.Program()): - x = fluid.data(name="x", shape=[3, 2], dtype="float32") - y = fluid.data(name='y', shape=[2, 3], dtype='float32') - res = fluid.data(name="output", shape=[3, 3], dtype="float32") + x = fluid.data(name="x", shape=[3, 2], dtype="float64") + y = fluid.data(name='y', shape=[2, 3], dtype='float64') + res = fluid.data(name="output", shape=[3, 3], dtype="float64") y_1 = paddle.mm(x, y, out=res) exe = fluid.Executor(fluid.CPUPlace()) - data1 = np.random.rand(3, 2).astype('float32') - data2 = np.random.rand(2, 3).astype('float32') + data1 = np.random.rand(3, 2) + data2 = np.random.rand(2, 3) np_res, np_y_1 = exe.run(feed={'x': data1, 'y': data2}, fetch_list=[res, y_1]) self.assertEqual((np_res == np_y_1).all(), True) with fluid.program_guard(fluid.Program()): - x = fluid.data(name="x", shape=[2], dtype="float32") - y = fluid.data(name='y', shape=[2], dtype='float32') - res = fluid.data(name="output", shape=[1], dtype="float32") + x = fluid.data(name="x", shape=[2], dtype="float64") + y = fluid.data(name='y', shape=[2], dtype='float64') + res = fluid.data(name="output", shape=[1], dtype="float64") result = paddle.mm(x, y) exe = fluid.Executor(fluid.CPUPlace()) - data1 = np.random.rand(2).astype('float32') - data2 = np.random.rand(2).astype('float32') + data1 = np.random.rand(2) + data2 = np.random.rand(2) np_res = exe.run(feed={'x': data1, 'y': data2}, fetch_list=[result]) expected_result = np.matmul( data1.reshape(1, 2), data2.reshape(2, 1)) -- GitLab