From 934cbcd88f29cdca2a1092ffbaeeabd20232c9a1 Mon Sep 17 00:00:00 2001 From: 0x45f <23097963+0x45f@users.noreply.github.com> Date: Fri, 1 Apr 2022 20:02:06 +0800 Subject: [PATCH] Switch some dy2st UT to eager mode (#41255) --- .../fluid/tests/unittests/dygraph_to_static/test_bert.py | 3 ++- .../paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py | 3 ++- .../fluid/tests/unittests/dygraph_to_static/test_mobile_net.py | 3 ++- .../unittests/dygraph_to_static/test_program_translator.py | 3 ++- .../fluid/tests/unittests/dygraph_to_static/test_sentiment.py | 3 ++- .../fluid/tests/unittests/dygraph_to_static/test_word2vec.py | 3 ++- python/paddle/fluid/tests/unittests/test_jit_save_load.py | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py index 6c26189a4ad..a9e94ef09b9 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py @@ -220,4 +220,5 @@ class TestBert(unittest.TestCase): if __name__ == '__main__': - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py index f69abb1e376..00af9c96ba9 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py @@ -773,4 +773,5 @@ class TestTrain(unittest.TestCase): if __name__ == "__main__": - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py index c6f491a5484..f58041cbb6c 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py @@ -628,4 +628,5 @@ class TestMobileNet(unittest.TestCase): if __name__ == '__main__': - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py index d2c43c31a88..b0ffbac88fb 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_program_translator.py @@ -363,4 +363,5 @@ class TestRemoveCommentInDy2St(unittest.TestCase): if __name__ == '__main__': - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py index 74d415cc3ee..b72894fb147 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py @@ -358,4 +358,5 @@ class TestSentiment(unittest.TestCase): if __name__ == '__main__': - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py index dd6cc7e9d32..f270c5672af 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py @@ -303,4 +303,5 @@ class TestWord2Vec(unittest.TestCase): if __name__ == '__main__': - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_jit_save_load.py b/python/paddle/fluid/tests/unittests/test_jit_save_load.py index fc58f979b4d..5dabf854734 100644 --- a/python/paddle/fluid/tests/unittests/test_jit_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_jit_save_load.py @@ -1454,4 +1454,5 @@ class TestInputSpecCompatibility(unittest.TestCase): if __name__ == '__main__': - unittest.main() + with fluid.framework._test_eager_guard(): + unittest.main() -- GitLab