@@ -21,7 +21,11 @@ namespace ext::oneapi {
21
21
22
22
class bfloat16 {
23
23
public:
24
- using Bfloat16StorageT = uint16_t ;
24
+ #ifndef __INTEL_PREVIEW_BREAKING_CHANGES
25
+ using Bfloat16StorageT
26
+ __SYCL_DEPRECATED (" bfloat16::Bfloat16StorageT is non-standard and has "
27
+ " been deprecated." ) = uint16_t;
28
+ #endif
25
29
26
30
bfloat16 () = default ;
27
31
~bfloat16 () = default ;
@@ -58,7 +62,7 @@ class bfloat16 {
58
62
friend bfloat16 operator -(const bfloat16 &lhs) {
59
63
#if defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__) && \
60
64
(__SYCL_CUDA_ARCH__ >= 800 )
61
- Bfloat16StorageT res;
65
+ uint16_t res;
62
66
asm (" neg.bf16 %0, %1;" : " =h" (res) : " h" (lhs.value ));
63
67
return bit_cast<bfloat16>(res);
64
68
#else
@@ -146,18 +150,18 @@ class bfloat16 {
146
150
#endif
147
151
148
152
private:
149
- Bfloat16StorageT value;
153
+ uint16_t value;
150
154
151
155
// Private tag used to avoid constructor ambiguity.
152
156
struct private_tag {
153
157
explicit private_tag () = default;
154
158
};
155
159
156
- constexpr bfloat16 (Bfloat16StorageT Value, private_tag) : value{Value} {}
160
+ constexpr bfloat16 (uint16_t Value, private_tag) : value{Value} {}
157
161
158
162
// Explicit conversion functions
159
- static float to_float (const Bfloat16StorageT &a);
160
- static Bfloat16StorageT from_float (const float &a);
163
+ static float to_float (const uint16_t &a);
164
+ static uint16_t from_float (const float &a);
161
165
162
166
// Friend traits.
163
167
friend std::numeric_limits<bfloat16>;
@@ -178,7 +182,7 @@ class bfloat16 {
178
182
extern " C" __DPCPP_SYCL_EXTERNAL float
179
183
__devicelib_ConvertBF16ToFINTEL (const uint16_t &) noexcept ;
180
184
#endif
181
- inline float bfloat16::to_float (const bfloat16::Bfloat16StorageT &a) {
185
+ inline float bfloat16::to_float (const uint16_t &a) {
182
186
#if defined(__SYCL_DEVICE_ONLY__) && (defined(__SPIR__) || defined(__SPIRV__))
183
187
return __devicelib_ConvertBF16ToFINTEL (a);
184
188
#else
@@ -213,11 +217,11 @@ inline uint16_t from_float_to_uint16_t(const float &a) {
213
217
extern " C" __DPCPP_SYCL_EXTERNAL uint16_t
214
218
__devicelib_ConvertFToBF16INTEL (const float &) noexcept ;
215
219
#endif
216
- inline bfloat16::Bfloat16StorageT bfloat16::from_float (const float &a) {
220
+ inline uint16_t bfloat16::from_float (const float &a) {
217
221
#if defined(__SYCL_DEVICE_ONLY__)
218
222
#if defined(__NVPTX__)
219
223
#if (__SYCL_CUDA_ARCH__ >= 800)
220
- Bfloat16StorageT res;
224
+ uint16_t res;
221
225
asm (" cvt.rn.bf16.f32 %0, %1;" : " =h" (res) : " f" (a));
222
226
return res;
223
227
#else
0 commit comments