diff options
Diffstat (limited to 'src/armnnUtils/BFloat16.hpp')
-rw-r--r-- | src/armnnUtils/BFloat16.hpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/armnnUtils/BFloat16.hpp b/src/armnnUtils/BFloat16.hpp index 52344db810..a293cd488c 100644 --- a/src/armnnUtils/BFloat16.hpp +++ b/src/armnnUtils/BFloat16.hpp @@ -7,6 +7,7 @@ #include <ostream> #include <cmath> +#include <cstring> #include <stdint.h> namespace armnn @@ -85,8 +86,10 @@ public: float ToFloat32() const { const uint32_t u32 = static_cast<uint32_t>(m_Value << 16u); - const float* f32 = reinterpret_cast<const float*>(&u32); - return *f32; + float f32; + static_assert(sizeof u32 == sizeof f32, ""); + std::memcpy(&f32, &u32, sizeof u32); + return f32; } uint16_t Val() const |