From 8795ffb03c1bb84a0d93e4ece153ceaa86118594 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 1 Dec 2017 16:13:40 +0000 Subject: COMPMID-700: Adds CPPPermute function Change-Id: I8f6adc67f6e6157710fca540f217d70e6f297217 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/111721 Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com Reviewed-by: Anthony Barbier --- arm_compute/core/Helpers.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'arm_compute/core/Helpers.h') diff --git a/arm_compute/core/Helpers.h b/arm_compute/core/Helpers.h index 13d1f6c99f..1be24e1841 100644 --- a/arm_compute/core/Helpers.h +++ b/arm_compute/core/Helpers.h @@ -33,6 +33,7 @@ #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" #include "arm_compute/core/Window.h" +#include "arm_compute/core/utils/misc/utility.h" #include #include @@ -459,6 +460,23 @@ inline Strides compute_strides(const ITensorInfo &info) return compute_strides(info, info.element_size()); } +/** Permutes given Dimensions according to a permutation vector + * + * @warning Validity of permutation is not checked + * + * @param[in, out] dimensions Dimensions to permute + * @param[in] perm Permutation vector + */ +template +inline void permute(Dimensions &dimensions, const PermutationVector &perm) +{ + auto copy_dimensions = utility::make_array::num_max_dimensions>(dimensions.begin(), dimensions.end()); + for(unsigned int i = 0; i < perm.num_dimensions(); ++i) + { + dimensions[i] = copy_dimensions[perm[i]]; + } +} + /* Auto initialize the tensor info (shape, number of channels, data type and fixed point position) if the current assignment is empty. * * @param[in,out] info Tensor info used to check and assign. -- cgit v1.2.1