diff options
-rw-r--r-- | support/Bfloat16.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/support/Bfloat16.h b/support/Bfloat16.h index d57d8ce9ee..173f2d16e2 100644 --- a/support/Bfloat16.h +++ b/support/Bfloat16.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,6 +25,7 @@ #define ARM_COMPUTE_BFLOAT16_H #include <cstdint> +#include <cstring> namespace arm_compute { @@ -70,9 +71,9 @@ inline uint16_t float_to_bf16(const float v) inline float bf16_to_float(const uint16_t &v) { const uint32_t lv = (v << 16); - const float *fp = reinterpret_cast<const float *>(&lv); - - return *fp; + float fp; + memcpy(&fp, &lv, sizeof(lv)); + return fp; } } @@ -137,4 +138,4 @@ private: uint16_t value; }; } // namespace arm_compute -#endif /* ARM_COMPUTE_BFLOAT16_H */
\ No newline at end of file +#endif /* ARM_COMPUTE_BFLOAT16_H */ |