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

fix bug of ListTransformer in dygraph_to_static. test=develop (#23153)

上级 e9b18c74
...@@ -196,6 +196,7 @@ class ListTransformer(gast.NodeTransformer): ...@@ -196,6 +196,7 @@ class ListTransformer(gast.NodeTransformer):
self.list_name_to_updated[target_id] = False self.list_name_to_updated[target_id] = False
self.list_nodes.add(node) self.list_nodes.add(node)
return True return True
elif target_id in self.list_name_to_updated: elif target_id in self.list_name_to_updated and \
self.list_name_to_updated[target_id] == False:
del self.list_name_to_updated[target_id] del self.list_name_to_updated[target_id]
return False return False
...@@ -58,8 +58,8 @@ def test_list_in_for_loop_with_concat(x, iter_num): ...@@ -58,8 +58,8 @@ def test_list_in_for_loop_with_concat(x, iter_num):
a = [] a = []
for i in range(iter_num): for i in range(iter_num):
a.append(x) a.append(x)
out = fluid.layers.concat(a, axis=0) a = fluid.layers.concat(a, axis=0)
return out return a
def test_list_in_while_loop(x, iter_num): def test_list_in_while_loop(x, iter_num):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册