You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
You can reproduce the issue with the following command:
# install the de_DE.UTF-8 locale on the system
# 0.7 in de_DE.UTF-8 is represented as 0,7
# 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
The text was updated successfully, but these errors were encountered:
stu1130
changed the title
MXNet Python numerical scalar broken when we set the locale
MXNet Python numerical scalar is truncated when we set the locale
Apr 16, 2020
Description
deepjavalibrary/djl#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:
The text was updated successfully, but these errors were encountered: