未验证 提交 dc17ac91 编写于 作者: Z Zhen Wang 提交者: GitHub

fix import fluid error in dygraph_to_static. test=develop (#25195)

上级 b0f18947
...@@ -369,6 +369,8 @@ def ast_to_func(ast_root, dyfunc, delete_on_exit=True): ...@@ -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. function, the other inner functions are invisible for the decorated function.
""" """
source = ast_to_source_code(ast_root) source = ast_to_source_code(ast_root)
import_fluid = "import paddle.fluid as fluid\n"
source = import_fluid + source
if six.PY2: if six.PY2:
source = source.encode('utf-8') source = source.encode('utf-8')
f = tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) f = tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册