aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/Types.h
diff options
context:
space:
mode:
authorMichel Iwaniec <michel.iwaniec@arm.com>2017-11-29 10:48:23 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:42:17 +0000
commit5dfeae62f89eefdc241887c3e67cd1c04ec0b6a7 (patch)
treed6b5d40353aa68aeda803c809812fd6e208c3e7f /arm_compute/core/Types.h
parent7f0f790ae7f5dd044a5d7564492583b8df974a11 (diff)
downloadComputeLibrary-5dfeae62f89eefdc241887c3e67cd1c04ec0b6a7.tar.gz
IVGCVSW-820: Add QASYMM8 support to NeonActivationLayerKernel
Change-Id: Ic3881e97b4fcbae0ac287a1e010cfc6f0fd8d7d1 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/112139 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute/core/Types.h')
-rw-r--r--arm_compute/core/Types.h25
1 files changed, 7 insertions, 18 deletions
diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h
index beaec143ef..538449b40a 100644
--- a/arm_compute/core/Types.h
+++ b/arm_compute/core/Types.h
@@ -25,10 +25,13 @@
#define __ARM_COMPUTE_TYPES_H__
#include "arm_compute/core/Coordinates.h"
+#include "arm_compute/core/QAsymm8.h"
+#include "arm_compute/core/Rounding.h"
#include "arm_compute/core/Strides.h"
#include "arm_compute/core/TensorShape.h"
#include "support/Half.h"
+#include <cmath>
#include <cstddef>
#include <cstdint>
#include <string>
@@ -102,17 +105,6 @@ constexpr float SCALE_PYRAMID_HALF = 0.5f;
/* Constant value used to indicate a ORB scaled pyramid */
constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01;
-/** Rounding method */
-enum class RoundingPolicy
-{
- TO_ZERO, /**< Truncates the least significand values that are lost in operations. */
- TO_NEAREST_UP, /**< Rounds to nearest value; half rounds away from zero */
- TO_NEAREST_EVEN, /**< Rounds to nearest value; half rounds to nearest even */
-};
-
-//forward declare round function
-int round(float, RoundingPolicy);
-
/** Quantization settings (used for QASYMM8 data type) */
struct QuantizationInfo
{
@@ -140,20 +132,17 @@ struct QuantizationInfo
int offset; /**< offset */
/** Quantizes a value using the scale/offset in this QuantizationInfo */
- uint8_t quantize(float value, RoundingPolicy rounding_policy) const
+ qasymm8_t quantize(float value, RoundingPolicy rounding_policy) const
{
ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::quantize: scale == 0");
- int quantized = arm_compute::round(value / scale, rounding_policy) + offset;
- quantized = std::max(0, std::min(quantized, 255));
- return quantized;
+ return sqcvt_qasymm8_f32(value, scale, offset, rounding_policy);
}
/** Dequantizes a value using the scale/offset in this QuantizationInfo */
- float dequantize(uint8_t value) const
+ float dequantize(qasymm8_t value) const
{
ARM_COMPUTE_ERROR_ON_MSG(scale == 0, "QuantizationInfo::dequantize: scale == 0");
- float dequantized = (static_cast<int>(value) - offset) * scale;
- return dequantized;
+ return scvt_f32_qasymm8(value, scale, offset);
}
/** Indicates whether this QuantizationInfo has valid settings or not */