aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils
diff options
context:
space:
mode:
authorDiego Lopez Recas <Diego.LopezRecas@arm.com>2021-09-16 17:25:04 +0100
committerDiego Lopez Recas <Diego.LopezRecas@arm.com>2021-09-23 08:41:43 +0000
commitfebc20fef1490a4ca9f7b0264a32b271760e370e (patch)
tree7160b96f13ff38b3031e7cf314fce51af8b614c1 /src/armnnUtils
parentfb50a176a201a165ccb300229e9e075a7ccb16de (diff)
downloadarmnn-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')
-rw-r--r--src/armnnUtils/BFloat16.hpp7
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