Skip to content

Commit a8fdb33

Browse files
authored
[SYCL][bfloat16] Simplify bfloat16 class (#17258)
This change makes a few changes aiming to make the code more readable. * Move declaration of the bfloat16 class right on top of the header file and move all declarations with the implementation helpers after the class declaration. * Converted ConvertToBfloat16 class to namespace. The class doesn't represent any object, it's a collection of static methods. * Declare public API of the class first. * Move Bfloat16StorageT declaration from the detail namespace directly into bfloat16 class definition. * Co-locate declaration of functions with similar functionality (e.g. conversion functions). * Simplified uniry operator- implementation by removing additional branch for the SPIR target. Generic code for SPIR target produces exactly the same code. * Added compile time checks for the array size inside conversion helper functions. Device side implementation of these functions work correctly only for certain array sizes. * Include C++ header instead of C (i.e. cstdint instead of stdint.h). * Applied "no-else-after-return" and "no-braces-for-single-statement-if" coding style changes.
1 parent e09cee2 commit a8fdb33

File tree

5 files changed

+453
-438
lines changed

5 files changed

+453
-438
lines changed

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ template <typename T> auto convertToOpenCLType(T &&x) {
172172
} else if constexpr (std::is_same_v<no_ref, ext::oneapi::bfloat16>) {
173173
// On host, don't interpret BF16 as uint16.
174174
#ifdef __SYCL_DEVICE_ONLY__
175-
using OpenCLType = sycl::ext::oneapi::detail::Bfloat16StorageT;
175+
using OpenCLType = sycl::ext::oneapi::bfloat16::Bfloat16StorageT;
176176
return sycl::bit_cast<OpenCLType>(x);
177177
#else
178178
return std::forward<T>(x);

0 commit comments

Comments
 (0)