Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix iterator over symbol when multiple children have the same name #14597

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/mxnet/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __iter__(self):
<Symbol d>
<Symbol _plus0>
"""
return (self[i] for i in self.list_outputs())
return (self[i] for i in range(len(self)))

def __add__(self, other):
"""x.__add__(y) <=> x+y
Expand Down
5 changes: 5 additions & 0 deletions tests/python/unittest/test_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ def test_simple_bind_gradient_graph_possible_with_cycle():
res = data + data + data + data + data + data + data + data
res.simple_bind(ctx=mx.cpu(), data=(1,))

def test_children_same_name():
a = mx.sym.Variable('data')
b = a + a
for c in b.get_children():
pass

if __name__ == '__main__':
import nose
Expand Down