From 7467ba8fac0afb19d750b3bdda9ba95002634038 Mon Sep 17 00:00:00 2001 From: Mohammed Suhail Munshi Date: Tue, 5 Dec 2023 14:27:31 +0000 Subject: Use look up table for fp16 activation - Enables FP16 lut for logistic activation - Adds LUTManager to re-use lut where appropriate. Signed-off-by: Mohammed Suhail Munshi Change-Id: I94667b63b452a8e58a1eb59cb0b5866178954523 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10864 Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- arm_compute/function_info/ActivationLayerInfo.h | 32 ++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/function_info/ActivationLayerInfo.h b/arm_compute/function_info/ActivationLayerInfo.h index 195b67cf99..9390d0c54f 100644 --- a/arm_compute/function_info/ActivationLayerInfo.h +++ b/arm_compute/function_info/ActivationLayerInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023 Arm Limited. + * Copyright (c) 2016-2024 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,13 +21,19 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ACL_ARM_COMPUTE_FUNCTION_INFO_ACTIVATIONLAYERINFO -#define ACL_ARM_COMPUTE_FUNCTION_INFO_ACTIVATIONLAYERINFO +#ifndef ACL_ARM_COMPUTE_FUNCTION_INFO_ACTIVATIONLAYERINFO_H +#define ACL_ARM_COMPUTE_FUNCTION_INFO_ACTIVATIONLAYERINFO_H #include "arm_compute/core/CoreTypes.h" +#include "arm_compute/core/Error.h" #include "arm_compute/core/QuantizationInfo.h" #include +#include + +#ifdef __aarch64__ +#include +#endif // __arch64__ namespace arm_compute { @@ -58,7 +64,10 @@ public: typedef arm_compute::ActivationFunction ActivationFunction; /** Lookup table */ - using LookupTable256 = std::array; +#ifdef __aarch64__ + using LookupTable256 = std::array; + using LookupTable65536 = std::array; +#endif // __aarch64__ ActivationLayerInfo() = default; /** Default Constructor @@ -101,6 +110,16 @@ public: { _lut = std::move(lut); } + + const LookupTable65536 &lut_fp16() const + { + ARM_COMPUTE_ERROR_ON(_lut_fp16 == nullptr); + return *_lut_fp16; + } + void setLookupTable65536(std::shared_ptr lut) + { + _lut_fp16 = lut; + } #endif // __aarch64__ private: ActivationFunction _act = {ActivationLayerInfo::ActivationFunction::IDENTITY}; @@ -109,8 +128,9 @@ private: bool _enabled = {false}; #ifdef __aarch64__ - LookupTable256 _lut = {}; + LookupTable256 _lut = {}; + std::shared_ptr _lut_fp16{nullptr}; #endif // __aarch64__ }; } // namespace arm_compute -#endif /* ACL_ARM_COMPUTE_FUNCTION_INFO_ACTIVATIONLAYERINFO */ +#endif // ACL_ARM_COMPUTE_FUNCTION_INFO_ACTIVATIONLAYERINFO_H -- cgit v1.2.1