Skip to content

Commit

Permalink
[ROCM]fix bfloat16 to float error! (PaddlePaddle#56517)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rane2021 authored and BeingGod committed Sep 9, 2023
1 parent 9977b1b commit 6b521cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion paddle/phi/common/bfloat16.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ struct PADDLE_ALIGN(2) bfloat16 {
uint16_t temp = x;
uint16_t* temp_ptr = reinterpret_cast<uint16_t*>(&temp);
res = *temp_ptr;
return res;
// return res;
res = res << 16;
return *reinterpret_cast<float*>(&res);
#else
#ifdef PADDLE_CUDA_BF16
return __bfloat162float(*reinterpret_cast<const __nv_bfloat16*>(&x));
Expand Down

0 comments on commit 6b521cd

Please sign in to comment.