From 2df1c0de4c894eb68c17bad227c878438ab9bb05 Mon Sep 17 00:00:00 2001 From: Garima Gupta Date: Wed, 9 Oct 2019 14:55:15 -0700 Subject: [PATCH] [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 --- sycl/source/half_type.cpp | 2 +- sycl/test/basic_tests/half_type.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sycl/source/half_type.cpp b/sycl/source/half_type.cpp index 200a3b1f68ccf..6f14ec47b0721 100644 --- a/sycl/source/half_type.cpp +++ b/sycl/source/half_type.cpp @@ -66,7 +66,7 @@ static uint16_t float2Half(const float &Val) { uint16_t Ret = 0; Ret |= Sign; Ret |= Exp16 << 10; - Ret |= Frac16; + Ret += Frac16;// Add the carry bit from operation Frac16 += 1; return Ret; } diff --git a/sycl/test/basic_tests/half_type.cpp b/sycl/test/basic_tests/half_type.cpp index 5fac58101001b..0475c3f1a1c0c 100644 --- a/sycl/test/basic_tests/half_type.cpp +++ b/sycl/test/basic_tests/half_type.cpp @@ -233,6 +233,8 @@ int main() { assert(bitwise_comparison_fp16(0.0, 0)); // -0 assert(bitwise_comparison_fp16(-0.0, 32768)); + // 1.9999f + assert(bitwise_comparison_fp16(1.9999f, 0x4000)); // nan assert(bitwise_comparison_fp16(0.0 / 0.0, 32256)); assert(bitwise_comparison_fp16(-0.0 / 0.0, 32256));