From 470d97fd8f6e8ef8ea8ef11da97f8d01debcc5fa Mon Sep 17 00:00:00 2001 From: Rane2021 Date: Mon, 21 Aug 2023 20:44:42 +0800 Subject: [PATCH] [ROCM]fix bfloat16 to float error! --- paddle/phi/common/bfloat16.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/phi/common/bfloat16.h b/paddle/phi/common/bfloat16.h index ccaf9b82bc5a5..028851e34c8bc 100644 --- a/paddle/phi/common/bfloat16.h +++ b/paddle/phi/common/bfloat16.h @@ -157,7 +157,9 @@ struct PADDLE_ALIGN(2) bfloat16 { uint16_t temp = x; uint16_t* temp_ptr = reinterpret_cast(&temp); res = *temp_ptr; - return res; + // return res; + res = res << 16; + return *reinterpret_cast(&res); #else #ifdef PADDLE_CUDA_BF16 return __bfloat162float(*reinterpret_cast(&x));