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 --- utils/Utils.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'utils/Utils.h') diff --git a/utils/Utils.h b/utils/Utils.h index b10d18aca2..7eeeae5419 100644 --- a/utils/Utils.h +++ b/utils/Utils.h @@ -296,20 +296,15 @@ inline void unmap(GCTensor &tensor) */ class uniform_real_distribution_fp16 { - half min{ 0.0f }, max{ 0.0f }; - std::uniform_real_distribution neg{ min, -0.3f }; - std::uniform_real_distribution pos{ 0.3f, max }; - std::uniform_int_distribution sign_picker{ 0, 1 }; - public: using result_type = half; /** Constructor * - * @param[in] a Minimum value of the distribution - * @param[in] b Maximum value of the distribution + * @param[in] min Minimum value of the distribution + * @param[in] max Maximum value of the distribution */ - explicit uniform_real_distribution_fp16(half a = half(0.0), half b = half(1.0)) - : min(a), max(b) + explicit uniform_real_distribution_fp16(half min = half(0.0), half max = half(1.0)) + : dist(min, max) { } @@ -319,12 +314,11 @@ public: */ half operator()(std::mt19937 &gen) { - if(sign_picker(gen)) - { - return (half)neg(gen); - } - return (half)pos(gen); + return half(dist(gen)); } + +private: + std::uniform_real_distribution dist; }; /** Numpy data loader */ -- cgit v1.2.1