-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[wasm] Add Mod kernel #7670
[wasm] Add Mod kernel #7670
Conversation
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 with a nit.
template <typename T> | ||
inline T ModInt(T a, T b) { | ||
T rem = a % b; | ||
if ((a < 0 && b < 0) || (a >= 0 && b >= 0)) { | ||
return rem; | ||
} | ||
return (rem + b) % b; | ||
} | ||
|
||
template <typename T> | ||
inline T ModFloat(T a, T b) { | ||
T rem = std::fmod(a, b); | ||
if ((a < 0 && b < 0) || (a >= 0 && b >= 0)) { | ||
return rem; | ||
} | ||
return std::fmod(rem + b, b); | ||
} |
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.
Nit: Should these be templates if they're specifically for int
and 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.
It's just 3 extra lines of code. Let's keep it for simplicity.
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!
Branch from #4236
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.