-
-
Notifications
You must be signed in to change notification settings - Fork 787
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
Slight fix on entropy
test
#4424
Conversation
'default': 1e-15}, | ||
scipy_name='scp') | ||
def test_entropy(self, xp, scp, dtype): | ||
# `entropy` returns float32 value for float16 input so float32 | ||
# tolerance is used for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the intermediate computations done in float32?
If that is the case this is fine. But if all the steps are done in float16, even though the output is float32, there will be precision losses. So the original tolerance should be kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In SciPy, float16 inputs do not seem to be explicitly cast to float32, so the normalization step that divides by a sum over the array will use float16. Thus, the normalization step here should be more accurate than in SciPy. The later use of the scipy.special
functions does result in things becoming float32, though (I don't think any functions in scipy.special
support half precision)
Yes, float16 input is `astype`ed to float32 at the very early point of
`entropy` (at least on CuPy.)
https://github.com/cupy/cupy/blob/3ce7aafc824863b35021862316d2b1b9b1a90736/cupyx/scipy/stats/distributions.py#L46
But the problem is that per-dtype tolerance uses the dtype of the returned
ndarray, so it can not determine that the input was float16 or floar32 when
the function returns float32 value for both float16 and float32 inputs...
|
Maybe possible to make `numpy_cupy_allclose` to sniff `dtype` when it is
used with `for_dtypes` family at the same time?
|
Shuffle test failed as |
Jenkins, test this please |
Jenkins CI test (for commit 426e6b4, target branch master) failed with status FAILURE. |
Seems like it didn't go well 😁 |
Could you merge #4481 first? |
Jenkins, test this please |
Jenkins CI test (for commit 426e6b4, target branch master) failed with status FAILURE. |
This PR follows #4369 to slightly fix its test.