apeforest commented on a change in pull request #15170: [MXNET-1413] Adding
Large Tensor support for sort operators
URL: https://github.com/apache/incubator-mxnet/pull/15170#discussion_r296058604
##########
File path: tests/nightly/test_large_array.py
##########
@@ -326,6 +326,33 @@ def test_softmax():
assert_almost_equal(output.asnumpy(), true_output, rtol=1e-5, atol=1e-5)
+def test_argsort():
+ b = create_2d_tensor(rows=LARGE_X, columns=SMALL_Y)
+ s = nd.argsort(b, axis=0, is_ascend=False, dtype=np.int64)
+ mx.nd.waitall()
+ assert (s[0].asnumpy() == (LARGE_X - 1)).all()
+
+
+def test_sort():
+ b = create_2d_tensor(rows=LARGE_X, columns=SMALL_Y)
+ s = nd.sort(b, axis=0, is_ascend=False)
+ assert np.sum(s[-1][SMALL_Y//2:SMALL_Y].asnumpy() == 0).all()
+ s = nd.sort(b, is_ascend=False)
+ assert np.sum(s[0].asnumpy() == 0).all()
+
+
+def test_topk():
+ b = create_2d_tensor(rows=LARGE_X, columns=SMALL_Y)
+ k = nd.topk(b, k=10, axis=0, dtype=np.int64)
+ assert np.sum(k.asnumpy() == (LARGE_X - 1)) == SMALL_Y
+ b = create_2d_tensor(rows=SMALL_Y, columns=LARGE_X)
+ l = nd.topk(b, k=1, axis=-1, dtype=np.int64, ret_typ="value")
+ assert l.sum() == np.sum(np.arange(0, SMALL_Y))
+ b = create_2d_tensor(rows=LARGE_X, columns=SMALL_Y)
Review comment:
fine. don't need to do in this 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]
With regards,
Apache Git Services