leezu opened a new issue #19170:
URL: https://github.com/apache/incubator-mxnet/issues/19170


   ## Description
   MXNet array indexing will only match numpy memory sharing in a few cases.
   
   ## To Reproduce
   Simple slice; mxnet matches numpy
   
   ``` python
   a = mx.np.ones((10,))
   b = a[:5]
   a[:] = 0
   print(a, b)  # [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.]
   ```
   
   Slice with step; mxnet diverges
   
   ``` python
   a = mx.np.ones((10,))
   b = a[:5:2]
   a[:] = 0
   print(a, b)  # [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] [1. 1. 1.]
   ```
   as numpy still shares memory between the arrays:
   
   ``` python
   a = np.ones((10,))
   b = a[:5:2]
   a[:] = 0
   print(a, b)  # [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] [0. 0. 0.]
   ```
   


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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to