-
Notifications
You must be signed in to change notification settings - Fork 809
Use fp32 accumulation in portable/optimized norms #16727
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,8 +77,8 @@ void group_norm( | |
| const CTYPE* x = input_data + i * inner_size; | ||
|
|
||
| // compute E[X] and Var[x] = E[x^2] - E[x]^2 | ||
| CTYPE sum = reduce_add(x, static_cast<CTYPE>(inner_size)); | ||
| CTYPE sq_sum = vec_powerf(x, static_cast<CTYPE>(inner_size)); | ||
| float sum = reduce_add(x, inner_size); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: We should ideally use float64 if CTYPE is double, but we're already forcing float32 in the various utility functions - reduce_add and vec_powerf return floats and use floats internally. I'm just removing the implicit cast to CTYPE on the return value. I'm inclined to leave this for a follow-up on an as-needed basis. |
||
| float sq_sum = vec_powerf(x, inner_size); | ||
| double mean_value = | ||
| static_cast<double>(sum) / static_cast<double>(inner_size); | ||
| double variance = | ||
|
|
||
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.
This matches the ATen convention from OpMathType.h.