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 <bsgcomp@arm.com>
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
diff --git a/arm_compute/core/Window.inl b/arm_compute/core/Window.inl
index 18d454a..8401227 100644
--- a/arm_compute/core/Window.inl
+++ b/arm_compute/core/Window.inl
@@ -134,10 +134,13 @@
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)