aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/NEON/NESymm.h
diff options
context:
space:
mode:
authorSang-Hoon Park <sang-hoon.park@arm.com>2020-03-26 14:02:37 +0000
committerSang-Hoon Park <sang-hoon.park@arm.com>2020-03-27 13:27:45 +0000
commit396cb95774bd7627254e3befec5e34844de701c9 (patch)
treeefdb87d02e398dba7440cee994e2d7a434bf51b8 /arm_compute/core/NEON/NESymm.h
parent1a531faf71c7563cf7b1d2e36cc4261e6a4a9906 (diff)
downloadComputeLibrary-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/NEON/NESymm.h')
-rw-r--r--arm_compute/core/NEON/NESymm.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/arm_compute/core/NEON/NESymm.h b/arm_compute/core/NEON/NESymm.h
index 924840930a..0cc2a963cf 100644
--- a/arm_compute/core/NEON/NESymm.h
+++ b/arm_compute/core/NEON/NESymm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 ARM Limited.
+ * Copyright (c) 2019-2020 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,6 +25,7 @@
#define ARM_COMPUTE_NESYMM_H
#include "arm_compute/core/NEON/NEMath.h"
+#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
#include <arm_neon.h>
namespace arm_compute
@@ -230,5 +231,26 @@ inline qsymm16x8x2_t vquantize_qsymm16(const float32x4x4_t &qv, const UniformQua
return res;
}
+/** Multiply a neon vector using quantized multiplier and shift
+ *
+ * @param[in] input Input vector to mutiply values to be quantized.
+ * @param[in] qmul Quantized multipler
+ * @param[in] shift Left bit shift
+ *
+ * @return A neon vector holding the multiplied value
+ */
+inline int32x4x2_t multiply_by_quantized_multipler_2row(int32x4x2_t input, int32_t qmul, int32_t shift)
+{
+ const auto left_shift = shift > 0 ? shift : 0;
+ const auto right_shift = shift > 0 ? 0 : -shift;
+ const auto one_shifted = 1 << left_shift;
+
+ int32x4x2_t result;
+ result.val[0] = rounding_divide_by_pow2(vqrdmulhq_n_s32(vmulq_n_s32(input.val[0], one_shifted), qmul), right_shift);
+ result.val[1] = rounding_divide_by_pow2(vqrdmulhq_n_s32(vmulq_n_s32(input.val[1], one_shifted), qmul), right_shift);
+
+ return result;
+}
+
} // namespace arm_compute
#endif // ARM_COMPUTE_NESYMM_H