aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2021-05-26 15:32:50 +0100
committerGiorgio Arena <giorgio.arena@arm.com>2021-06-01 11:27:17 +0000
commit433ea4981675b64c44c8f47f2f4aac6bfcbfc911 (patch)
tree7f73bdb5f7c068bd2d6849ae615447e8ea93843f /support
parentb3be45759bdd0749ae3a16fe470820f0d9830ea9 (diff)
downloadComputeLibrary-433ea4981675b64c44c8f47f2f4aac6bfcbfc911.tar.gz
Optimize int8 arithmetic addition on CPU
Avoid accessing quantization info from TensorInfo in leftover loop. Use the already available UniformQuantizationInfo instead Create another version of the quantize utility function which assumes RoundingPolicy::TO_NEAREST_UP. This allows us to call std::lround() and avoid some overhead Resolve COMPMID-4546 Signed-off-by: Giorgio Arena <giorgio.arena@arm.com> Change-Id: Ib481a586f879b7e937e3d54ba11100d0a37ef277 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5722 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'support')
-rw-r--r--support/ToolchainSupport.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h
index e79084a629..d8c14411e8 100644
--- a/support/ToolchainSupport.h
+++ b/support/ToolchainSupport.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -72,6 +72,21 @@ inline T round(T value)
return ::round(value);
}
+/** Round floating-point value with half value rounding away from zero and cast to long
+ *
+ * @note This function implements the same behaviour as std::lround except that it doesn't
+ * support Integral type. The latter is not in the namespace std in some Android toolchains.
+ *
+ * @param[in] value floating-point value to be rounded.
+ *
+ * @return Floating-point value of rounded @p value casted to long
+ */
+template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
+inline long lround(T value)
+{
+ return ::lround(value);
+}
+
/** Truncate floating-point value.
*
* @note This function implements the same behaviour as std::truncate except that it doesn't
@@ -172,6 +187,21 @@ inline T round(T value)
return (value < 0.f) ? static_cast<int>(value - 0.5f) : static_cast<int>(value + 0.5f);
}
+/** Round floating-point value with half value rounding away from zero and cast to long
+ *
+ * @note This function implements the same behaviour as std::lround except that it doesn't
+ * support Integral type. The latter is not in the namespace std in some Android toolchains.
+ *
+ * @param[in] value floating-point value to be rounded.
+ *
+ * @return Floating-point value of rounded @p value casted to long
+ */
+template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
+inline long lround(T value)
+{
+ return std::lround(value);
+}
+
/** Truncate floating-point value.
*
* @note This function implements the same behaviour as std::truncate except that it doesn't