apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.77k stars 6.79k forks source link

[MXNet] Operator _zeros inferring shapes failed #15766

Open giuseppedib opened 5 years ago

giuseppedib commented 5 years ago

Description

The definition of a mx.ndarray, with one of the dimensions set to zero, produces an error in mxnet v1.5.0, while it was working fine in mxnet v1.4.1 .

Environment info

----------Python Info----------
Version      : 3.7.3
Compiler     : Clang 4.0.1 (tags/RELEASE_401/final)
Build        : ('default', 'Mar 27 2019 16:54:48')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 19.2.1
Directory    : /anaconda3/lib/python3.7/site-packages/pip
----------MXNet Info-----------
Version      : 1.5.0
Directory    : /anaconda3/lib/python3.7/site-packages/mxnet
Commit Hash   : 75a9e187d00a8b7ebc71412a02ed0e3ae489d91f
Library      : ['/anaconda3/lib/python3.7/site-packages/mxnet/libmxnet.so']

Steps to reproduce

import mxnet as mx
p = mx.ndarray.zeros(shape=(3,0))

Error Message:

Traceback (most recent call last): File "", line 1, in File "/anaconda3/lib/python3.7/site-packages/mxnet/ndarray/utils.py", line 67, in zeros return _zeros_ndarray(shape, ctx, dtype, kwargs) File "/anaconda3/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py", line 3885, in zeros return _internal._zeros(shape=shape, ctx=ctx, dtype=dtype, kwargs) File "", line 34, in _zeros File "/anaconda3/lib/python3.7/site-packages/mxnet/_ctypes/ndarray.py", line 92, in _imperative_invoke ctypes.byref(out_stypes))) File "/anaconda3/lib/python3.7/site-packages/mxnet/base.py", line 253, in check_call raise MXNetError(py_str(_LIB.MXGetLastError())) mxnet.base.MXNetError: [16:54:11] src/imperative/./imperative_utils.h:145: Operator _zeros inferring shapes failed. input shapes: output shapes: [3,-1] operator attributes: dtype : float32 ctx : cpu(0) shape : (3, 0)

Stack trace: [bt] (0) 1 libmxnet.so 0x00000001133fc929 mxnet::op::NDArrayOpProp::~NDArrayOpProp() + 4473 [bt] (1) 2 libmxnet.so 0x000000011497bb1f 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) + 8767 [bt] (2) 3 libmxnet.so 0x000000011497883c 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&) + 716 [bt] (3) 4 libmxnet.so 0x00000001148be48e SetNDInputsOutputs(nnvm::Op const, std::1::vector<mxnet::NDArray*, std::1::allocator<mxnet::NDArray> >, std::1::vector<mxnet::NDArray*, std::1::allocator<mxnet::NDArray> >, int, void const, int*, int, int, void***) + 1582 [bt] (4) 5 libmxnet.so 0x00000001148bf1d0 MXImperativeInvokeEx + 176 [bt] (5) 6 libffi.6.dylib 0x000000010b722884 ffi_call_unix64 + 76

mxnet-label-bot commented 5 years ago

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: Bug

vdantu commented 5 years ago

@mxnet-label-bot add [Bug]

ifeherva commented 4 years ago

I can confirm the bug with version 1.5.1

sxjscience commented 4 years ago

@reminisce I think shape with 0s are generally not supported in the original ndarray interface. We will need to use the new numpy array in MXNet:

import mxnet as mx
mx.npx.set_np()
p = mx.np.zeros(shape=(3,0))