You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/04/16 04:31:42 UTC

[GitHub] [incubator-mxnet] stu1130 opened a new issue #18079: MXNet Python numerical scalar broken when we set the locale

stu1130 opened a new issue #18079: MXNet Python numerical scalar broken when we set the locale
URL: https://github.com/apache/incubator-mxnet/issues/18079
 
 
   ## Description
   https://github.com/awslabs/djl/issues/49 indicates that MXNet backend didn't handle the locale right. When we use the operator that can input the scalar, we use string as medium to pass the scalar to backend. In C++ engine, we use std::stod to convert the string back to double https://github.com/apache/incubator-mxnet/blob/7a59239a260920dfde7c6bac410679c57a868cc0/src/operator/tensor/elemwise_binary_scalar_op.h#L365
   The std::stod converts the string based on locale, but it doesn't get the locale from environment variable. So it is still use us by default. This is not the case in Java, you can see scalar was truncated which leads to wrong result.
   
   You can reproduce the issue with the following command:
   ```
   # install the de_DE.UTF-8 locale on the system
   # then start the python
   >>> import mxnet as mx
   >>> from mxnet import npx
   >>> import locale
   >>> a = mx.np.array(1.3)
   >>> a + 0.7
   2.0 # right result as expected
   >>> locale.setlocale(locale.LC_NUMERIC, 'de_DE.UTF-8')
   >>>  a + 0.7
   1.3 # wrong result because 0.7 was truncated to 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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] nickguletskii commented on issue #18079: MXNet Python numerical scalar is truncated when we set the locale

Posted by GitBox <gi...@apache.org>.
nickguletskii commented on issue #18079: MXNet Python numerical scalar is truncated when we set the locale
URL: https://github.com/apache/incubator-mxnet/issues/18079#issuecomment-614531476
 
 
   Related: https://github.com/apache/incubator-mxnet/pull/17177

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] stu1130 commented on issue #18079: MXNet Python numerical scalar is truncated when we set the locale

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


   I can confirm the issue is fixed by https://github.com/apache/incubator-mxnet/pull/17177 Thanks @nickguletskii 


----------------------------------------------------------------
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:
users@infra.apache.org