Skip to content

Commit 83da9f2

Browse files
committed
Add bfloat16::from_bits() static method
1 parent b363682 commit 83da9f2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sycl/include/sycl/ext/intel/experimental/bfloat16.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class [[sycl_detail::uses_aspects(ext_intel_bf16_conversion)]] bfloat16 {
4343
#endif
4444
}
4545

46+
static bfloat16 from_bits(const storage_t &a) {
47+
bfloat16 res;
48+
res.value = a;
49+
return res;
50+
}
51+
4652
// Implicit conversion from float to bfloat16
4753
bfloat16(const float &a) { value = from_float(a); }
4854

sycl/test/extensions/bfloat16.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ __attribute__((noinline)) float op(float a, float b) {
2727
// CHECK-NOT: uitofp
2828
// CHECK-NOT: fptoui
2929

30-
bfloat16 D = some_bf16_intrinsic(A, C);
30+
bfloat16 D = bfloat16::from_bits(some_bf16_intrinsic(A, C));
3131
// CHECK: [[D:%.*]] = tail call spir_func zeroext i16 @_Z19some_bf16_intrinsictt(i16 zeroext [[A]], i16 zeroext [[C]])
3232
// CHECK-NOT: uitofp
3333
// CHECK-NOT: fptoui

0 commit comments

Comments
 (0)