aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/helpers/LUTManager.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/helpers/LUTManager.cpp b/src/core/helpers/LUTManager.cpp
index 2f1746e31e..06e35eed8c 100644
--- a/src/core/helpers/LUTManager.cpp
+++ b/src/core/helpers/LUTManager.cpp
@@ -29,17 +29,22 @@ namespace arm_compute
#ifdef __aarch64__
namespace
{
+
void init_lut_fp16(ActivationLayerInfo::LookupTable65536 *lut)
{
- for (uint16_t i = 0; i < lut->size() - 1; ++i)
+ union Element
+ {
+ uint16_t i = 0;
+ float16_t fp;
+ } item;
+ // Fill lut by iterating over all 16 bit values using the union.
+ while (true)
{
- const float16_t *v = reinterpret_cast<float16_t *>(&i);
- (*lut)[i] = 1.f / (1.f + std::exp(-*v));
+ (*lut)[item.i] = 1.f / (1.f + std::exp(-item.fp));
+ if (item.i == 65535)
+ break;
+ item.i++;
}
- // Final value should be filled outside of loop to avoid overflows.
- const uint16_t i = lut->size() - 1;
- const float16_t *v = reinterpret_cast<const float16_t *>(&i);
- (*lut)[i] = 1.f / (1.f + std::exp(-*v));
}
} // namespace