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

MXNet Ndarray initialization with constant scalar inconsistencies #14227

Open
ChaiBapchya opened this issue Feb 22, 2019 · 6 comments
Open

MXNet Ndarray initialization with constant scalar inconsistencies #14227

ChaiBapchya opened this issue Feb 22, 2019 · 6 comments

Comments

@ChaiBapchya
Copy link
Contributor

Iniitializing MXNet NDArray with constant as a list
This is valid

>>> b=mx.nd.array([2**25])
>>> a=mx.nd.array([np.array(2**25)])
>>> a==b

[1.]
<NDArray 1 @cpu(0)>

Iniitializing MXNet NDArray with constant as a scalar
However, this is not. Gives an infershape error.

>>> a=mx.nd.array(np.array(2**25))
>>> b=mx.nd.array(2**25)
>>> a==b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chaitanyabapat/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 326, in __eq__
    return equal(self, other)
  File "/Users/chaitanyabapat/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 3182, in equal
    None)
  File "/Users/chaitanyabapat/workspace/incubator-mxnet/python/mxnet/ndarray/ndarray.py", line 2641, in _ufunc_helper
    return fn_array(lhs, rhs)
  File "<string>", line 46, in broadcast_equal
  File "/Users/chaitanyabapat/workspace/incubator-mxnet/python/mxnet/_ctypes/ndarray.py", line 92, in _imperative_invoke
    ctypes.byref(out_stypes)))
  File "/Users/chaitanyabapat/workspace/incubator-mxnet/python/mxnet/base.py", line 252, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [19:44:28] src/imperative/./imperative_utils.h:124: Check failed: infershape[attrs.op](attrs, &in_shapes, &out_shapes) 

Stack trace returned 8 entries:
[bt] (0) 0   libmxnet.so                         0x000000011327dced dmlc::StackTrace() + 877
[bt] (1) 1   libmxnet.so                         0x000000011327d845 dmlc::LogMessageFatal::~LogMessageFatal() + 53
[bt] (2) 2   libmxnet.so                         0x000000011327c285 dmlc::LogMessageFatal::~LogMessageFatal() + 21
[bt] (3) 3   libmxnet.so                         0x0000000116263d20 mxnet::imperative::SetShapeType(mxnet::Context const&, nnvm::NodeAttrs const&, std::__1::vector<mxnet::NDArray*, std::__1::allocator<mxnet::NDArray*> > const&, std::__1::vector<mxnet::NDArray*, std::__1::allocator<mxnet::NDArray*> > const&, mxnet::DispatchMode*) + 5024
[bt] (4) 4   libmxnet.so                         0x0000000116260d13 mxnet::Imperative::Invoke(mxnet::Context const&, nnvm::NodeAttrs const&, std::__1::vector<mxnet::NDArray*, std::__1::allocator<mxnet::NDArray*> > const&, std::__1::vector<mxnet::NDArray*, std::__1::allocator<mxnet::NDArray*> > const&) + 1491
[bt] (5) 5   libmxnet.so                         0x0000000115fc6136 MXImperativeInvokeImpl(void*, int, void**, int*, void***, int, char const**, char const**) + 854
[bt] (6) 6   libmxnet.so                         0x0000000115fc9712 MXImperativeInvokeEx + 178
[bt] (7) 7   libffi.6.dylib                      0x000000010e661884 ffi_call_unix64 + 76

PR #12678 provided support for importing numpy scalar
Might be of use

@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Feature

@frankfliu
Copy link
Contributor

@mxnet-label-bot add [Feature request]

@ChaiBapchya
Copy link
Contributor Author

@frankfliu Don't think this is a feature request per se. I am highlighting a bug or a possible question (would like some to verify if my doubts are valid)

@ChaiBapchya
Copy link
Contributor Author

@mxnet-label-bot update [Bug, Operator]

@ifeherva
Copy link
Contributor

The bug seems to be related to the operator returning ndarrays with 0 shape

@ifeherva
Copy link
Contributor

Considering there is work going on on adding zero-shape support, is there a need to fix this? If yes, I can do it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants