-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-1410]Adding Large Tensor Support for tensor transpose #15059
Conversation
@mxnet-label-bot add [pr-work-in-progress] |
1976567
to
cc20e34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/operator/tensor/matrix_op-inl.h
Outdated
@@ -1950,7 +1950,7 @@ struct ReverseParam : public dmlc::Parameter<ReverseParam> { | |||
#define REVERSE_MAX_DIM 10U | |||
|
|||
struct reverse { | |||
MSHADOW_XINLINE static int ReverseIndex(index_t idx, | |||
MSHADOW_XINLINE static index_t ReverseIndex(index_t idx, | |||
index_t nreversedim, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad .. will fix it
t = b.T | ||
assert t.shape == (SMALL_Y, LARGE_X) | ||
assert np.sum(t[:,-1].asnumpy() == LARGE_X) == b.shape[1] | ||
t = nd.swapaxes(b, dim1=0, dim2=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test transpose
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are 3 different transpose operations all three are tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought transpose
is a operator name? If you are testing swapaxes
, maybe change the test name as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flip(), swapaxes() and b.T are all transpose operations
t = nd.swapaxes(b, dim1=0, dim2=1) | ||
assert t.shape == (SMALL_Y, LARGE_X) | ||
assert np.sum(t[:,-1].asnumpy() == LARGE_X) == b.shape[1] | ||
t = nd.flip(b, axis=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test this operator in separate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try test operator invidually to avoid collateral failures.
d5443f0
to
e678461
Compare
tests/nightly/test_large_array.py
Outdated
@@ -279,6 +279,33 @@ def test_diag(): | |||
assert_almost_equal(r.asnumpy(), np.diag(a_np, k=k)) | |||
|
|||
|
|||
def create_large_tensor(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this method more generic, so user can pass in values to create tensors with different dimension? Also, if it is limited to a 2D tensor, maybe you want to rename the method too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is currently generic to 2D tensor. Can be used for other tests will update that in a separate PR. Apart from this do you think its good to go ?
e678461
to
2e1bd4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0ff8c43
to
791db77
Compare
@access2rohit @apeforest this is causing nightly to fail on test large tensors |
Description
Adds tests for tensor transpose
Fix operators: flip
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.