You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
Setting a range in an NDArray using a Python list fails with an obscure error about broadcasting when the range to set values in is equal to the size of the respective dimension in the target array.
Bug occurs in latest master (not in MXNet 1.5.1).
When another NDArray is used as data source, no error is thrown.
Error Message
ValueError Traceback (most recent call last)
<ipython-input-32-7d7d8c3fa8f4> in <module>
----> 1 dst[0, :len(src), 0] = src
~/anaconda3/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in __setitem__(self, key, value)
523 indexing_dispatch_code = get_indexing_dispatch_code(slc_key)
524 if indexing_dispatch_code == _NDARRAY_BASIC_INDEXING:
--> 525 self._set_nd_basic_indexing(key, value)
526 elif indexing_dispatch_code == _NDARRAY_ADVANCED_INDEXING:
527 self._set_nd_advanced_indexing(key, value)
~/anaconda3/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in _set_nd_basic_indexing(self, key, value)
958 # Other array-like
959 value_nd = self._prepare_value_nd(
--> 960 value, bcast_shape=self.shape
961 )
962 value_nd.copyto(self)
~/anaconda3/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in _prepare_value_nd(self, value, bcast_shape, squeeze_axes)
755 value_nd = value_nd.reshape(bcast_shape)
756 else:
--> 757 value_nd = value_nd.broadcast_to(bcast_shape)
758 return value_nd
759
~/anaconda3/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in broadcast_to(self, shape)
2275 broadcasting_axes = np.nonzero(cur_shape_arr != np.array(shape))
2276 if (cur_shape_arr[broadcasting_axes] != 1).any():
-> 2277 raise ValueError(err_str)
2278 if cur_shape != self.shape:
2279 return op.broadcast_to(self.reshape(cur_shape), shape=shape)
ValueError: operands could not be broadcast together with remapped shapes[original->remapped]: (3,) and requested shape (1, 3, 1)
Description
Setting a range in an NDArray using a Python list fails with an obscure error about broadcasting when the range to set values in is equal to the size of the respective dimension in the target array.
Bug occurs in latest master (not in MXNet 1.5.1).
When another NDArray is used as data source, no error is thrown.
Error Message
To Reproduce
Using an NDArray as source data works
And also any range that is
< dim2
ofdst
Environment
The text was updated successfully, but these errors were encountered: