Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

indexing op does not report out of bound indices #15933

Closed
eric-haibin-lin opened this issue Aug 16, 2019 · 3 comments
Closed

indexing op does not report out of bound indices #15933

eric-haibin-lin opened this issue Aug 16, 2019 · 3 comments

Comments

@eric-haibin-lin
Copy link
Member

out of bound error is reported in numpy:

>>> import numpy as np
>>> np.ones((1,))[[10]]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: index 10 is out of bounds for axis 0 with size 1
>>>

but MXNet does not:

>>> import mxnet as mx
>>> mx.nd.ones((1,))[[10]]
[6.4e-44]
<NDArray 1 @cpu(0)>

We can reuse the kernel in nd.take(mode='raise') to report such an error.

@reminisce @haojin2 @hhexiy

@mxnet-label-bot
Copy link
Contributor

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

@kshitij12345
Copy link
Contributor

@eric-haibin-lin ,

From a quick view,
take as of now doesn't actually support mode=raise,
https://github.com/apache/incubator-mxnet/blob/a8b9728d5729b565fdf2f588d1985bb5eca7f68a/src/operator/tensor/indexing_op.h#L671-L675

https://github.com/apache/incubator-mxnet/blob/a8b9728d5729b565fdf2f588d1985bb5eca7f68a/src/operator/tensor/indexing_op.h#L679-L709

So as of now, it doesn't actually raise out-of-bounds error.

@eric-haibin-lin
Copy link
Member Author

Raise mode added in #15887

@yzhliu yzhliu closed this as completed Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants