From e496d1e9b05906b38e2e5d424b6d4ad571ff678f Mon Sep 17 00:00:00 2001 From: Haohongxiang <86215757+haohongxiang@users.noreply.github.com> Date: Mon, 18 Oct 2021 10:46:30 +0800 Subject: [PATCH] modify ut of cond (#36475) --- python/paddle/fluid/tests/unittests/test_linalg_cond.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_linalg_cond.py b/python/paddle/fluid/tests/unittests/test_linalg_cond.py index 237c9643024..d13bdd676b4 100644 --- a/python/paddle/fluid/tests/unittests/test_linalg_cond.py +++ b/python/paddle/fluid/tests/unittests/test_linalg_cond.py @@ -32,7 +32,8 @@ def test_static_assert_true(self, x_list, p_list): exe = static.Executor() result = exe.run(feed={"X": x}, fetch_list=[output]) expected_output = np.linalg.cond(x, p) - self.assertTrue(np.allclose(result, expected_output)) + np.testing.assert_allclose( + result[0], expected_output, rtol=5e-5) def test_dygraph_assert_true(self, x_list, p_list): @@ -41,7 +42,8 @@ def test_dygraph_assert_true(self, x_list, p_list): input_tensor = paddle.to_tensor(x) output = paddle.linalg.cond(input_tensor, p) expected_output = np.linalg.cond(x, p) - self.assertTrue(np.allclose(output, expected_output)) + np.testing.assert_allclose( + output.numpy(), expected_output, rtol=5e-5) def gen_input(): @@ -156,5 +158,4 @@ class TestCondEmptyTensorInput(unittest.TestCase): if __name__ == "__main__": paddle.enable_static() - # paddle.device.set_device("cpu") unittest.main() -- GitLab