diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-12-01 16:13:40 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:42:17 +0000 |
commit | 8795ffb03c1bb84a0d93e4ece153ceaa86118594 (patch) | |
tree | 87d6fec8a6422dd195a79c38bbe170afd7106fc3 /arm_compute/core/Helpers.h | |
parent | ab4907325ea264efc26b89ebad7e10522cb823e5 (diff) | |
download | ComputeLibrary-8795ffb03c1bb84a0d93e4ece153ceaa86118594.tar.gz |
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 <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute/core/Helpers.h')
-rw-r--r-- | arm_compute/core/Helpers.h | 18 |
1 files changed, 18 insertions, 0 deletions
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 <array> #include <cstddef> @@ -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 <typename T> +inline void permute(Dimensions<T> &dimensions, const PermutationVector &perm) +{ + auto copy_dimensions = utility::make_array<Dimensions<T>::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. |