aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/Dimensions.h
diff options
context:
space:
mode:
authorDiego Lopez Recas <Diego.LopezRecas@arm.com>2017-12-18 14:42:56 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:45:00 +0000
commit0021d750d66d199c411df00cdd8308c325f1fef3 (patch)
treeb96e618977442a8aab335c136d369a958998d416 /arm_compute/core/Dimensions.h
parent5b6904b8d9cb5e8a343cde96fd5a8701f44dff90 (diff)
downloadComputeLibrary-0021d750d66d199c411df00cdd8308c325f1fef3.tar.gz
IVGCVSW-863 Broadcast support in CL/NEON Arithmetic Add
Also, added instrumentation to support generic tensor broadcasting for NEON and CL backends. Change-Id: I1bc5747a286e1a4b464c209067581e103d473b9a Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114201 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/core/Dimensions.h')
-rw-r--r--arm_compute/core/Dimensions.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/arm_compute/core/Dimensions.h b/arm_compute/core/Dimensions.h
index ae8d6c3503..58ffd7ff3c 100644
--- a/arm_compute/core/Dimensions.h
+++ b/arm_compute/core/Dimensions.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -135,23 +135,24 @@ public:
* @param[in] n Number of dimensions to collapse into @p first.
* @param[in] first Dimensions into which the following @p n are collapsed.
*/
- void collapse(size_t n, size_t first = 0)
+ void collapse(const size_t n, const size_t first = 0)
{
ARM_COMPUTE_ERROR_ON(first + n > _id.size());
- if(n == 0)
+ const size_t last = std::min(_num_dimensions, first + n);
+
+ if(last > (first + 1))
{
- return;
+ // Collapse dimensions into the first
+ _id[first] = std::accumulate(&_id[first], &_id[last], 1, std::multiplies<T>());
+ // Shift the remaining dimensions down
+ std::copy(&_id[last], &_id[_num_dimensions], &_id[first + 1]);
+ // Reduce the number of dimensions
+ const size_t old_num_dimensions = _num_dimensions;
+ _num_dimensions -= last - first - 1;
+ // Fill the now empty dimensions with zero
+ std::fill(&_id[_num_dimensions], &_id[old_num_dimensions], 0);
}
-
- // 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 -= std::min(n, _num_dimensions) - 1;
- // Fill the now empty dimensions with zero
- std::fill(_id.begin() + _num_dimensions, _id.end(), 0);
}
/** Collapse dimensions starting from a given point