xidulu opened a new issue #16937: [Numpy] Zero-size tensor add zero-size sum 
raises exception
URL: https://github.com/apache/incubator-mxnet/issues/16937
 
 
   ## Description
   
   Very weird problem:
   
   
   ```python
   npx.set_np()
   a = np.ones((3,4))
   b = np.ones((3,3,4))
   a[:, :0] += b[:, :0].sum(-1)
   print(a)
   ```
   
   ```python
   MXNetError                                Traceback (most recent call last)
   <ipython-input-57-ed8f66a38679> in <module>
         2 b = np.ones((3,3,4))
         3 a[:, :0] += b[:, :0].sum(-1)
   ----> 4 print(a)
   
   ~/mxnet_master_develop/python/mxnet/numpy/multiarray.py in __str__(self)
       929     def __str__(self):
       930         """Returns a string representation of the array."""
   --> 931         array_str = self.asnumpy().__str__()
       932         context = self.ctx
       933         if context.device_type == 'cpu' or self.ndim == 0:
   
   ~/mxnet_master_develop/python/mxnet/ndarray/ndarray.py in asnumpy(self)
      2550             self.handle,
      2551             data.ctypes.data_as(ctypes.c_void_p),
   -> 2552             ctypes.c_size_t(data.size)))
      2553         return data
      2554 
   
   ~/mxnet_master_develop/python/mxnet/base.py in check_call(ret)
       276     """
       277     if ret != 0:
   --> 278         raise MXNetError(py_str(_LIB.MXGetLastError()))
       279 
       280 
   
   MXNetError: [10:12:44] 
/home/ubuntu/mxnet_master_develop/include/mxnet/././tensor_blob.h:198: Check 
failed: this->shape_.Size() == shape.Size() (0 vs. 1) : Shape size mismatch 0 
v.s. 1
   Stack trace:
     [bt] (0) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x32)
 [0x7fc85352bd52]
     [bt] (1) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(mxnet::TBlob::reshape(mxnet::TShape
 const&) const+0x140) [0x7fc8539d1570]
     [bt] (2) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(void 
mxnet::op::ReduceAxesComputeImpl<mshadow::cpu, mxnet::op::mshadow_op::sum, 
false, false, mxnet::op::mshadow_op::identity>(mxnet::OpContext const&, 
std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&, 
std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, 
std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&, mxnet::TShape 
const&)+0x2255) [0x7fc85695c105]
     [bt] (3) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(void 
mxnet::op::NumpyReduceAxesCompute<mshadow::cpu, mxnet::op::mshadow_op::sum, 
true, false, mxnet::op::mshadow_op::identity>(nnvm::NodeAttrs const&, 
mxnet::OpContext const&, std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> 
> const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > 
const&, std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&)+0x239) 
[0x7fc8569af0e9]
     [bt] (4) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(mxnet::imperative::PushFCompute(std::function<void
 (nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::TBlob, 
std::allocator<mxnet::TBlob> > const&, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::TBlob, 
std::allocator<mxnet::TBlob> > const&)> const&, nnvm::Op const*, 
nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, 
std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<unsigned int, 
std::allocator<unsigned int> > const&, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> > 
const&)::{lambda(mxnet::RunContext)#1}::operator()(mxnet::RunContext) 
const+0x2a6) [0x7fc855ff97f6]
     [bt] (5) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(std::_Function_handler<void
 (mxnet::RunContext), mxnet::imperative::PushFCompute(std::function<void 
(nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::TBlob, 
std::allocator<mxnet::TBlob> > const&, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::TBlob, 
std::allocator<mxnet::TBlob> > const&)> const&, nnvm::Op const*, 
nnvm::NodeAttrs const&, mxnet::Context const&, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> > const&, std::vector<mxnet::Resource, 
std::allocator<mxnet::Resource> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<unsigned int, 
std::allocator<unsigned int> > const&, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> > 
const&)::{lambda(mxnet::RunContext)#1}>::_M_invoke(std::_Any_data const&, 
mxnet::RunContext&&)+0x17) [0x7fc855ff9a47]
     [bt] (6) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(+0x413328e)
 [0x7fc855f2f28e]
     [bt] (7) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(mxnet::engine::ThreadedEngine::ExecuteOprBlock(mxnet::RunContext,
 mxnet::engine::OprBlock*)+0x5cf) [0x7fc855f3b4cf]
     [bt] (8) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(std::_Function_handler<void
 (std::shared_ptr<dmlc::ManualEvent>), 
mxnet::engine::ThreadedEnginePerDevice::PushToExecute(mxnet::engine::OprBlock*, 
bool)::{lambda()#1}::operator()() 
const::{lambda(std::shared_ptr<dmlc::ManualEvent>)#1}>::_M_invoke(std::_Any_data
 const&, std::shared_ptr<dmlc::ManualEvent>&&)+0x118) [0x7fc855f3ea98]
   
   ```
   
   
   
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to