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

Fix mx.symbol.numpy._Symbol.__deepcopy__ logic error #18686

Merged
merged 4 commits into from
Jul 22, 2020
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/numpy/_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def __neg__(self):
return negative(self)

def __deepcopy__(self, _):
return super(_Symbol, self).as_np_ndarray()
return super().__deepcopy__(_).as_np_ndarray()

def __eq__(self, other):
"""x.__eq__(y) <=> x == y"""
Expand Down
10 changes: 10 additions & 0 deletions tests/python/unittest/test_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,13 @@ def test_infershape_happens_for_all_ops_in_graph():

assert False

def test_symbol_copy():
a = mx.sym.Variable('a')
b = copy.copy(a)
b._set_attr(name='b')
assert a.name == 'a' and b.name == 'b'

a = mx.sym.Variable('a').as_np_ndarray()
b = copy.copy(a)
b._set_attr(name='b')
assert a.name == 'a' and b.name == 'b'