xidulu opened a new issue #17744: [Numpy] Indexing high-dimensional data raises 
exception
URL: https://github.com/apache/incubator-mxnet/issues/17744
 
 
   ```python
   n = 16
   W = np.random.rand(16, 16)
   b = np.random.rand(16,)
   log_potentials = np.zeros([2]*n)
   for state in itertools.product([0, 1], repeat=n):
       state_ind = np.array(state)
       state_val = 2 * state_ind - 1
       log_potentials[state] = state_val.dot(W.dot(state_val)) + 
b.dot(state_val)
   print(log_potentials)
   ```
   
   would  raise
   
   ```python
   ---------------------------------------------------------------------------
   MXNetError                                Traceback (most recent call last)
   <ipython-input-318-01383abd1f85> in <module>
         6     state_ind = np.array(state)
         7     state_val = 2 * state_ind - 1
   ----> 8     log_potentials[state] = state_val.dot(W.dot(state_val)) + 
b.dot(state_val)
         9 print(log_potentials)
   
   ~/mxnet_master_develop/python/mxnet/numpy/multiarray.py in __setitem__(self, 
key, value)
       818             indexing_dispatch_code = 
get_indexing_dispatch_code(slc_key)
       819             if indexing_dispatch_code == _NDARRAY_BASIC_INDEXING:
   --> 820                 self._set_nd_basic_indexing(key, value)  # function 
is inheritated from NDArray class
       821             elif indexing_dispatch_code == 
_NDARRAY_EMPTY_TUPLE_INDEXING:
       822                 pass # no action needed
   
   ~/mxnet_master_develop/python/mxnet/ndarray/ndarray.py in 
_set_nd_basic_indexing(self, key, value)
      1000             value_nd = self._prepare_value_nd(value, 
bcast_shape=bcast_shape, squeeze_axes=new_axes)
      1001             value_nd = value_nd.reshape(indexed_shape)
   -> 1002             self.slice_assign(value_nd, begin, end, step)
      1003 
      1004     def _get_nd_basic_indexing(self, key):
   
   ~/mxnet_master_develop/python/mxnet/numpy/multiarray.py in 
slice_assign(self, rhs, begin, end, step)
      1643                 [1., 1.]]])
      1644         """
   -> 1645         return _npi.slice_assign(self, rhs, begin=begin, end=end, 
step=step, out=self)
      1646 
      1647     def take(self, indices, axis=None, mode='raise'):  # pylint: 
disable=arguments-differ, redefined-outer-name
   
   ~/mxnet_master_develop/python/mxnet/ndarray/register.py in slice_assign(lhs, 
rhs, begin, end, step, out, name, **kwargs)
   
   ~/mxnet_master_develop/python/mxnet/_ctypes/ndarray.py in 
_imperative_invoke(handle, ndargs, keys, vals, out, is_np_op, output_is_list)
        89         c_str_array(keys),
        90         c_str_array([str(s) for s in vals]),
   ---> 91         ctypes.byref(out_stypes)))
        92 
        93     create_ndarray_fn = _global_var._np_ndarray_cls if is_np_op else 
_global_var._ndarray_cls
   
   ~/mxnet_master_develop/python/mxnet/base.py in check_call(ret)
       244     """
       245     if ret != 0:
   --> 246         raise get_last_ffi_error()
       247 
       248 
   
   MXNetError: Traceback (most recent call last):
     [bt] (5) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(MXImperativeInvokeEx+0x8b)
 [0x7f756303e80b]
     [bt] (4) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(MXImperativeInvokeImpl(void*,
 int, void**, int*, void***, int, char const**, char const**)+0x652) 
[0x7f756303e112]
     [bt] (3) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/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&)+0x23a) [0x7f75631daf0a]
     [bt] (2) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/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*)+0x2c5) 
[0x7f75631e23a5]
     [bt] (1) 
/home/ubuntu/mxnet_master_develop/python/mxnet/../../build/libmxnet.so(mxnet::op::SliceAssignOpShape(nnvm::NodeAttrs
 const&, std::vector<mxnet::TShape, std::allocator<mxnet::TShape> >*, 
std::vector<mxnet::TShape, std::allocator<mxnet::TShape> >*)+0x381) 
[0x7f7566fd5241]
     [bt] (0) 
/home/ubuntu/anaconda3/lib/python3.7/site-packages/dgl/libdgl.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x22)
 [0x7f75a5469f42]
     File "../src/operator/tensor/./matrix_op-inl.h", line 1100
   MXNetError: ndim=16too large 
   
   ```

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