aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/utils
diff options
context:
space:
mode:
authorVidhya Sudhan Loganathan <vidhyasudhan.loganathan@arm.com>2018-12-18 14:17:00 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2018-12-18 17:40:19 +0000
commit5e96be7707a571b136dc64256af399dbbb0fdfe0 (patch)
tree92229d9824f3089814ed2af56c5f76a474366954 /arm_compute/core/utils
parent52ebf4219385efe54463dc794ba806b82a6137b3 (diff)
downloadComputeLibrary-5e96be7707a571b136dc64256af399dbbb0fdfe0.tar.gz
COMPMID-1722 : CL: Implement Range
Change-Id: I88da6eb5289c303b1dc91606c1560ce629746058 Reviewed-on: https://review.mlplatform.org/381 Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute/core/utils')
-rw-r--r--arm_compute/core/utils/misc/Utility.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arm_compute/core/utils/misc/Utility.h b/arm_compute/core/utils/misc/Utility.h
index 37c8b66e06..8dd9afd5cd 100644
--- a/arm_compute/core/utils/misc/Utility.h
+++ b/arm_compute/core/utils/misc/Utility.h
@@ -80,8 +80,10 @@ std::array<typename std::iterator_traits<Iterator>::value_type, N> make_array(It
*
* @return Clamped value.
*/
-template <typename T>
-inline T clamp(const T &n, const T &lower, const T &upper)
+template <typename DataType, typename RangeType = DataType>
+inline DataType clamp(const DataType &n,
+ const DataType &lower = std::numeric_limits<RangeType>::lowest(),
+ const DataType &upper = std::numeric_limits<RangeType>::max())
{
return std::max(lower, std::min(n, upper));
}