access2rohit commented on a change in pull request #19541:
URL: https://github.com/apache/incubator-mxnet/pull/19541#discussion_r538948709



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1312,6 +1312,219 @@ def test_polyval():
     assert poly.grad.shape == poly.shape
     assert poly.grad[0] == 4
 
+
+@use_np
+def test_rot90():
+    inp = np.zeros((1, 2, INT_OVERFLOW))
+    inp[-1, -1, -1] = 1
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.rot90(inp, axes=(1,2))
+        out.backward()
+    assert out.shape == (1, INT_OVERFLOW, 2)
+    assert out[0, 0, 1] == 1
+    assert inp.grad.shape == inp.shape
+    assert inp.grad[-1, -1, -1] == 1
+
+
+@use_np
+def test_squeeze():
+    inp = np.zeros((2, 1, INT_OVERFLOW))
+    inp[-1, -1, -1] = 1
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.squeeze(inp, axis=1)
+        out.backward()
+    assert out.shape == (2, INT_OVERFLOW)
+    assert out[-1, -1] == 1
+    assert inp.grad.shape == inp.shape
+    assert inp.grad[-1, -1, -1] == 1
+
+
+@use_np
+def test_tile():
+    inp = np.array([[0, 1],[2, 3]])
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.tile(inp, (1, HALF_INT_OVERFLOW))
+        out.backward()
+    assert out.shape == (2, INT_OVERFLOW)
+    assert out[-1, -1] == 3
+    assert inp.grad.shape == inp.shape
+    assert inp.grad[-1, -1] == HALF_INT_OVERFLOW
+
+
+@use_np
+def test_trace():
+    N = 2**16
+    inp1 = np.eye(N)
+    inp1.attach_grad()
+    with mx.autograd.record():
+        out1 = np.trace(inp1)
+        out1.backward()
+    assert out1 == N
+    assert inp1.grad.shape == inp1.shape
+    assert inp1.grad[0, 0] == 1 and inp1.grad[-1, -1] == 1
+    inp2 = np.zeros((2, INT_OVERFLOW))

Review comment:
       Can we use inp1 here again so previous memory is released by python ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to