yuxiangw opened a new issue #12389: [Bug] Not able to detect out of bound index 
on an ndarray. potential memory overflow.
URL: https://github.com/apache/incubator-mxnet/issues/12389
 
 
   
   ## Minimum reproducible example
   
   '''
   from mxnet import ndarray as nd
   import numpy as np
   # Declare an mxnet ndarray
   x = nd.array(range(5))
   print(x)
   
   # Try an out of bound index 
   idx = [5]
   print('mxnet:',x[idx])
   '''
   
   ## Output:
   '''
   [0. 1. 2. 3. 4.]
   <NDArray 5 @cpu(0)>
   mxnet: 
   [-3.689349e+19]
   <NDArray 1 @cpu(0)>
   '''
   
   Note that there is no complaint what-so-ever.  Not even a warning.
   
   On the other hand, if you do the following instead:
   '''
   # indexing with integer
   idx=5
   x[idx]
   ''' 
   Then you get the desired error message:
   '''
   IndexError: index 5 is out of bounds for axis 0 with size 5
   '''

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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