File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
include/sycl/ext/oneapi/experimental Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -63,10 +63,9 @@ class bfloat16 {
6363 return __spirv_ConvertBF16ToFINTEL (a);
6464#endif
6565#else
66- // Shift temporary variable to silence the warning
6766 uint32_t bits = a;
6867 bits <<= 16 ;
69- return static_cast <float >(bits);
68+ return sycl::bit_cast <float >(bits);
7069#endif
7170 }
7271
Original file line number Diff line number Diff line change @@ -73,15 +73,17 @@ int main() {
7373 Success &= check_bf16_from_float (std::numeric_limits<float >::quiet_NaN (),
7474 std::stoi (" 1111111111000001" , nullptr , 2 ));
7575
76+ // see https://float.exposed/b0xffff
7677 Success &= check_bf16_to_float (
7778 0 , bitsToFloatConv (std::string (" 00000000000000000000000000000000" )));
7879 Success &= check_bf16_to_float (
79- 1 , bitsToFloatConv (std::string (" 01000111100000000000000000000000 " )));
80+ 1 , bitsToFloatConv (std::string (" 00000000000000010000000000000000 " )));
8081 Success &= check_bf16_to_float (
81- 42 , bitsToFloatConv (std::string (" 01001010001010000000000000000000 " )));
82+ 42 , bitsToFloatConv (std::string (" 00000000001010100000000000000000 " )));
8283 Success &= check_bf16_to_float (
83- std::numeric_limits<uint16_t >::max (),
84- bitsToFloatConv (std::string (" 01001111011111111111111100000000" )));
84+ // std::numeric_limits<uint16_t>::max() - 0xffff is bfloat16 -Nan and
85+ // -Nan == -Nan check in check_bf16_to_float would fail, so use not Nan:
86+ 65407 , bitsToFloatConv (std::string (" 11111111011111110000000000000000" )));
8587 if (!Success)
8688 return -1 ;
8789 return 0 ;
You can’t perform that action at this time.
0 commit comments