aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2020-12-15 15:45:43 +0000
committerGiorgio Arena <giorgio.arena@arm.com>2020-12-17 13:08:07 +0000
commit6aeb2170d18824135acef2d5c16fb93c4488c1fe (patch)
treeb91c323eeae2ecccb8c42cd3c69f296298de7c4c /utils
parent72610dcf2d634c9c2919ad55245c5c91609e87eb (diff)
downloadComputeLibrary-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 'utils')
-rw-r--r--utils/Utils.h22
1 files changed, 8 insertions, 14 deletions
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<float> neg{ min, -0.3f };
- std::uniform_real_distribution<float> pos{ 0.3f, max };
- std::uniform_int_distribution<uint8_t> 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<float> dist;
};
/** Numpy data loader */