From 55f9b71ad98a68b5328e193ab84b18e51cb0349c Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Tue, 29 Mar 2022 09:52:38 +0800 Subject: [PATCH] [Eager]Switch new Eager mode (#40990) * [Eager]Switch new Eager mode * switch into eager * fix typo --- .../fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py | 4 +++- .../fluid/tests/unittests/dygraph_to_static/test_resnet.py | 4 +++- .../fluid/tests/unittests/dygraph_to_static/test_se_resnet.py | 4 +++- .../fluid/tests/unittests/dygraph_to_static/test_seq2seq.py | 4 +++- .../fluid/tests/unittests/dygraph_to_static/test_simnet.py | 4 +++- .../tests/unittests/dygraph_to_static/test_transformer.py | 4 +++- .../fluid/tests/unittests/dygraph_to_static/test_tsm.py | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py index ea0529ffb28..7b7ff66343a 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py @@ -314,4 +314,6 @@ class TestPtb(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py index 2fbb933f9ce..efb69b530ef 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py @@ -366,4 +366,6 @@ class TestResnet(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py index eb17264977f..eba7e238bb5 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py @@ -505,4 +505,6 @@ class TestSeResnet(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py index 3c0c046191c..a363526530d 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py @@ -203,4 +203,6 @@ class TestSeq2seq(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py index 01e9ed07efa..ce88ea74af2 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_simnet.py @@ -170,4 +170,6 @@ class TestSimnet(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_transformer.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_transformer.py index 451ceea75c0..06f2c60dfae 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_transformer.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_transformer.py @@ -402,4 +402,6 @@ class TestTransformer(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py index 7ca0a1a539e..37fc78458dd 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py @@ -347,4 +347,6 @@ class TestTsm(unittest.TestCase): if __name__ == '__main__': - unittest.main() + # switch into new eager mode + with fluid.framework._test_eager_guard(): + unittest.main() -- GitLab