aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/cl_kernels/helpers_asymm.h
diff options
context:
space:
mode:
authorManuel Bottini <manuel.bottini@arm.com>2019-12-10 15:28:40 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-01-09 11:38:00 +0000
commit8481d833783589e70191c6388c93685b4fc4a0b8 (patch)
tree98e171bf013ad86bfe021bcc5c5a03e8634094d1 /src/core/CL/cl_kernels/helpers_asymm.h
parenta35980546c00ae1647ce033b061530607a5ad1e4 (diff)
downloadComputeLibrary-8481d833783589e70191c6388c93685b4fc4a0b8.tar.gz
COMPMID-2753: Add support for QASYMM8_SIGNED in CL kernels/functions
Change-Id: I7ed2d43f33458ba0571323f6fa9dc2e45fcd672a Signed-off-by: Manuel Bottini <manuel.bottini@arm.com> Reviewed-on: https://review.mlplatform.org/c/2516 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'src/core/CL/cl_kernels/helpers_asymm.h')
-rw-r--r--src/core/CL/cl_kernels/helpers_asymm.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core/CL/cl_kernels/helpers_asymm.h b/src/core/CL/cl_kernels/helpers_asymm.h
index 09409dc5e9..5a7c7126dc 100644
--- a/src/core/CL/cl_kernels/helpers_asymm.h
+++ b/src/core/CL/cl_kernels/helpers_asymm.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 ARM Limited.
+ * Copyright (c) 2017-2020 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -64,6 +64,19 @@ inline float dequantize_qasymm8(uchar input, float offset, float scale)
return ((float)input - offset) * scale;
}
+/** Dequantize a scalar value from signed 8-bit asymmetric to floating-point
+ *
+ * @param[in] input Input value to quantize
+ * @param[in] offset Quantization offset
+ * @param[in] scale Quantization scale
+ *
+ * @return quantized value
+ */
+inline float dequantize_qasymm8_signed(char input, float offset, float scale)
+{
+ return ((float)input - offset) * scale;
+}
+
/** Quantize a vector of values from floating-point
*
* @param[in] type Output data type.
@@ -91,7 +104,7 @@ inline float dequantize_qasymm8(uchar input, float offset, float scale)
#define DEQUANTIZE_IMPL(type, size) \
inline VEC_DATA_TYPE(float, size) dequantize_##type##size(VEC_DATA_TYPE(type, size) input, float offset, float scale) \
{ \
- return (CONVERT(input, VEC_DATA_TYPE(float, 4)) - offset) * scale; \
+ return (CONVERT(input, VEC_DATA_TYPE(float, size)) - offset) * scale; \
}
/** Correctly-rounded-to-nearest division by a power-of-two.
@@ -384,10 +397,14 @@ inline float dequantize_qasymm8(uchar input, float offset, float scale)
#define ASYMM_ROUNDING_HALF_SUM(a, b, size) asymm_rounding_half_sum##size(a, b)
#define ASYMM_RESCALE(value, src_integer_bits, dst_integer_bits, size) asymm_rescale##size(value, src_integer_bits, dst_integer_bits)
+QUANTIZE_IMPL(uchar, 1)
+QUANTIZE_IMPL(char, 1)
QUANTIZE_IMPL(uchar, 4)
QUANTIZE_IMPL(ushort, 4)
QUANTIZE_IMPL(short, 4)
+DEQUANTIZE_IMPL(uchar, 1)
+DEQUANTIZE_IMPL(char, 1)
DEQUANTIZE_IMPL(uchar, 4)
DEQUANTIZE_IMPL(ushort, 4)
DEQUANTIZE_IMPL(short, 4)