access2rohit commented on a change in pull request #16476: added large tensor support for add_n and tests for more ops URL: https://github.com/apache/incubator-mxnet/pull/16476#discussion_r336134272
########## File path: tests/nightly/test_large_array.py ########## @@ -1199,6 +1200,57 @@ def test_full(): assert a[-1][-1] == 3 +def test_load_save(): + x = create_2d_tensor(SMALL_Y, LARGE_X) + nd.save('large_tensor', [x]) + y = nd.load('large_tensor') + y = y[0] + assert x[0][0] == y[0][0] + assert x[-1][-1]== y[-1][-1] + os.remove('large_tensor') + + +def test_add_n(): + x = [nd.ones(LARGE_X) for j in range(SMALL_Y)] + y = nd.add_n(*x) + assert y[0] == SMALL_Y + assert y[-1] == SMALL_Y + + +def test_modulo(): + x = mx.nd.ones((SMALL_Y, LARGE_X))*6 + y = mx.nd.ones(LARGE_X)*4 + z = (x%y) + assert z[0][0] == 2 + assert z[-1][-1] == 2 + x = mx.nd.ones((SMALL_Y, LARGE_X))*5 + z = nd.modulo(x,y) + assert z[0][0] == 1 + assert z[-1][-1] == 1 + + +def test_maximum(): + x = mx.nd.ones((SMALL_Y, LARGE_X))*3 Review comment: @ChaiBapchya Did you know this works or not? https://mxnet.apache.org/api/python/docs/api/ndarray/ndarray.html#mxnet.ndarray.ones gives the following error: ` >>> x = mx.nd.ones(2, 1)*3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/ubuntu/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 3162, in ones return _internal._ones(shape=shape, ctx=ctx, dtype=dtype, **kwargs) File "<string>", line 36, in _ones File "/home/ubuntu/incubator-mxnet/python/mxnet/_ctypes/ndarray.py", line 107, in _imperative_invoke ctypes.byref(out_stypes))) File "/home/ubuntu/incubator-mxnet/python/mxnet/base.py", line 254, in check_call raise MXNetError(py_str(_LIB.MXGetLastError())) mxnet.base.MXNetError: [17:31:04] include/mxnet/./base.h:526: Invalid context string 1 Stack trace: [bt] (0) /home/ubuntu/incubator-mxnet/python/mxnet/../../lib/libmxnet.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x34) [0x7f3f4fe284c6] [bt] (1) /home/ubuntu/incubator-mxnet/python/mxnet/../../lib/libmxnet.so(mxnet::Context::FromString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x4d9) [0x7f3f545699c9] [bt] (2) /home/ubuntu/incubator-mxnet/python/mxnet/../../lib/libmxnet.so(mxnet::imperative::GetContext(nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, mxnet::Context const&)+0x414) [0x7f3f54569e1d] [bt] (3) /home/ubuntu/incubator-mxnet/python/mxnet/../../lib/libmxnet.so(mxnet::Imperative::Invoke(mxnet::Context const&, nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&)+0x250) [0x7f3f5457030c] [bt] (4) /home/ubuntu/incubator-mxnet/python/mxnet/../../lib/libmxnet.so(MXImperativeInvokeImpl(void*, int, void**, int*, void***, int, char const**, char const**)+0x195) [0x7f3f54eedf89] [bt] (5) /home/ubuntu/incubator-mxnet/python/mxnet/../../lib/libmxnet.so(MXImperativeInvokeEx+0x87) [0x7f3f54eee2fa] [bt] (6) /home/ubuntu/anaconda3/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7f3f5dedbec0] [bt] (7) /home/ubuntu/anaconda3/lib/python3.6/lib-dynload/../../libffi.so.6(ffi_call+0x22d) [0x7f3f5dedb87d] [bt] (8) /home/ubuntu/anaconda3/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(_ctypes_callproc+0x2ce) [0x7f3f5e0f0dee] ` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services