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



##########
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))
+    inp2[-1, -1] = 1
+    inp2.attach_grad()
+    with mx.autograd.record():
+        out2 = np.trace(inp2, offset=INT_OVERFLOW-2)
+        out2.backward()
+    assert out2 == 1
+    assert inp2.grad.shape == inp2.shape
+    assert inp2.grad[0, -2] == 1 and inp2.grad[-1, -1] == 1
+
+
+@use_np
+def test_tri():
+    N = 2**16
+    data1 = np.tri(N)
+    assert data1.shape == (N, N)
+    assert data1[0, 0] == 1 and data1[-1, -1] == 1
+    assert data1[0, -1] == 0 and data1[-1, 0] == 1
+    data2 = np.tri(2, INT_OVERFLOW, INT_OVERFLOW-2)

Review comment:
       same 

##########
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))
+    inp2[-1, -1] = 1
+    inp2.attach_grad()
+    with mx.autograd.record():
+        out2 = np.trace(inp2, offset=INT_OVERFLOW-2)
+        out2.backward()
+    assert out2 == 1
+    assert inp2.grad.shape == inp2.shape
+    assert inp2.grad[0, -2] == 1 and inp2.grad[-1, -1] == 1
+
+
+@use_np
+def test_tri():
+    N = 2**16
+    data1 = np.tri(N)
+    assert data1.shape == (N, N)
+    assert data1[0, 0] == 1 and data1[-1, -1] == 1
+    assert data1[0, -1] == 0 and data1[-1, 0] == 1
+    data2 = np.tri(2, INT_OVERFLOW, INT_OVERFLOW-2)
+    assert data2.shape == (2, INT_OVERFLOW)
+    assert data2[0, -1] == 0 and data2[-1, -1] == 1
+
+
+@use_np
+def test_tril():
+    N = 2**16
+    inp1 = np.ones((N, N))
+    inp1.attach_grad()
+    with mx.autograd.record():
+        out1 = np.tril(inp1)
+        out1.backward()
+    assert out1.shape == (N, N)
+    assert out1[-1, -1] == 1 and out1[0, -1] == 0 and out1[-1, 0] == 1
+    assert inp1.grad.shape == inp1.shape
+    assert inp1.grad[-1, -1] == 1 and inp1.grad[0, -1] == 0 and \
+        inp1.grad[-1, 0] == 1
+    inp2 = np.ones((2, INT_OVERFLOW))

Review comment:
       same




----------------------------------------------------------------
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