diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-08-28 16:24:56 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:54:54 +0000 |
commit | ea9e0dc18c408fecb6dc482b774bd900dd321610 (patch) | |
tree | b6e67a6559b53b5d4d97f77251d83ac73a6e55a5 /src/core/CPP | |
parent | 84797636b0ad44c16838df4177cf5a05aa929781 (diff) | |
download | ComputeLibrary-ea9e0dc18c408fecb6dc482b774bd900dd321610.tar.gz |
COMPMID-1469: Add validate in NEGEMMMatrixAdditionKernel
Change-Id: I228e2503eb40c12869fbd7e834ac1309aa613480
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/145878
Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CPP')
-rw-r--r-- | src/core/CPP/ICPPSimpleKernel.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
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<Status, Window> 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 |