Compute Hard-Swish with a Lookup table for qasymm8.
* Resolves COMPMID-5211
Change-Id: I5914f971d733174dae67e6b4c589f45c75733cf7
Signed-off-by: Pablo Marquez Tello <pablo.tello@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7654
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/arm_compute/core/QuantizationInfo.h b/arm_compute/core/QuantizationInfo.h
index b331f7d..0bd0f21 100644
--- a/arm_compute/core/QuantizationInfo.h
+++ b/arm_compute/core/QuantizationInfo.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 Arm Limited.
+ * Copyright (c) 2019-2022 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -399,6 +399,16 @@
return value * qinfo.scale;
}
+inline qasymm8_t qasymm8_hard_swish(qasymm8_t in,
+ const UniformQuantizationInfo &qi_in,
+ const UniformQuantizationInfo &qi_out)
+{
+ float tmp_f = dequantize_qasymm8(in, qi_in);
+ tmp_f = tmp_f * ((std::min(std::max((tmp_f + 3), 0.0f), 6.0f)) * 0.166666667f);
+ 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