samskalicky opened a new issue #20422:
URL: https://github.com/apache/incubator-mxnet/issues/20422
## Description
it looks like there is a change in how slicing works since 1.4.1 (where it
worked correctly) to newer versions (errors out in 1.5, but succeeds and
returns weird results in 1.6)
in 1.4.1 slicing returns:
```
[[0. 0. 0. 0. 0. 0. 0. 0. 1. 0.]
[0. 0. 0. 1. 0. 0. 0. 0. 0. 0.]
[1. 0. 0. 0. 0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 1. 0.]
[0. 1. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 1. 0. 0. 0.]
[1. 0. 1. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]
[0. 0. 0. 0. 0. 1. 0. 0. 0. 0.]]
<NDArray 10x10 @cpu(0)>
<CSRNDArray 10x10 @cpu(0)>
```
and in 1.5.0 & 1.5.1 it throws this error:
```
Traceback (most recent call last):
File "test.py", line 30, in <module>
a = arr.slice(begin=(0,0), end=(10,0))
File "/home/ubuntu/mxnet2/python/mxnet/ndarray/ndarray.py", line 1148, in
slice
return op.slice(self, *args, **kwargs)
File "<string>", line 86, in slice
File "/home/ubuntu/mxnet2/python/mxnet/_ctypes/ndarray.py", line 92, in
_imperative_invoke
ctypes.byref(out_stypes)))
File "/home/ubuntu/mxnet2/python/mxnet/base.py", line 253, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [19:46:49] src/operator/tensor/./matrix_op-inl.h:701:
Check failed: b != e (0 vs. 0) : slicing with begin[1]=end[1]=0 results in an
empty tensor and is not supported
```
but in 1.6.0 slicing returns:
```
[]
<NDArray 10x0 @cpu(0)>
<CSRNDArray 10x0 @cpu(0)>
```
## To Reproduce
```
import mxnet as mx
data = [[0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
[1, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 1],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0]]
arr = mx.nd.array(data)
print(arr)
csr = arr.tostype('csr')
print(csr)
a = arr.slice(begin=(0,0), end=(10,0))
b = csr.slice(begin=(0,0), end=(10,0))
print(a)
print(b)
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]