未验证 提交 11f94cdc 编写于 作者: L liym27 提交者: GitHub

Improve function is_control_flow_to_transform. test=develop (#23109)

上级 573d2faa
......@@ -93,8 +93,10 @@ def is_control_flow_to_transform(node, var_name_to_type):
"The type of input node must be gast.AST, but received %s." % type(node)
if isinstance(node, gast.If):
# TODO: make a better condition
return True
from .ifelse_transformer import IfConditionVisitor
if_visitor = IfConditionVisitor(
node.test, node_var_type_map=var_name_to_type)
return if_visitor.is_control_flow()
if isinstance(node, gast.For):
# TODO: make a better condition
......
......@@ -27,7 +27,9 @@ def test_list_without_control_flow(x):
# Python list will not be transformed.
x = fluid.dygraph.to_variable(x)
a = []
a.append(x)
# It's a plain python control flow which won't be transformed
if 2 > 1:
a.append(x)
return a
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册