-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rounding on float16
conversions
#8378
Conversation
Also please write tests. |
I added an initial try for testing it, it is for the float32 case, Since this is a numpy related change I was doubting on how to do the testing. |
b493edc
to
51e1ec4
Compare
Jenkins, test this please. |
Jenkins CI test (for commit 51e1ec4, target branch master) succeeded! |
LGTM. |
float16
conversions
Jenkins CI test (for commit 51e1ec4, target branch master) failed with status FAILURE. |
Closes #8366
When casting a Chainerx array in the native backend to float16 the float16 code differs subtly from the numpy one in the rounding of elements.
https://github.com/numpy/numpy/blob/1f8fb2ca31a7f41a23c60e4ffcb38b3e0cb201f7/numpy/core/src/npymath/halffloat.c#L339-L347
This caused the IRemainder test to yield 150 failures for 1 million runs.
After fixing the number went down to 0.
The fp64 to fp16 case has been similarly fixed to match the numpy logic as some of the calculations were different and it was not clear where did they come from.