From 7d920f4ce6e9b7b0f6d03fcac2c9598122de5404 Mon Sep 17 00:00:00 2001 From: Anthony Barbier Date: Mon, 4 Jun 2018 14:09:09 +0100 Subject: COMPMID-1246 Fixed Window::scale() - There used to be two problems with scale(): - The first argument of ceil_to_multiple was promoted to float which broke the function (For example ceil_to_multiple( 24.0, 8 ) will return 31. - "End - start" needs to be a multiple of step, not "end" (e.g start=1, end =5, step =4 is a valid dimension) The reason it didn't break before is because Window::scale() was only used on windows used by iterators, and therefore the "end" value is not used in that context. Change-Id: I1798db73014294ac82eed53c74eec3d4b8cb7d59 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/133967 Tested-by: Jenkins Reviewed-by: Pablo Tello --- arm_compute/core/Window.inl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'arm_compute/core/Window.inl') diff --git a/arm_compute/core/Window.inl b/arm_compute/core/Window.inl index 18d454a0cb..8401227eee 100644 --- a/arm_compute/core/Window.inl +++ b/arm_compute/core/Window.inl @@ -134,10 +134,13 @@ inline void Window::adjust(size_t dimension, int adjust_value, bool is_at_start) inline void Window::scale(size_t dimension, float scale_value) { ARM_COMPUTE_ERROR_ON(dimension >= Coordinates::num_max_dimensions); - Window::Dimension &d = _dims[dimension]; - const int scaled_step = d.step() * scale_value; - const int scaled_end = ceil_to_multiple(d.end() * scale_value, scaled_step); - d = Window::Dimension(d.start() * scale_value, scaled_end, scaled_step); + Window::Dimension &d = _dims[dimension]; + const int scaled_step = d.step() * scale_value; + const int scaled_start = d.start() * scale_value; + const int scaled_diff = (d.end() - d.start()) * scale_value; + const int scaled_end = scaled_start + ceil_to_multiple(scaled_diff, scaled_step); + + d = Window::Dimension(scaled_start, scaled_end, scaled_step); } inline void Window::set_dimension_step(size_t dimension, int step) -- cgit v1.2.1