From bcbc970f1f5b47f7314a5ad078820bc8a5edca94 Mon Sep 17 00:00:00 2001 From: Diego Lopez Recas Date: Mon, 18 Dec 2017 11:28:27 +0000 Subject: IVGCVSW-863 calculate_max_window..() family takes ValidRegion Change-Id: I91e39713ffa580e9d2213988ad3517a8a41bf4e8 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114013 Tested-by: Jenkins Reviewed-by: Anthony Barbier --- .../CL/kernels/CLDepthConcatenateLayerKernel.cpp | 4 +- .../CLLocallyConnectedMatrixMultiplyKernel.cpp | 4 +- .../kernels/GCDepthConcatenateLayerKernel.cpp | 2 +- .../kernels/GCGEMMMatrixMultiplyKernel.cpp | 2 +- .../kernels/GCGEMMTranspose1xWKernel.cpp | 4 +- src/core/Helpers.cpp | 68 ++++++++++++---------- .../NEON/kernels/NEDepthConcatenateLayerKernel.cpp | 4 +- .../kernels/NEGEMMLowpMatrixMultiplyKernel.cpp | 4 +- .../NEON/kernels/NEGEMMLowpReductionKernel.cpp | 6 +- src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp | 4 +- .../NELocallyConnectedMatrixMultiplyKernel.cpp | 4 +- src/core/SubTensorInfo.cpp | 6 +- src/core/TensorInfo.cpp | 14 ++--- 13 files changed, 61 insertions(+), 65 deletions(-) (limited to 'src/core') diff --git a/src/core/CL/kernels/CLDepthConcatenateLayerKernel.cpp b/src/core/CL/kernels/CLDepthConcatenateLayerKernel.cpp index 0275d4fd83..9b30c64130 100644 --- a/src/core/CL/kernels/CLDepthConcatenateLayerKernel.cpp +++ b/src/core/CL/kernels/CLDepthConcatenateLayerKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -103,7 +103,7 @@ void CLDepthConcatenateLayerKernel::configure(const ICLTensor *input, unsigned i AccessWindowRectangle input_access(input->info(), -_left_right, -_top_bottom, num_elems_read_per_iteration, num_rows_read_per_iteration); AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape())); ICLKernel::configure(win); } diff --git a/src/core/CL/kernels/CLLocallyConnectedMatrixMultiplyKernel.cpp b/src/core/CL/kernels/CLLocallyConnectedMatrixMultiplyKernel.cpp index 508fb899f1..a3af5b00ba 100644 --- a/src/core/CL/kernels/CLLocallyConnectedMatrixMultiplyKernel.cpp +++ b/src/core/CL/kernels/CLLocallyConnectedMatrixMultiplyKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -88,7 +88,7 @@ void CLLocallyConnectedMatrixMultiplyKernel::configure(const ICLTensor *input0, update_window_and_padding(win, input0_access, input1_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape())); ICLKernel::configure(win); } diff --git a/src/core/GLES_COMPUTE/kernels/GCDepthConcatenateLayerKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCDepthConcatenateLayerKernel.cpp index 1aac2502e7..4eceab8266 100644 --- a/src/core/GLES_COMPUTE/kernels/GCDepthConcatenateLayerKernel.cpp +++ b/src/core/GLES_COMPUTE/kernels/GCDepthConcatenateLayerKernel.cpp @@ -106,7 +106,7 @@ void GCDepthConcatenateLayerKernel::configure(const IGCTensor *input, unsigned i AccessWindowRectangle input_access(input->info(), -_left_right, -_top_bottom, num_elems_read_per_iteration, num_rows_read_per_iteration); AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape())); IGCKernel::configure(win); } diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp index 32fbbfeefb..a5f09e8eac 100644 --- a/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp +++ b/src/core/GLES_COMPUTE/kernels/GCGEMMMatrixMultiplyKernel.cpp @@ -106,7 +106,7 @@ void GCGEMMMatrixMultiplyKernel::configure(const IGCTensor *input0, const IGCTen update_window_and_padding(win, input0_access, input1_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape())); } else { diff --git a/src/core/GLES_COMPUTE/kernels/GCGEMMTranspose1xWKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCGEMMTranspose1xWKernel.cpp index c361b60f84..a78446e074 100644 --- a/src/core/GLES_COMPUTE/kernels/GCGEMMTranspose1xWKernel.cpp +++ b/src/core/GLES_COMPUTE/kernels/GCGEMMTranspose1xWKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -90,7 +90,7 @@ void GCGEMMTranspose1xWKernel::configure(const IGCTensor *input, IGCTensor *outp update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), input->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), input->info()->tensor_shape())); IGCKernel::configure(win); } 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 -#include - 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(shape[0]) - static_cast(border_size.left) - static_cast(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(1, shape[n]))); + } + for(; n < Coordinates::num_max_dimensions; ++n) { - window.set(n, Window::Dimension(0, std::max(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(1, tensor_shape[n]), steps[2])); + window.set(2, Window::Dimension(0, std::max(1, shape[n]), steps[2])); ++n; } + for(; n < anchor.num_dimensions(); ++n) + { + window.set(n, Window::Dimension(anchor[n], std::max(1, shape[n]))); + } + for(; n < Coordinates::num_max_dimensions; ++n) { - window.set(n, Window::Dimension(0, std::max(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(shape[0]) - static_cast(border_size.left) - static_cast(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(1, shape[n]))); + } + for(; n < Coordinates::num_max_dimensions; ++n) { - window.set(n, Window::Dimension(0, std::max(1, tensor_shape[n]))); + window.set(n, Window::Dimension(0, 1)); } return window; diff --git a/src/core/NEON/kernels/NEDepthConcatenateLayerKernel.cpp b/src/core/NEON/kernels/NEDepthConcatenateLayerKernel.cpp index 01b0f10f70..891a03c5cc 100644 --- a/src/core/NEON/kernels/NEDepthConcatenateLayerKernel.cpp +++ b/src/core/NEON/kernels/NEDepthConcatenateLayerKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -154,7 +154,7 @@ void NEDepthConcatenateLayerKernel::configure(const ITensor *input, unsigned int AccessWindowRectangle input_access(input->info(), -_left_right, -_top_bottom, num_elems_read_per_iteration, num_rows_read_per_iteration); AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape())); INEKernel::configure(win); } diff --git a/src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.cpp b/src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.cpp index 9104f0b98a..a100cd2bf6 100644 --- a/src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.cpp +++ b/src/core/NEON/kernels/NEGEMMLowpMatrixMultiplyKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -786,7 +786,7 @@ std::pair validate_and_configure_window(ITensorInfo *input0, ITe window_changed = update_window_and_padding(win, in0_access, in1_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape())); } Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; diff --git a/src/core/NEON/kernels/NEGEMMLowpReductionKernel.cpp b/src/core/NEON/kernels/NEGEMMLowpReductionKernel.cpp index 0aadfc941c..c1ee770db5 100644 --- a/src/core/NEON/kernels/NEGEMMLowpReductionKernel.cpp +++ b/src/core/NEON/kernels/NEGEMMLowpReductionKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -64,7 +64,7 @@ std::pair validate_and_configure_window_matrix_a_reduction(ITens bool window_changed = update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape())); Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; return std::make_pair(err, win); @@ -90,7 +90,7 @@ std::pair validate_and_configure_window_matrix_b_reduction(ITens bool window_changed = update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape())); Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; return std::make_pair(err, win); diff --git a/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp b/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp index a88dc655c1..5d6163d583 100644 --- a/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp +++ b/src/core/NEON/kernels/NEGEMMTranspose1xWKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017 ARM Limited. + * Copyright (c) 2016, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -89,7 +89,7 @@ std::pair validate_and_configure_window(ITensorInfo *input, ITen { AccessWindowTranspose output_access(output, 0, 0, num_elems_processed_per_iteration, 1, scale_x, 1.f / scale_x); window_changed = window_changed || update_window_and_padding(win, output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), input->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), input->tensor_shape())); } Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; diff --git a/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp b/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp index 52e30066de..58da0402bc 100644 --- a/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp +++ b/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -333,7 +333,7 @@ void NELocallyConnectedMatrixMultiplyKernel::configure(const ITensor *input0, co AccessWindowHorizontal(input1->info(), 0, num_elems_processed_per_iteration_x), output_access); - output_access.set_valid_region(win, ValidRegion(Coordinates(0, 0), output->info()->tensor_shape())); + output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape())); INEKernel::configure(win); } diff --git a/src/core/SubTensorInfo.cpp b/src/core/SubTensorInfo.cpp index 8acd71ceb0..7a4886ff60 100644 --- a/src/core/SubTensorInfo.cpp +++ b/src/core/SubTensorInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -46,9 +46,7 @@ SubTensorInfo::SubTensorInfo(ITensorInfo *parent, TensorShape tensor_shape, Coor } // Initialize valid region - Coordinates coordinates; - coordinates.set_num_dimensions(_tensor_shape.num_dimensions()); - _valid_region = ValidRegion{ coordinates, _tensor_shape }; + _valid_region = ValidRegion{ Coordinates(), _tensor_shape }; } std::unique_ptr SubTensorInfo::clone() const diff --git a/src/core/TensorInfo.cpp b/src/core/TensorInfo.cpp index 60e76bf84a..2008217c85 100644 --- a/src/core/TensorInfo.cpp +++ b/src/core/TensorInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017 ARM Limited. + * Copyright (c) 2016, 2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -159,9 +159,7 @@ void TensorInfo::init(const TensorShape &tensor_shape, size_t num_channels, Data _strides_in_bytes = strides_in_bytes; _total_size = total_size_in_bytes; - Coordinates coordinates; - coordinates.set_num_dimensions(_tensor_shape.num_dimensions()); - _valid_region = ValidRegion{ coordinates, _tensor_shape }; + _valid_region = ValidRegion{ Coordinates(), _tensor_shape }; } void TensorInfo::init(const HOGInfo &hog_info, unsigned int width, unsigned int height) @@ -201,9 +199,7 @@ size_t TensorInfo::init_auto_padding(const TensorShape &tensor_shape, size_t num _format = Format::UNKNOWN; _tensor_shape = tensor_shape; - Coordinates coordinates; - coordinates.set_num_dimensions(_tensor_shape.num_dimensions()); - _valid_region = ValidRegion{ coordinates, _tensor_shape }; + _valid_region = ValidRegion{ Coordinates(), _tensor_shape }; auto_padding(); @@ -368,9 +364,7 @@ ITensorInfo &TensorInfo::set_tensor_shape(TensorShape shape) _total_size = _tensor_shape[idx_last_dimension] * _strides_in_bytes[idx_last_dimension]; } - Coordinates coordinates; - coordinates.set_num_dimensions(_tensor_shape.num_dimensions()); - _valid_region = ValidRegion{ coordinates, _tensor_shape }; + _valid_region = ValidRegion{ Coordinates(), _tensor_shape }; return *this; } -- cgit v1.2.1