From b11e269be7a92197567ff1c3a532c1991180c810 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Mon, 25 Sep 2017 11:31:42 +0100 Subject: COMPMID-417 - Fix bad_alloc in ScaleFixture Change-Id: Ifc0b686a30512adbe3ec7e0ec28dd2990ccac347 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/88955 Tested-by: Kaizen Reviewed-by: Moritz Pflanzer --- tests/validation/fixtures/ScaleFixture.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/validation/fixtures/ScaleFixture.h b/tests/validation/fixtures/ScaleFixture.h index 6fa810aa96..476985e066 100644 --- a/tests/validation/fixtures/ScaleFixture.h +++ b/tests/validation/fixtures/ScaleFixture.h @@ -46,15 +46,22 @@ public: template void setup(TensorShape shape, DataType data_type, InterpolationPolicy policy, BorderMode border_mode) { + constexpr float max_width = 8192.0f; + constexpr float max_height = 6384.0f; + _shape = shape; _policy = policy; _border_mode = border_mode; _data_type = data_type; - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 4); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); + std::mt19937 generator(library->seed()); + std::uniform_real_distribution distribution_float(0.25, 3); + float scale_x = distribution_float(generator); + float scale_y = distribution_float(generator); + + scale_x = ((shape.x() * scale_x) > max_width) ? (max_width / shape.x()) : scale_x; + scale_y = ((shape.y() * scale_y) > max_height) ? (max_height / shape.y()) : scale_y; + std::uniform_int_distribution distribution_u8(0, 255); T constant_border_value = static_cast(distribution_u8(generator)); -- cgit v1.2.1