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

Support Half/BFloat16 in op_allclose #7766

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions kernels/portable/cpu/op_allclose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ bool tensors_are_close(
a.numel(),
rtol,
atol);
} else if (a.scalar_type() == ScalarType::Half) {
return data_is_close<Half>(
a.const_data_ptr<Half>(),
b.const_data_ptr<Half>(),
a.numel(),
rtol,
atol);
} else if (a.scalar_type() == ScalarType::BFloat16) {
return data_is_close<BFloat16>(
a.const_data_ptr<BFloat16>(),
b.const_data_ptr<BFloat16>(),
a.numel(),
rtol,
atol);
} else {
// Non-floating-point types can be compared bitwise.
return memcmp(a.mutable_data_ptr(), b.mutable_data_ptr(), a.nbytes()) == 0;
Expand Down
Loading
Loading