From 6aeb2170d18824135acef2d5c16fb93c4488c1fe Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Tue, 15 Dec 2020 15:45:43 +0000 Subject: Fix fill() for FP data type in fixtures - Part 1 Resolves: COMPMID-4050 Signed-off-by: Giorgio Arena Change-Id: I182548bf4b944c499a7134ac005b137877e61baf Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4700 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- support/Random.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'support/Random.h') diff --git a/support/Random.h b/support/Random.h index c8b767e505..d5d372dc82 100644 --- a/support/Random.h +++ b/support/Random.h @@ -25,6 +25,7 @@ #define ARM_COMPUTE_MISC_RANDOM_H #include "arm_compute/core/Error.h" +#include "utils/Utils.h" #include #include @@ -43,13 +44,14 @@ template class RangedUniformDistribution { public: - using DT = typename std::conditional::value, - std::uniform_int_distribution, - std::uniform_real_distribution>::type; + static constexpr bool is_half = std::is_same::value; + static constexpr bool is_integral = std::is_integral::value && !is_half; + + using fp_dist = typename std::conditional>::type; + using DT = typename std::conditional, fp_dist>::type; using result_type = T; using range_pair = std::pair; -public: /** Constructor * * @param[in] low lowest value in the range (inclusive) @@ -62,7 +64,7 @@ public: result_type clow = low; for(const auto &erange : exclude_ranges) { - result_type epsilon = std::is_integral::value ? 1 : static_cast(std::numeric_limits::epsilon()); + result_type epsilon = is_integral ? result_type(1) : result_type(std::numeric_limits::epsilon()); ARM_COMPUTE_ERROR_ON(clow > erange.first || clow >= erange.second); -- cgit v1.2.1