From 41a7ce8347dcf154f3f33707d96fc4217b5dbd60 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 25 Sep 2020 10:09:31 +0800 Subject: [PATCH] fix random failure of test_buffer_sahred_memory_reuse_pass (#27551) --- .../test_buffer_shared_memory_reuse_pass.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_buffer_shared_memory_reuse_pass.py b/python/paddle/fluid/tests/unittests/test_buffer_shared_memory_reuse_pass.py index 2c9168df472..9dd617f90b6 100644 --- a/python/paddle/fluid/tests/unittests/test_buffer_shared_memory_reuse_pass.py +++ b/python/paddle/fluid/tests/unittests/test_buffer_shared_memory_reuse_pass.py @@ -115,8 +115,15 @@ class InplaceTestBase(unittest.TestCase): fetch_val2, = exe.run(compiled_prog, feed=feed_dict, fetch_list=[fetch_var]) - - self.assertTrue(np.array_equal(fetch_val1, fetch_val2)) + #NOTE(zhiqiu): Temporally changed from array_equal to allclose. + # The real root is fuse_all_reduce and fuse_all_optimizer_opss may + # result in diff because of the instruction set on the virtual machine. + # And the related unit tests: test_fuse_all_reduce_pass and test_fuse_optimizer_pass use "almostEqual" in their checks. + # There are also some related issues: + # https://github.com/PaddlePaddle/Paddle/issues/21270 + # https://github.com/PaddlePaddle/Paddle/issues/21046 + # https://github.com/PaddlePaddle/Paddle/issues/21045 + self.assertTrue(np.allclose(fetch_val1, fetch_val2)) def check_multi_card_fetch_var(self): if self.is_invalid_test(): @@ -160,7 +167,8 @@ class InplaceTestBase(unittest.TestCase): fetch_vals.append(fetch_val) for item in fetch_vals: - self.assertTrue(np.array_equal(fetch_vals[0], item)) + # save above + self.assertTrue(np.allclose(fetch_vals[0], item)) class CUDAInplaceTest(InplaceTestBase): -- GitLab