Zha0q1 commented on a change in pull request #18932:
URL: https://github.com/apache/incubator-mxnet/pull/18932#discussion_r473316123
##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -78,14 +79,669 @@ def test_softmax():
output = npx.softmax(input_data, axis=axis)
assert_almost_equal(output.asnumpy(), true_output, rtol=1e-5,
atol=1e-5)
-#@pytest.mark.skip(reason="CI hasn't switch to ILP64 OpenBLAS yet")
+'''
+ _ _ _ _ _ __ _ __ _ _
+ | ' \ || | ' \| '_ \ || |
+ |_||_\_,_|_|_|_| .__/\_, |
+ |_| |__/
+'''
+
+@use_np
+def test_ones():
+ A = np.ones((INT_OVERFLOW, 2))
+ assert A.shape == (INT_OVERFLOW, 2)
+ assert A[0][0] == 1
+
+@use_np
+def test_zeros():
+ A = np.zeros((INT_OVERFLOW, 2))
+ assert A.shape == (INT_OVERFLOW, 2)
+ assert A[0][0] == 0
+
+@use_np
+def test_abs():
+ A = np.ones((INT_OVERFLOW, 2))
+ A[0][0] = -1
+ A.attach_grad()
+ with mx.autograd.record():
+ B = np.abs(A)
+ assert B.shape == (INT_OVERFLOW, 2)
+ assert B[0][0] == 1
+ B.backward()
+ assert A.grad.shape == (INT_OVERFLOW, 2)
+ assert A.grad[0][0] == -1
+
+@use_np
+def test_absolute():
+ A = np.ones((INT_OVERFLOW, 2))
+ A[0][0] = -1
+ A.attach_grad()
+ with mx.autograd.record():
+ B = np.absolute(A)
+ assert B.shape == (INT_OVERFLOW, 2)
+ assert B[0][0] == 1
+ B.backward()
+ assert A.grad.shape == (INT_OVERFLOW, 2)
+ assert A.grad[0][0] == -1
+
+@use_np
[email protected](reason='backward errors out on (2^30,2), gives wrong result \
+ on (2^31, 2)')
+def test_add():
+ INT_OVERFLOW = 2**30
+ A = np.ones((INT_OVERFLOW, 2))
+ B = np.ones((INT_OVERFLOW, 2))
+ A.attach_grad()
+ with mx.autograd.record():
+ C = np.add(A, B)
+ assert C.shape == (INT_OVERFLOW, 2)
+ assert C[0][0] == 2
+ C.backward()
+ assert A.grad.shape == (INT_OVERFLOW, 2)
+ assert A.grad[0][0] == 1
+
+# this will fail; broadcast needs to be fixed
+# TODO add backward test after forward is fixed
+@use_np
[email protected](reason='Does not support large tensor; to be fixed')
+def test_add_broadcast():
+ A = np.ones((INT_OVERFLOW, 2))
+ B = np.ones((INT_OVERFLOW, 1))
+ C = np.add(A, B)
+ assert C.shape == (INT_OVERFLOW, 2)
+ assert C[0][0] == 2
+
+@use_np
+def test_all():
+ A = np.ones((INT_OVERFLOW, 2))
+ A.attach_grad()
+ with mx.autograd.record():
+ B = np.all(A)
+ assert B.asnumpy() == True
Review comment:
It is numpy compatible. This is probably left over from my previous
version. I removed `asnumpy()` locally and will probably include this fix in
the next pr
----------------------------------------------------------------
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]