diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py index 4b489c7d2847dc49df86645f69c61573a4adfbcb..bb5b2843c92e2b1ed88b002bb1511c07ddd61f37 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)