diff options
author | Mohammed Suhail Munshi <MohammedSuhail.Munshi@arm.com> | 2024-01-16 15:52:39 +0000 |
---|---|---|
committer | Mohmun02 <MohammedSuhail.Munshi@arm.com> | 2024-01-17 12:21:14 +0000 |
commit | 8896cf7cb7df34c699e7453a0f0c683d1202ed15 (patch) | |
tree | cef9fdc7d108fade9261d2a0a08ccc4e33d331da /src | |
parent | 27dee1e276dc8816a5b9f4e04d8b31d5c5816ca0 (diff) | |
download | ComputeLibrary-8896cf7cb7df34c699e7453a0f0c683d1202ed15.tar.gz |
Fix minor issue, clean lut code
Resolves: [COMPMID-6799]
Signed-off-by: Mohammed Suhail Munshi <MohammedSuhail.Munshi@arm.com>
Change-Id: I47baeeea75f1d03609d1fa1e9a10d2f53d5694f7
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10969
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/helpers/LUTManager.cpp | 19 |
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 |