Skip to content

Commit

Permalink
Get rid of type-aliasing warning
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Krebbel <[email protected]>
  • Loading branch information
Andreas-Krebbel committed Nov 22, 2024
1 parent dfc5b87 commit e976de7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions zdnn/convert_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,13 @@ float cnvt_1_fp16_to_fp32(uint16_t a) {
}

// convert 1 FP32 element to BFLOAT
// cppcheck-suppress invalidPointerCast
uint16_t cnvt_1_fp32_to_bfloat(float a) { return *(uint16_t *)(&a); }
uint16_t cnvt_1_fp32_to_bfloat(float a) {
union {
float in;
uint16_t out;
} u = {.in = a};
return u.out;
}

// convert 1 FP32 element to FP16
uint16_t cnvt_1_fp32_to_fp16(float a) {
Expand Down

0 comments on commit e976de7

Please sign in to comment.