[MXNET-1401] adding more operators to test support for Large Tensor#14944
[MXNET-1401] adding more operators to test support for Large Tensor#14944apeforest merged 1 commit intoapache:masterfrom
Conversation
|
@mxnet-label-bot add [pr-work-in-progress] |
|
@mxnet-label-bot add [pr-awaiting-review] |
|
@apeforest please review |
| SMALL_Y = 50 | ||
| LARGE_SIZE = LARGE_X * SMALL_Y | ||
|
|
||
|
|
There was a problem hiding this comment.
keep it. It's Pep8 style
There was a problem hiding this comment.
Sure! Are you referring to this: https://www.python.org/dev/peps/pep-0008/#blank-lines
Please verify.
| assert b.shape == (MEDIUM_X, SMALL_Y, MEDIUM_X) | ||
| assert b.asnumpy().size == LARGE_SIZE | ||
|
|
||
|
|
There was a problem hiding this comment.
keep it. It's Pep8 style
| assert a.shape == (LARGE_X, SMALL_Y) | ||
| assert a.size == LARGE_SIZE | ||
|
|
||
|
|
There was a problem hiding this comment.
keep it. It's Pep8 style
tests/nightly/test_large_array.py
Outdated
|
|
||
|
|
||
| def test_argmin(): | ||
| a = nd.arange(0, LARGE_X).reshape(LARGE_X, 1) |
There was a problem hiding this comment.
Why do we need to broadcast? Can we just create a super long array and perform argmin?
tests/nightly/test_large_array.py
Outdated
|
|
||
| def test_take(): | ||
| a = nd.ones(shape=(LARGE_X, SMALL_Y)) | ||
| idx = nd.arange(LARGE_X-1000, LARGE_X) |
There was a problem hiding this comment.
add space between LARGE_X and -
|
|
||
|
|
||
| def test_diag(): | ||
| h = np.random.randint(2,9) |
There was a problem hiding this comment.
why use randint? Can we just use deterministic values to test diag?
There was a problem hiding this comment.
@apeforest : using random values is better since we are checking diagonal. Having different values actually ensures that the operation is performed correctly. Checking just the shape is fine but this ensures total correctness. I think if we can perform this check then it ensures total correctness
26f85d3 to
41df5d6
Compare
tests/nightly/test_large_array.py
Outdated
| a = nd.arange(0, LARGE_X * SMALL_Y).reshape(LARGE_X, SMALL_Y) | ||
| outs = nd.split(a, num_outputs=SMALL_Y, axis=1) | ||
| sum = 0 | ||
| for i, out in enumerate(outs): |
There was a problem hiding this comment.
You may make this more pythonic:
| for i, out in enumerate(outs): | |
| result = sum(1 for i, v in enumerate(outs) if i == v) |
You also need to convert outs into outs.asnumpy() first in the line above.
| def test_diag(): | ||
| h = np.random.randint(2,9) | ||
| w = np.random.randint(2,9) | ||
| a_np = np.random.random((LARGE_X, 64)).astype(np.float32) |
There was a problem hiding this comment.
Why do you need to convert to np.float32 explicitly here?
There was a problem hiding this comment.
@apeforest by default np.random.random((LARGE_X, 64)) makes it float64 by default.
x = np.random.random((50000000, 64))
x
array([[0.77259927, 0.17861939, 0.73446367, ..., 0.61712618, 0.00411382,
0.80232583],
[0.99131563, 0.29269588, 0.34078989, ..., 0.14693316, 0.68376766,
0.13507782],
[0.26176515, 0.54208053, 0.42594753, ..., 0.76032471, 0.30179728,
0.83745653],
...,
[0.45731445, 0.84679834, 0.02738181, ..., 0.27567623, 0.94721731,
0.77850831],
[0.65551258, 0.92503922, 0.43253718, ..., 0.23874736, 0.55155928,
0.33177961],
[0.95565209, 0.86454407, 0.75257631, ..., 0.31738383, 0.90281116,
0.93569039]])
x.dtype
dtype('float64')
I am trying to keep it consistent with: https://github.com/apache/incubator-mxnet/blob/f680255fbff25818ed3eee0d4541d80b3c7b9d9d/tests/python/unittest/test_operator.py#L8029
So, I think float32 is required here.
There was a problem hiding this comment.
ok. mx.nd.array(a_np) is float32 by default.
y = mx.nd.array(x)
y.dtype
<class 'numpy.float32'>
I will remove astype('float32') from next line
tests/nightly/test_large_array.py
Outdated
| 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)) |
There was a problem hiding this comment.
nit: add space after comma
tests/nightly/test_large_array.py
Outdated
| 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)) |
There was a problem hiding this comment.
nit: same between h and w
Description
Test to check support for operators: tostype, split, argmin, tile, take and diag
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.