You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/07/09 18:56:49 UTC

[GitHub] [incubator-mxnet] AustinDoolittle opened a new issue #18681: Infer Shape Fails for empty NDArrays

AustinDoolittle opened a new issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681


   ## Description
   When trying to move a tensor of size 0 to a different context than the context that it is currently on, an "inferring shapes failed" error is raised. This occurs for tensors regardless of the number of dimensions they contain. It seems that inferring the shape of an empty NDArray is not currently possible.
   
   ### Error Message
   ```
   Traceback (most recent call last):
     File "<redacted>/recreate_shape_bug.py", line 7, in <module>
       new_array = empty_array.as_in_context(mx.cpu())
     File "<redacted>/python3.6/site-packages/mxnet/ndarray/ndarray.py", line 2144, in as_in_context
       return self.copyto(context)
     File "<redacted>/python3.6/site-packages/mxnet/ndarray/ndarray.py", line 2093, in copyto
       return _internal._copyto(self, out=hret)
     File "<string>", line 25, in _copyto
     File "<redacted>/python3.6/site-packages/mxnet/_ctypes/ndarray.py", line 92, in _imperative_invoke
       ctypes.byref(out_stypes)))
     File "<redacted>/python3.6/site-packages/mxnet/base.py", line 253, in check_call
       raise MXNetError(py_str(_LIB.MXGetLastError()))
   mxnet.base.MXNetError: [18:43:30] <redacted>/src/imperative/./imperative_utils.h:145: Operator _copyto inferring shapes failed.
   input shapes:
   [-1]
   output shapes:
   [-1]
   operator attributes:
   
   Stack trace:
     [bt] (0) <redacted>/lib/libmxnet.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x24) [0x7fe5f79ba534]
     [bt] (1) <redacted>/lib/libmxnet.so(mxnet::imperative::SetShapeType(mxnet::Context const&, nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, mxnet::DispatchMode*)+0x1dd5) [0x7fe5f983c1e5]
     [bt] (2) <redacted>/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&)+0x297) [0x7fe5f98300c7]
     [bt] (3) <redacted>/lib/libmxnet.so(MXImperativeInvokeImpl(void*, int, void**, int*, void***, int, char const**, char const**)+0x5e5) [0x7fe5f973c995]
     [bt] (4) <redacted>/lib/libmxnet.so(MXImperativeInvokeEx+0x67) [0x7fe5f973dd27]
     [bt] (5) <redacted>/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7fe622ba3ef8]
     [bt] (6) <redacted>/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(ffi_call+0x15f) [0x7fe622ba2fff]
     [bt] (7) <redacted>/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(_ctypes_callproc+0x292) [0x7fe622b9ae02]
     [bt] (8) <redacted>/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(+0xa08b) [0x7fe622b9208b]
   ```
   
   ## To Reproduce
   Code to reproduce is as follows
   ```
   import mxnet as mx
   
   empty_array = mx.nd.array([], ctx=mx.Context('cpu_shared', 0))
   new_array = empty_array.as_in_context(mx.cpu())
   ```
   
   ### Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1. Run above code as-is 
   
   ## What have you tried to solve it?
   
   1. Attempted with tensors of >1 dimension, but got the same result.
   
   ## Environment
   Python: 3.6.10
   MXNet: 1.6.1
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on issue #18681: Infer Shape Fails for empty NDArrays

Posted by GitBox <gi...@apache.org>.
szha commented on issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681#issuecomment-656296552


   @AustinDoolittle zero size array support is not available by default and needs to be turned on manually. If you turn on `mx.set_np_shape(True)` does it resolve the issue?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-mxnet] leezu commented on issue #18681: Infer Shape Fails for empty NDArrays

Posted by GitBox <gi...@apache.org>.
leezu commented on issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681#issuecomment-656317619


   > Just out of curiosity, will the np_shape approach be the default in the future? Or will this continue to be opt-in only?
   
   Numpy compatible mode will be default (and the only supported way) in MXNet 2


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-mxnet] AustinDoolittle commented on issue #18681: Infer Shape Fails for empty NDArrays

Posted by GitBox <gi...@apache.org>.
AustinDoolittle commented on issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681#issuecomment-656337307


   > You can try and mark the part of code that requires zero-size/zero-dim array with the decorator `@mx.use_np_shape` and it will only take effect for that part of code.
   
   This works, I'll run with this for now. Since this is expected behavior, I'll close out the ticket. Thanks Sheng and Leonard for the quick help and useful information :)


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-mxnet] AustinDoolittle commented on issue #18681: Infer Shape Fails for empty NDArrays

Posted by GitBox <gi...@apache.org>.
AustinDoolittle commented on issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681#issuecomment-656303642


   That does appear to resolve the issue as reported. Unfortunately that will break quite a bit of our existing code. We'll look into some temporary workarounds. Just out of curiosity, will the np_shape approach be the default in the future? Or will this continue to be opt-in only?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-mxnet] AustinDoolittle closed issue #18681: Infer Shape Fails for empty NDArrays

Posted by GitBox <gi...@apache.org>.
AustinDoolittle closed issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on issue #18681: Infer Shape Fails for empty NDArrays

Posted by GitBox <gi...@apache.org>.
szha commented on issue #18681:
URL: https://github.com/apache/incubator-mxnet/issues/18681#issuecomment-656311424


   You can try and mark the part of code that requires zero-size/zero-dim array with the decorator `@mx.use_np_shape` and it will only take effect for that part of code.


----------------------------------------------------------------
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:
users@infra.apache.org