Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 7c915e3

Browse files
author
Rohit Kumar Srivastava
committed
[MXNET-1408] Adding test to verify Large Tensor Support for ravel and unravel
1 parent 66aa983 commit 7c915e3

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

3rdparty/dmlc-core

3rdparty/tvm

Submodule tvm updated from 21935dc to 8518c7d

tests/nightly/test_large_array.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,19 @@ def test_diag():
279279
assert_almost_equal(r.asnumpy(), np.diag(a_np, k=k))
280280

281281

282+
def test_ravel_and_unravel():
283+
idxs_2d = [[LARGE_X-1,LARGE_X-100,6],[SMALL_Y-1,SMALL_Y-10,1]]
284+
idx = mx.nd.array(1)
285+
def test_ravel_multi_index():
286+
idx = mx.nd.ravel_multi_index(mx.nd.array(idxs_2d, dtype=np.int64), shape=(LARGE_X,SMALL_Y))
287+
idx_numpy = np.ravel_multi_index(idxs_2d, (LARGE_X,SMALL_Y))
288+
assert np.sum(1 for i in range(idx.size) if idx[i] == idx_numpy[i]) == 3
289+
290+
def test_unravel_index():
291+
original_2d_idxs = mx.nd.unravel_index(mx.nd.array(idx, dtype=np.int64), shape=(LARGE_X,SMALL_Y))
292+
assert (original_2d_idxs.asnumpy() == np.array(idxs_2d)).all()
293+
294+
282295
if __name__ == '__main__':
283296
import nose
284297
nose.runmodule()

0 commit comments

Comments
 (0)