Skip to content

Commit 2de1379

Browse files
garimaguromanovvlad
authored andcommitted
[SYCL] Rectified precision issue with the float->half conversion.
Edited the test case to include the specific scenario that was failing. Signed-off-by: Garima Gupta <garima.gupta@intel.com>
1 parent 01869a0 commit 2de1379

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sycl/source/half_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static uint16_t float2Half(const float &Val) {
6666
uint16_t Ret = 0;
6767
Ret |= Sign;
6868
Ret |= Exp16 << 10;
69-
Ret |= Frac16;
69+
Ret += Frac16;// Add the carry bit from operation Frac16 += 1;
7070

7171
return Ret;
7272
}

sycl/test/basic_tests/half_type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ int main() {
233233
assert(bitwise_comparison_fp16(0.0, 0));
234234
// -0
235235
assert(bitwise_comparison_fp16(-0.0, 32768));
236+
// 1.9999f
237+
assert(bitwise_comparison_fp16(1.9999f, 0x4000));
236238
// nan
237239
assert(bitwise_comparison_fp16(0.0 / 0.0, 32256));
238240
assert(bitwise_comparison_fp16(-0.0 / 0.0, 32256));

0 commit comments

Comments
 (0)