-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL] Add std::hash and std::numeric_limits specialization for bfloat16 #19838
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
base: sycl
Are you sure you want to change the base?
Conversation
This commit adds the missing std::hash and std::numeric_limits specializations for the sycl::ext::oneapi::bfloat16 class. Signed-off-by: Larsen, Steffen <[email protected]>
@gmlueck - These are also specialized for |
Signed-off-by: Larsen, Steffen <[email protected]>
I think we should update the bfloat16 extension spec to say that the extension does provide these specializations. Using For example, we could add a new section to the spec titled something like "Standard C++ library specializations" |
// Friend traits. | ||
friend std::numeric_limits<bfloat16>; | ||
friend std::hash<bfloat16>; |
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.
Do we have any guarantees on the layout/size? If so, can we use bit_cast
instead of friendship?
// Specialization of some functions in namespace `std`. | ||
namespace std { |
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.
Subjective, but I prefer
// in global ns
template <> struct std::{type}<types...> { ... };
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out |
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.
Looks like this belongs to sycl/test
, not sycl/test-e2e
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.
Or even sycl/unittests
This commit adds the missing std::hash and std::numeric_limits specializations for the sycl::ext::oneapi::bfloat16 class.