diff options
author | Anthony Barbier <anthony.barbier@arm.com> | 2017-07-11 18:13:08 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | be35b0ed7cb6fbf9010142aab97854c467b14c5c (patch) | |
tree | bd654b559317e438a6703a09e243e4401d41d07d /arm_compute | |
parent | 7ff47a313d62011923c5307cc52510b4ba41a631 (diff) | |
download | ComputeLibrary-be35b0ed7cb6fbf9010142aab97854c467b14c5c.tar.gz |
COMPMID-443: Collapse higher dimensions for activation layer
Change-Id: I5943235aff1bb6440e3ab08e818d53aa5d94143a
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/80349
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r-- | arm_compute/core/Window.h | 11 | ||||
-rw-r--r-- | arm_compute/core/Window.inl | 29 |
2 files changed, 40 insertions, 0 deletions
diff --git a/arm_compute/core/Window.h b/arm_compute/core/Window.h index 6e7ef22531..a2fbc8f06f 100644 --- a/arm_compute/core/Window.h +++ b/arm_compute/core/Window.h @@ -326,6 +326,17 @@ public: return _num_threads; } + /* Collapse the dimensions higher than @p first if possible. + * + * A dimension is collapsable if it starts from 0 and matches the corresponding dimension in the full_window + * + * @param[in] full_window Full window @p window has been created from. + * @param[in] first Dimensions into which the following are collapsed. + * + * @return Collapsed window. + */ + Window collapse_if_possible(const Window &full_window, size_t first) const; + private: /** First slice of the window * diff --git a/arm_compute/core/Window.inl b/arm_compute/core/Window.inl index 75428a145b..c33613fcea 100644 --- a/arm_compute/core/Window.inl +++ b/arm_compute/core/Window.inl @@ -43,6 +43,35 @@ inline void Window::set(const size_t dimension, const Window::Dimension &dim) _dims[dimension] = dim; } +inline Window Window::collapse_if_possible(const Window &full_window, size_t first) const +{ + bool is_collapsable = false; + Window collapsed; + for(size_t d = 0; d < Coordinates::num_max_dimensions; ++d) + { + if(is_collapsable) + { + collapsed.set(first, Window::Dimension(collapsed[first].end() * _dims[d].start(), collapsed[first].end() * _dims[d].end())); + } + else + { + collapsed.set(d, _dims[d]); + } + + if(is_collapsable || d == first) // Try to start collapsing from this dimension + { + // The _dims's dimension must match the full _dims dimension to be collapsable: + is_collapsable = _dims[d].start() == 0 && _dims[d].start() == full_window[d].start() + && full_window[d].end() == _dims[d].end(); + } + else + { + is_collapsable = false; + } + } + return collapsed; +} + inline void Window::shift(const size_t dimension, const int shift_value) { ARM_COMPUTE_ERROR_ON(dimension >= Coordinates::num_max_dimensions); |