aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/Types.h
diff options
context:
space:
mode:
authorMichel Iwaniec <michel.iwaniec@arm.com>2017-10-12 14:14:15 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit0063380ca6e43d04722707c707e610b59e1f8dde (patch)
treec60f6e5b380851cefd5aa994b75d3e4ab3484055 /arm_compute/core/Types.h
parent27c9efb922832e5e6785a492e84a46934d9a47f8 (diff)
downloadComputeLibrary-0063380ca6e43d04722707c707e610b59e1f8dde.tar.gz
IVGCVSW-619: Support for Cl u8 bounded Relu
Change-Id: I3c39ecbd36f06d5376c35ed4eb38dd73533ef97e Reviewed-on: http://mpd-gerrit.cambridge.arm.com/93686 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute/core/Types.h')
-rw-r--r--arm_compute/core/Types.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h
index f52dd12597..e567bac860 100644
--- a/arm_compute/core/Types.h
+++ b/arm_compute/core/Types.h
@@ -67,6 +67,7 @@ enum class DataType
U8,
S8,
QS8,
+ QASYMM8,
U16,
S16,
QS16,
@@ -90,6 +91,46 @@ constexpr float SCALE_PYRAMID_HALF = 0.5f;
/* Constant value used to indicate a ORB scaled pyramid */
constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01;
+/** Quantization settings (used for QASYMM8 data type) */
+struct QuantizationInfo
+{
+ QuantizationInfo()
+ : scale(0.0f), offset(0)
+ {
+ }
+
+ QuantizationInfo(float scale, int offset)
+ : scale(scale), offset(offset)
+ {
+ }
+
+ float scale; /**< scale */
+ int offset; /**< offset */
+
+ /** Quantizes a value using the scale/offset in this QuantizationInfo */
+ uint8_t quantize(float value) const
+ {
+ ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::quantize: scale == 0");
+ int quantized = static_cast<int>(value / scale + offset);
+ quantized = std::max(0, std::min(quantized, 255));
+ return quantized;
+ }
+
+ /** Dequantizes a value using the scale/offset in this QuantizationInfo */
+ float dequantize(uint8_t value) const
+ {
+ ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::dequantize: scale == 0");
+ float dequantized = (value - offset) * scale;
+ return dequantized;
+ }
+
+ /** Indicates whether this QuantizationInfo has valid settings or not */
+ bool empty() const
+ {
+ return scale == 0;
+ }
+};
+
struct ValidRegion
{
ValidRegion()