diff options
author | Diego Lopez Recas <Diego.LopezRecas@arm.com> | 2017-12-18 11:28:27 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:43:10 +0000 |
commit | bcbc970f1f5b47f7314a5ad078820bc8a5edca94 (patch) | |
tree | 6bca70896b993adc80aea5e652d9e8dcefff3d8d /src/core/Helpers.cpp | |
parent | 1bfc7849950b67aeee382b08f27fd0b1b5ef0587 (diff) | |
download | ComputeLibrary-bcbc970f1f5b47f7314a5ad078820bc8a5edca94.tar.gz |
IVGCVSW-863 calculate_max_window..() family takes ValidRegion
Change-Id: I91e39713ffa580e9d2213988ad3517a8a41bf4e8
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114013
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/core/Helpers.cpp')
-rw-r--r-- | src/core/Helpers.cpp | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/src/core/Helpers.cpp b/src/core/Helpers.cpp index 151d7de9a4..3ee0fa7321 100644 --- a/src/core/Helpers.cpp +++ b/src/core/Helpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017 ARM Limited. + * Copyright (c) 2016, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -23,25 +23,17 @@ */ #include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/IKernel.h" -#include "arm_compute/core/ITensorInfo.h" -#include "arm_compute/core/Utils.h" - -#include <algorithm> -#include <cstdint> - using namespace arm_compute; -Window arm_compute::calculate_max_window(const ITensorInfo &info, const Steps &steps, bool skip_border, BorderSize border_size) +Window arm_compute::calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size) { if(!skip_border) { border_size = BorderSize(0); } - const Coordinates &anchor = info.valid_region().anchor; - const TensorShape &shape = info.valid_region().shape; + const Coordinates &anchor = valid_region.anchor; + const TensorShape &shape = valid_region.shape; Window window; @@ -53,10 +45,9 @@ Window arm_compute::calculate_max_window(const ITensorInfo &info, const Steps &s anchor[0] + border_size.left + ceil_to_multiple(std::max(0, static_cast<int>(shape[0]) - static_cast<int>(border_size.left) - static_cast<int>(border_size.right)), steps[0]), steps[0])); - size_t n = 1; - const TensorShape &tensor_shape = info.tensor_shape(); + size_t n = 1; - if(tensor_shape.num_dimensions() > 1) + if(anchor.num_dimensions() > 1) { window.set(1, Window::Dimension( // Skip the border above the image @@ -68,18 +59,23 @@ Window arm_compute::calculate_max_window(const ITensorInfo &info, const Steps &s ++n; } + for(; n < anchor.num_dimensions(); ++n) + { + window.set(n, Window::Dimension(anchor[n], std::max<size_t>(1, shape[n]))); + } + for(; n < Coordinates::num_max_dimensions; ++n) { - window.set(n, Window::Dimension(0, std::max<size_t>(1, tensor_shape[n]))); + window.set(n, Window::Dimension(0, 1)); } return window; } -Window arm_compute::calculate_max_enlarged_window(const ITensorInfo &info, const Steps &steps, BorderSize border_size) +Window arm_compute::calculate_max_enlarged_window(const ValidRegion &valid_region, const Steps &steps, BorderSize border_size) { - const Coordinates &anchor = info.valid_region().anchor; - const TensorShape &shape = info.valid_region().shape; + const Coordinates &anchor = valid_region.anchor; + const TensorShape &shape = valid_region.shape; Window window; @@ -91,10 +87,9 @@ Window arm_compute::calculate_max_enlarged_window(const ITensorInfo &info, const anchor[0] - border_size.left + ceil_to_multiple(shape[0] + border_size.left + border_size.right, steps[0]), steps[0])); - size_t n = 1; - const TensorShape &tensor_shape = info.tensor_shape(); + size_t n = 1; - if(tensor_shape.num_dimensions() > 1) + if(anchor.num_dimensions() > 1) { window.set(1, Window::Dimension( // Include the border above the image @@ -106,22 +101,27 @@ Window arm_compute::calculate_max_enlarged_window(const ITensorInfo &info, const ++n; } - if(tensor_shape.num_dimensions() > 2) + if(anchor.num_dimensions() > 2) { - window.set(2, Window::Dimension(0, std::max<size_t>(1, tensor_shape[n]), steps[2])); + window.set(2, Window::Dimension(0, std::max<size_t>(1, shape[n]), steps[2])); ++n; } + for(; n < anchor.num_dimensions(); ++n) + { + window.set(n, Window::Dimension(anchor[n], std::max<size_t>(1, shape[n]))); + } + for(; n < Coordinates::num_max_dimensions; ++n) { - window.set(n, Window::Dimension(0, std::max<size_t>(1, tensor_shape[n]))); + window.set(n, Window::Dimension(0, 1)); } return window; } -Window arm_compute::calculate_max_window_horizontal(const ITensorInfo &info, const Steps &steps, bool skip_border, BorderSize border_size) +Window arm_compute::calculate_max_window_horizontal(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size) { if(skip_border) { @@ -134,8 +134,8 @@ Window arm_compute::calculate_max_window_horizontal(const ITensorInfo &info, con border_size.right = 0; } - const Coordinates &anchor = info.valid_region().anchor; - const TensorShape &shape = info.valid_region().shape; + const Coordinates &anchor = valid_region.anchor; + const TensorShape &shape = valid_region.shape; Window window; @@ -147,10 +147,9 @@ Window arm_compute::calculate_max_window_horizontal(const ITensorInfo &info, con anchor[0] + border_size.left + ceil_to_multiple(std::max(0, static_cast<int>(shape[0]) - static_cast<int>(border_size.left) - static_cast<int>(border_size.right)), steps[0]), steps[0])); - size_t n = 1; - const TensorShape &tensor_shape = info.tensor_shape(); + size_t n = 1; - if(tensor_shape.num_dimensions() > 1) + if(anchor.num_dimensions() > 1) { window.set(1, Window::Dimension( // Skip the border above the image @@ -162,9 +161,14 @@ Window arm_compute::calculate_max_window_horizontal(const ITensorInfo &info, con ++n; } + for(; n < anchor.num_dimensions(); ++n) + { + window.set(n, Window::Dimension(anchor[n], std::max<size_t>(1, shape[n]))); + } + for(; n < Coordinates::num_max_dimensions; ++n) { - window.set(n, Window::Dimension(0, std::max<size_t>(1, tensor_shape[n]))); + window.set(n, Window::Dimension(0, 1)); } return window; |