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>
diff --git a/utils/Utils.h b/utils/Utils.h
index b10d18a..7eeeae5 100644
--- a/utils/Utils.h
+++ b/utils/Utils.h
@@ -296,20 +296,15 @@
*/
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 @@
*/
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 */