From dc17ac919993b3ca102d3daa02d11ed26b4fb7d2 Mon Sep 17 00:00:00 2001 From: Zhen Wang Date: Thu, 2 Jul 2020 17:27:22 +0800 Subject: [PATCH] fix import fluid error in dygraph_to_static. test=develop (#25195) --- python/paddle/fluid/dygraph/dygraph_to_static/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py index 4b489c7d28..bb5b2843c9 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py @@ -369,6 +369,8 @@ def ast_to_func(ast_root, dyfunc, delete_on_exit=True): function, the other inner functions are invisible for the decorated function. """ source = ast_to_source_code(ast_root) + import_fluid = "import paddle.fluid as fluid\n" + source = import_fluid + source if six.PY2: source = source.encode('utf-8') f = tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) -- GitLab