未验证 提交 05476e9f 编写于 作者: W wawltor 提交者: GitHub

Fix the matmul test case, avoid double and float precision diff

reduce the pricision of test case for matmul
上级 4c57e395
......@@ -253,10 +253,14 @@ class API_TestMm(unittest.TestCase):
exe = fluid.Executor(fluid.CPUPlace())
data1 = np.random.rand(3, 2)
data2 = np.random.rand(2, 3)
np_res, np_y_1 = exe.run(feed={'x': data1,
np_res, expected_result = exe.run(feed={'x': data1,
'y': data2},
fetch_list=[res, y_1])
self.assertEqual((np_res == np_y_1).all(), True)
self.assertTrue(
np.allclose(
np.array(np_res), np.array(expected_result), atol=1e-5),
"two value is\
{}\n{}, check diff!".format(np_res, expected_result))
with fluid.program_guard(fluid.Program()):
x = fluid.data(name="x", shape=[2], dtype="float64")
......@@ -270,7 +274,11 @@ class API_TestMm(unittest.TestCase):
expected_result = np.matmul(
data1.reshape(1, 2), data2.reshape(2, 1))
self.assertEqual((np_res == expected_result).all(), True)
self.assertTrue(
np.allclose(
np_res, expected_result, atol=1e-5),
"two value is\
{}\n{}, check diff!".format(np_res, expected_result))
class API_TestMmError(unittest.TestCase):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册