apeforest commented on a change in pull request #15048: [MXNET-1408] Adding 
test to verify Large Tensor Support for ravel and unravel
URL: https://github.com/apache/incubator-mxnet/pull/15048#discussion_r289494889
 
 

 ##########
 File path: tests/nightly/test_large_array.py
 ##########
 @@ -274,11 +265,26 @@ def test_diag():
     assert_almost_equal(r.asnumpy(), np.diag(a_np, k=k))
 
     # random k
-    k = np.random.randint(-min(LARGE_X, 64) + 1, min(h, w))
+    k = np.random.randint(-min(LARGE_X, SMALL_Y) + 1, min(LARGE_X, SMALL_Y))
     r = mx.nd.diag(a, k=k)
     assert_almost_equal(r.asnumpy(), np.diag(a_np, k=k))
 
 
+def test_ravel_multi_index():
+    indices_2d = [[LARGE_X-1, LARGE_X-100, 6], [SMALL_Y-1, SMALL_Y-10, 1]]
+    idx = mx.nd.ravel_multi_index(mx.nd.array(indices_2d, dtype=np.int64), 
shape=(LARGE_X, SMALL_Y))
+    idx_numpy = np.ravel_multi_index(indices_2d, (LARGE_X, SMALL_Y))
+    assert np.sum(1 for i in range(idx.size) if idx[i] == idx_numpy[i]) == 3
+
+
+def test_unravel_index():
+    original_2d_indices = [[LARGE_X-1, LARGE_X-100, 6], [SMALL_Y-1, 
SMALL_Y-10, 1]]
 
 Review comment:
   same here. can we generate random indices? you can pass in the 2d_array as 
input so you only keep one copy

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


With regards,
Apache Git Services

Reply via email to