From 9397515779a021638bc1b997f450c2b1f8e9ad93 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Fri, 8 Nov 2019 13:47:53 +0000 Subject: COMPMID-2855: NEReduceMean throws error for invalid configs Change-Id: I600507d0de19d7da6c1a13edcfff0a11ea6b5264 Signed-off-by: Pablo Tello Reviewed-on: https://review.mlplatform.org/c/2254 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Reviewed-by: Giorgio Arena Reviewed-by: Giuseppe Rossini Reviewed-by: Michalis Spyrou Reviewed-by: Manuel Bottini Reviewed-by: SiCong Li --- arm_compute/core/Helpers.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'arm_compute/core/Helpers.h') diff --git a/arm_compute/core/Helpers.h b/arm_compute/core/Helpers.h index 87b1fdf64c..8d526e96c0 100644 --- a/arm_compute/core/Helpers.h +++ b/arm_compute/core/Helpers.h @@ -766,6 +766,20 @@ inline T wrap_around(T x, T m) return x >= 0 ? x % m : (x % m + m) % m; } +/** Convert negative coordinates to positive in the range [0, num_dims_input] + * + * @param[out] coords Array of coordinates to be converted. + * @param[in] max_value Maximum value to be used when wrapping the negative values in coords + */ +inline Coordinates &convert_negative_axis(Coordinates &coords, int max_value) +{ + for(unsigned int i = 0; i < coords.num_dimensions(); ++i) + { + coords[i] = wrap_around(coords[i], max_value); + } + return coords; +} + /** Given an integer value, this function returns the next power of two * * @param[in] x Input value -- cgit v1.2.1