aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/QuantizationInfo.h
diff options
context:
space:
mode:
authorViet-Hoa Do <viet-hoa.do@arm.com>2022-06-21 15:56:15 +0100
committerViet-Hoa Do <viet-hoa.do@arm.com>2022-06-29 13:30:06 +0000
commitb042e39060901b44e615b923b5723c04d9b42a95 (patch)
treee23fd9b89c753f9731e1e8ec4a0d9ca468f9f683 /arm_compute/core/QuantizationInfo.h
parent13f96d0a5efc140785a6de58bff9b24b80dd0cfd (diff)
downloadComputeLibrary-b042e39060901b44e615b923b5723c04d9b42a95.tar.gz
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 <viet-hoa.do@arm.com> Change-Id: I1ea49611cc922765ee741e31138c888401d33e9b Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7845 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/core/QuantizationInfo.h')
-rw-r--r--arm_compute/core/QuantizationInfo.h11
1 files changed, 11 insertions, 0 deletions
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