From ea9e0dc18c408fecb6dc482b774bd900dd321610 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 28 Aug 2018 16:24:56 +0100 Subject: COMPMID-1469: Add validate in NEGEMMMatrixAdditionKernel Change-Id: I228e2503eb40c12869fbd7e834ac1309aa613480 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/145878 Reviewed-by: Giorgio Arena Tested-by: Jenkins --- src/core/CPP/ICPPSimpleKernel.cpp | 43 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'src/core/CPP/ICPPSimpleKernel.cpp') diff --git a/src/core/CPP/ICPPSimpleKernel.cpp b/src/core/CPP/ICPPSimpleKernel.cpp index 9d18a9c165..01fb016ffe 100644 --- a/src/core/CPP/ICPPSimpleKernel.cpp +++ b/src/core/CPP/ICPPSimpleKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017 ARM Limited. + * Copyright (c) 2016-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -27,7 +27,26 @@ #include "arm_compute/core/IAccessWindow.h" #include "arm_compute/core/ITensor.h" -using namespace arm_compute; +namespace arm_compute +{ +namespace +{ +std::pair validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, unsigned int num_elems_processed_per_iteration, + bool border_undefined, const arm_compute::BorderSize &border_size) +{ + // Configure kernel window + Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration), border_undefined, border_size); + AccessWindowHorizontal input_access(input, 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); + + bool window_changed = update_window_and_padding(win, input_access, output_access); + + output_access.set_valid_region(win, input->valid_region(), border_undefined, border_size); + + Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; + return std::make_pair(err, win); +} +} // namespace ICPPSimpleKernel::ICPPSimpleKernel() : _input{ nullptr }, _output{ nullptr } @@ -40,14 +59,16 @@ void ICPPSimpleKernel::configure(const ITensor *input, ITensor *output, unsigned _output = output; // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size); - AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(win, - AccessWindowHorizontal(input->info(), 0, num_elems_processed_per_iteration), - output_access); - - output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size); + auto win_config = validate_and_configure_window(input->info(), output->info(), num_elems_processed_per_iteration, border_undefined, border_size); + ARM_COMPUTE_ERROR_THROW_ON(win_config.first); + ICPPKernel::configure(win_config.second); +} - ICPPKernel::configure(win); +Status ICPPSimpleKernel::validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int num_elems_processed_per_iteration, + bool border_undefined, const arm_compute::BorderSize &border_size) +{ + ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get(), num_elems_processed_per_iteration, border_undefined, border_size).first); + return Status{}; } + +} // namespace arm_compute \ No newline at end of file -- cgit v1.2.1