diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2020-12-15 15:45:43 +0000 |
---|---|---|
committer | Giorgio Arena <giorgio.arena@arm.com> | 2020-12-17 13:08:07 +0000 |
commit | 6aeb2170d18824135acef2d5c16fb93c4488c1fe (patch) | |
tree | b91c323eeae2ecccb8c42cd3c69f296298de7c4c /support | |
parent | 72610dcf2d634c9c2919ad55245c5c91609e87eb (diff) | |
download | ComputeLibrary-6aeb2170d18824135acef2d5c16fb93c4488c1fe.tar.gz |
Fix fill() for FP data type in fixtures - Part 1
Resolves: COMPMID-4050
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Change-Id: I182548bf4b944c499a7134ac005b137877e61baf
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4700
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'support')
-rw-r--r-- | support/Random.h | 12 |
1 files changed, 7 insertions, 5 deletions
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 <random> #include <type_traits> @@ -43,13 +44,14 @@ template <typename T> class RangedUniformDistribution { public: - using DT = typename std::conditional<std::is_integral<T>::value, - std::uniform_int_distribution<T>, - std::uniform_real_distribution<float>>::type; + static constexpr bool is_half = std::is_same<T, half>::value; + static constexpr bool is_integral = std::is_integral<T>::value && !is_half; + + using fp_dist = typename std::conditional<is_half, arm_compute::utils::uniform_real_distribution_fp16, std::uniform_real_distribution<T>>::type; + using DT = typename std::conditional<is_integral, std::uniform_int_distribution<T>, fp_dist>::type; using result_type = T; using range_pair = std::pair<result_type, result_type>; -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<result_type>::value ? 1 : static_cast<result_type>(std::numeric_limits<float>::epsilon()); + result_type epsilon = is_integral ? result_type(1) : result_type(std::numeric_limits<T>::epsilon()); ARM_COMPUTE_ERROR_ON(clow > erange.first || clow >= erange.second); |