-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][Docs] 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
[SYCL][Docs] Add std::hash and std::numeric_limits specialization for bfloat16 #19838
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 <steffen.larsen@intel.com>
|
@gmlueck - These are also specialized for |
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
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?
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.
We do, but bit_cast in our implementation is only sometimes constexpr, so the friendship for numeric_limits lets it be unconditionally constexpr. For std::hash it should be fine to drop the friendship though!
| // 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...> { ... };
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.
I don't have a strong preference, but the current style is what we use for hash in other headers, so I would like to keep it as is. Then we can change it at a global level if we want.
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
This commit adds the missing std::hash and std::numeric_limits specializations for the sycl::ext::oneapi::bfloat16 class.