-
-
Notifications
You must be signed in to change notification settings - Fork 826
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 intermediate dtypes for float16 inputs in cupyx.scipy.ndimage
stats functions
#3402
Conversation
cupyx/scipy/ndimage/measurements.py
Outdated
|
||
if cupy.isscalar(index): | ||
count, sum_c_sq = single_group(input[labels == index]) | ||
return sum_c_sq / cupy.asanyarray(count).astype(float) |
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.
The three cases looks too similar
Couldn't be grouped in something like
def calc_var_with_intermediate_float(input):
vals_c = input - input.mean()
return cupy.square(vals_c).sum() / cupy.asanyarray(count).astype(float)
cupyx/scipy/ndimage/measurements.py
Outdated
|
||
if cupy.isscalar(index): | ||
count, sum = single_group(input[labels == index]) | ||
return sum / cupy.asanyarray(count).astype(float) |
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.
Same as above 😇
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.
Left some comments, but I don't know if it makes sense 😅
I fixed them as well as |
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.
LGTM
Sorry, please fix travis! |
Mmm �[91mWarning, treated as error:�[39;49;00m .. autofunction:: |
Perhaps because of |
has it been updated recently? |
Yesterday. https://pypi.org/project/Sphinx/#history |
|
08351d7
to
442aa77
Compare
Jenkins, test this please |
Successfully created a job for commit 442aa77: |
Jenkins CI test (for commit 442aa77, target branch master) succeeded! |
Follows #3259 (comment).
NumPy's
ndarray.sum()
andndarray.mean()
use different intermediate dtypes for summation and return a little different results for float16 inputs.Because of this,
cupyx.scipy.ndimage
stats functions introduced in #3259 return slightly different results for float16 inputs compared with their SciPy counterparts. This PR fixes the functions to follow SciPy's way to compute such values.