Skip to content
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

Merged
merged 8 commits into from
May 11, 2023
Merged

[wasm] Add Mod kernel #7670

merged 8 commits into from
May 11, 2023

Conversation

chunnienc
Copy link
Collaborator

Branch from #4236

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.

@chunnienc chunnienc marked this pull request as ready for review May 8, 2023 22:26
Copy link
Member

@mattsoulanille mattsoulanille left a 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.

Comment on lines +30 to +46
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);
}
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@fengwuyao fengwuyao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@chunnienc chunnienc merged commit 6d7c132 into tensorflow:master May 11, 2023
@chunnienc chunnienc mentioned this pull request May 11, 2023
@chunnienc chunnienc deleted the wasm-mod branch May 11, 2023 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants