diff options
author | Diego Lopez Recas <Diego.LopezRecas@arm.com> | 2021-09-16 17:25:04 +0100 |
---|---|---|
committer | Diego Lopez Recas <Diego.LopezRecas@arm.com> | 2021-09-23 08:41:43 +0000 |
commit | febc20fef1490a4ca9f7b0264a32b271760e370e (patch) | |
tree | 7160b96f13ff38b3031e7cf314fce51af8b614c1 /src/armnnUtils/BFloat16.hpp | |
parent | fb50a176a201a165ccb300229e9e075a7ccb16de (diff) | |
download | armnn-febc20fef1490a4ca9f7b0264a32b271760e370e.tar.gz |
Fix undefined reinterpret_cast in BFloat16.hpp
This fixes gcc builds with version 8 or above.
Signed-off-by: Diego Lopez Recas <Diego.LopezRecas@arm.com>
Change-Id: I4b886854f4f3391f766e95c3478d3a5f9661507a
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 |