diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-07-05 15:54:42 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | 1b31afc07fe7faf52ad4ae15dcb4b61dc3742816 (patch) | |
tree | 6d9d5fe179b3dc0dfc74f21e30b6b1beee0ad5b6 /arm_compute/core | |
parent | b93f5de2676ce0608b283a8f10213ff1c0d2489e (diff) | |
download | ComputeLibrary-1b31afc07fe7faf52ad4ae15dcb4b61dc3742816.tar.gz |
COMPMID-417: Fix Dimensions::collapse
Number of dimensions was reduced to zero if more dimensions than
available were requested to be collapsed. Correct result is to keep at
least one dimension.
Change-Id: I094c3f2f41411913a2ac417b42310416642fb5a8
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79801
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'arm_compute/core')
-rw-r--r-- | arm_compute/core/Dimensions.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arm_compute/core/Dimensions.h b/arm_compute/core/Dimensions.h index b080435b69..d2131018fa 100644 --- a/arm_compute/core/Dimensions.h +++ b/arm_compute/core/Dimensions.h @@ -126,12 +126,17 @@ public: { ARM_COMPUTE_ERROR_ON(first + n > _id.size()); + if(n == 0) + { + return; + } + // Collapse dimensions into the first _id[first] = std::accumulate(_id.cbegin() + first, _id.cbegin() + first + n, 1, std::multiplies<T>()); // Shift the remaining dimensions down std::copy(_id.begin() + first + n, _id.end(), _id.begin() + first + 1); // Reduce the number of dimensions - _num_dimensions -= n - 1; + _num_dimensions -= std::min(n, _num_dimensions) - 1; // Fill the now empty dimensions with zero std::fill(_id.begin() + _num_dimensions, _id.end(), 0); } |