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

adding error message when attempting to use Large tensor with linalg_syevd #18807

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/operator/tensor/la_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ inline bool LaEigFactShape(const nnvm::NodeAttrs& attrs,
const mxnet::TShape& in_a = (*in_attrs)[0];
const mxnet::TShape& out_u = (*out_attrs)[0];
const mxnet::TShape& out_l = (*out_attrs)[1];
CHECK_LE(in_a.Size(), INT_MAX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you include climit ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is included in base.h

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to be explicit about your dependencies.

"Avoid surprises. Avoid having to change #includes if an #included header changes. Avoid accidentally becoming dependent on implementation details and logically separate entities included in a header."

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rs-implicit

<< "Large tensors are not supported by Linear Algebra operator syevd";
if ( in_a.ndim() >= 2 ) {
// Forward shape inference.
const int ndim(in_a.ndim());
Expand Down
13 changes: 12 additions & 1 deletion tests/nightly/test_large_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

from mxnet.test_utils import rand_ndarray, assert_almost_equal, rand_coord_2d, default_context, check_symbolic_forward, create_2d_tensor, get_identity_mat, get_identity_mat_batch
from mxnet import gluon, nd
from common import with_seed, with_post_test_cleanup
from common import with_seed, with_post_test_cleanup, assertRaises
from mxnet.base import MXNetError
from nose.tools import with_setup
import unittest

Expand Down Expand Up @@ -1352,6 +1353,16 @@ def run_trsm(inp):
check_batch_trsm()


def test_linalg_errors():
def check_syevd_error():
A = get_identity_mat(LARGE_SQ_X)
for i in range(LARGE_SQ_X):
A[i,i] = 1
assertRaises(MXNetError, mx.nd.linalg.syevd, A)

This comment was marked as outdated.


check_syevd_error()


def test_basic():
def check_elementwise():
a = nd.ones(shape=(LARGE_X, SMALL_Y))
Expand Down