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

revert-23830-2.0-beta
liym27 5 years ago committed by GitHub
parent e9b18c7402
commit ebe4eab985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -196,6 +196,7 @@ class ListTransformer(gast.NodeTransformer):
self.list_name_to_updated[target_id] = False
self.list_nodes.add(node)
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]
return False

@ -58,8 +58,8 @@ def test_list_in_for_loop_with_concat(x, iter_num):
a = []
for i in range(iter_num):
a.append(x)
out = fluid.layers.concat(a, axis=0)
return out
a = fluid.layers.concat(a, axis=0)
return a
def test_list_in_while_loop(x, iter_num):

Loading…
Cancel
Save