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: [email protected] With regards, Apache Git Services
