Skip to content

Commit

Permalink
Fix iterator over symbol when multiple children have the same name (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrendx authored and haohuw committed Jun 23, 2019
1 parent 09c50e7 commit 81c2425
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit 81c2425

Please sign in to comment.