From a330a022d4c32b9096c4b6d7066a936d6eef59a1 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Wed, 22 Jul 2020 06:31:47 +0000 Subject: [PATCH] Fix mx.symbol.numpy._Symbol.__deepcopy__ logic error (#18686) * Fix mx.symbol.numpy._Symbol.__deepcopy__ logic error Performed shallow copy instead of deep copy * Test * Fix test --- tests/python/unittest/test_symbol.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/python/unittest/test_symbol.py b/tests/python/unittest/test_symbol.py index 1c84af0c668e..910b6ca15499 100644 --- a/tests/python/unittest/test_symbol.py +++ b/tests/python/unittest/test_symbol.py @@ -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'