From 42ab899e159720eb87765d93e6ae765b220a8840 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Fri, 4 Aug 2017 10:54:55 +0100 Subject: COMPMID-417 - Added method to shift down the dimensions of a tensor shape Change-Id: I71b24ac35670824ae3d27710d45519761b0dbcf0 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/82872 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- arm_compute/core/TensorShape.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'arm_compute/core/TensorShape.h') diff --git a/arm_compute/core/TensorShape.h b/arm_compute/core/TensorShape.h index 17348e4fc6..6cf08de114 100644 --- a/arm_compute/core/TensorShape.h +++ b/arm_compute/core/TensorShape.h @@ -92,6 +92,29 @@ public: apply_dimension_correction(); } + /** Accessor to remove the dimension n from the tensor shape. + * + * @note The upper dimensions of the tensor shape will be shifted down by 1 + * + * @param[in] n Dimension to remove + */ + void remove_dimension(size_t n) + { + ARM_COMPUTE_ERROR_ON(_num_dimensions < 1); + ARM_COMPUTE_ERROR_ON(n >= _num_dimensions); + + std::copy(_id.begin() + n + 1, _id.end(), _id.begin() + n); + + // Reduce number of dimensions + _num_dimensions--; + + // Make sure all empty dimensions are filled with 1 + std::fill(_id.begin() + _num_dimensions, _id.end(), 1); + + // Correct number dimensions to ignore trailing dimensions of size 1 + apply_dimension_correction(); + } + /** Collapse the first n dimensions. * * @param[in] first Dimensions into which the following @p n are collapsed. -- cgit v1.2.1