From b042e39060901b44e615b923b5723c04d9b42a95 Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Tue, 21 Jun 2022 15:56:15 +0100 Subject: Add LUT-based leaky relu for QASYMM8 on CPU * Add LUT generation function for Leaky ReLU. * Some additional changes in the existing LUT implementation: + Bring back the NEON implementation of hard swish for 32-bit build. Library size of 64-bit build is not affected. + Add some extra #ifdef to remove unnecessary code in 32-bit build. Resolves: COMPMID-5386 Signed-off-by: Viet-Hoa Do Change-Id: I1ea49611cc922765ee741e31138c888401d33e9b Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7845 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins --- arm_compute/core/QuantizationInfo.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'arm_compute/core/QuantizationInfo.h') diff --git a/arm_compute/core/QuantizationInfo.h b/arm_compute/core/QuantizationInfo.h index 0bd0f21bc1..21d962d08b 100644 --- a/arm_compute/core/QuantizationInfo.h +++ b/arm_compute/core/QuantizationInfo.h @@ -409,6 +409,17 @@ inline qasymm8_t qasymm8_hard_swish(qasymm8_t in, return tmp; } +inline qasymm8_t qasymm8_leaky_relu(qasymm8_t in, + const UniformQuantizationInfo &qi_in, + const UniformQuantizationInfo &qi_out, + float alpha) +{ + float tmp_f = dequantize_qasymm8(in, qi_in); + tmp_f = tmp_f > 0 ? tmp_f : tmp_f * alpha; + const qasymm8_t tmp = quantize_qasymm8(tmp_f, qi_out); + return tmp; +} + /** Dequantize a value given a 8-bit symmetric quantization scheme * * @param[in] value Value to dequantize -- cgit v1.2.1