diff options
author | Pablo Marquez Tello <pablo.tello@arm.com> | 2022-05-26 14:19:39 +0100 |
---|---|---|
committer | Pablo Marquez Tello <pablo.tello@arm.com> | 2022-06-07 12:33:48 +0000 |
commit | d75cd8ac5de1a785712e2e23c735a0167d64dfa3 (patch) | |
tree | 4e07c3cb0b159e14596c5e47d677de5877ec6efc /arm_compute/core/QuantizationInfo.h | |
parent | fe1b1f6d94c196f086122613277ff95062a7e834 (diff) | |
download | ComputeLibrary-d75cd8ac5de1a785712e2e23c735a0167d64dfa3.tar.gz |
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>
Diffstat (limited to 'arm_compute/core/QuantizationInfo.h')
-rw-r--r-- | arm_compute/core/QuantizationInfo.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/arm_compute/core/QuantizationInfo.h b/arm_compute/core/QuantizationInfo.h index b331f7d923..0bd0f21bc1 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 @@ inline float dequantize_qsymm8(int8_t value, const UniformQuantizationInfo &qinf 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 |