diff options
author | Sang-Hoon Park <sang-hoon.park@arm.com> | 2020-03-26 14:02:37 +0000 |
---|---|---|
committer | Sang-Hoon Park <sang-hoon.park@arm.com> | 2020-03-27 13:27:45 +0000 |
commit | 396cb95774bd7627254e3befec5e34844de701c9 (patch) | |
tree | efdb87d02e398dba7440cee994e2d7a434bf51b8 /arm_compute/core/utils/quantization/AsymmHelpers.h | |
parent | 1a531faf71c7563cf7b1d2e36cc4261e6a4a9906 (diff) | |
download | ComputeLibrary-396cb95774bd7627254e3befec5e34844de701c9.tar.gz |
COMPMID-3284 add utilities for layer normalization of NEON QLSTM
Change-Id: Ie98a8c4c30ac7859a989a29cbe7602c1c6fec26b
Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2934
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute/core/utils/quantization/AsymmHelpers.h')
-rw-r--r-- | arm_compute/core/utils/quantization/AsymmHelpers.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/arm_compute/core/utils/quantization/AsymmHelpers.h b/arm_compute/core/utils/quantization/AsymmHelpers.h index 94876fb02f..0f0ec72b60 100644 --- a/arm_compute/core/utils/quantization/AsymmHelpers.h +++ b/arm_compute/core/utils/quantization/AsymmHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -99,6 +99,46 @@ void compute_quantized_multipliers_and_shifts(const ITensorInfo *input, unsigned int idx_ofms, int32_t *output_multipliers_ptr, int32_t *output_shifts_ptr); + +/** Round to the nearest division by a power-of-two using exponent, copied from NEMath + * + * @note This function calculates the following expression: (x + 2^n -1 ) / 2^n where n = exponent + * + * @param[in] x Element to divide. + * @param[in] exponent Integer value used to round to nearest division by a power-of-two + * + * @return the nearest division by a power-of-two using exponent + */ +int32_t rounding_divide_by_pow2(int32_t x, int exponent); + +/** Compute multiplication of two integers + * + * @param[in] a One integer to multiply + * @param[in] b Another integer to multiply + * + * @return The multiplied value + */ +int32_t saturating_rounding_doubling_highmul(int32_t a, int32_t b); + +/** Compute the value multiplied by given quantized multiplier and shift + * + * @param[in] input Target value to multiply. + * @param[in] qmul Quantized multipler + * @param[in] shift Left bit shift + * + * @return The multiplied value + */ +int32_t multiply_by_quantized_multipler(int32_t input, int32_t qmul, int32_t shift); + +/** Compute the value multiplied the power-of-two + * + * @param[in] exponent Exponent used to calculate power-of-two + * @param[in] v Target value to multiply + * + * @return The multiplied value + */ +int32_t saturating_rounding_multiply_by_pow2(int exponent, int32_t v); + } // namespace quantization } // namespace arm_compute #endif /* ARM_COMPUTE_IO_FILE_HANDLER_H */ |