未验证 提交 8666902b 编写于 作者: W Wu Yi 提交者: GitHub

fix test_transpiler random fail test=develop (#15736)

上级 69f5c0ee
...@@ -22,6 +22,9 @@ import six ...@@ -22,6 +22,9 @@ import six
import unittest import unittest
import numpy as np import numpy as np
import gc
gc.set_debug(gc.DEBUG_COLLECTABLE)
import paddle.fluid as fluid import paddle.fluid as fluid
...@@ -99,6 +102,12 @@ class TranspilerTest(unittest.TestCase): ...@@ -99,6 +102,12 @@ class TranspilerTest(unittest.TestCase):
with fluid.unique_name.guard(): with fluid.unique_name.guard():
with fluid.program_guard(main, startup): with fluid.program_guard(main, startup):
self.transpiler_test_impl() self.transpiler_test_impl()
# NOTE: run gc.collect to eliminate pybind side objects to
# prevent random double-deallocate when inherited in python.
del self.transpiler
del main
del startup
gc.collect()
class TestBasicModel(TranspilerTest): class TestBasicModel(TranspilerTest):
...@@ -797,6 +806,7 @@ class TestNCCL2Transpile(TranspilerTest): ...@@ -797,6 +806,7 @@ class TestNCCL2Transpile(TranspilerTest):
print([op.type for op in startup.global_block().ops]) print([op.type for op in startup.global_block().ops])
self.assertEqual(startup.global_block().ops[-1].type, "gen_nccl_id") self.assertEqual(startup.global_block().ops[-1].type, "gen_nccl_id")
self.assertIsNotNone(startup.global_block().vars.get("NCCLID")) self.assertIsNotNone(startup.global_block().vars.get("NCCLID"))
gc.collect()
else: else:
pass pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册