You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2022/03/18 05:29:13 UTC

[GitHub] [incubator-mxnet] DickJC123 opened a new issue #20968: mxnet.numpy and original numpy differ on bitwise right shift of uint64 types

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


   ## Description
   This difference was flagged by the array api tests, so it's likely that mxnet.numpy is not producing the correct value.  Test failure log is: https://jenkins.mxnet-ci.com/blue/organizations/jenkins/mxnet-validation%2Funix-cpu/detail/PR-20957/3/pipeline/286/#step-438-log-636
   
   When mxnet.numpy does a right shift on a uint64 type, if uses a low level instruction that duplicates the most significant bit (i.e. an arithmetic right shift).  The simplest example showing the issue involves a right shift by 1 of 2**63 (a value with just the most significant bit set):
   
   ```
   $python
   >>> import mxnet.numpy as mxnp
   >>> import numpy as np
   >>> 2**63
   9223372036854775808
   >>> bin(2**63)
   '0b1000000000000000000000000000000000000000000000000000000000000000'
   >>> 2**63 >> 1
   4611686018427387904
   >>> np.right_shift(np.array(2**63, dtype='uint64'), np.array(1, dtype='uint8'))
   4611686018427387904
   >>> mxnp.bitwise_right_shift(mxnp.array(2**63, dtype='uint64'), mxnp.array(1, dtype='uint8'))
   array(13835058055282163712, dtype=uint64)
   >>> bin(13835058055282163712)
   '0b1100000000000000000000000000000000000000000000000000000000000000'
   ```
   A recent issue I filed involving an array api unittest failure involved Cython vs. ctypes, but this issue is unrelated and most likely an issue with the cast to int64_t in the lines:
   https://github.com/apache/incubator-mxnet/blob/master/src/operator/mshadow_op.h#L835-L847
   


-- 
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: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] agrabows commented on issue #20968: mxnet.numpy and original numpy differ on bitwise right shift of uint64 types

Posted by GitBox <gi...@apache.org>.
agrabows commented on issue #20968:
URL: https://github.com/apache/incubator-mxnet/issues/20968#issuecomment-1075402289


   Hi, I added a fix here: https://github.com/apache/incubator-mxnet/pull/20974. It was caused by static_cast to int64.


-- 
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: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org