Michalis Spyrou | 1d38259 | 2018-08-13 17:28:04 +0100 | [diff] [blame] | 1 | /* |
Gian Marco Iodice | e214fcf | 2019-03-15 09:12:40 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 ARM Limited. |
Michalis Spyrou | 1d38259 | 2018-08-13 17:28:04 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/core/NEON/kernels/NECopyKernel.h" |
| 25 | |
| 26 | #include "arm_compute/core/Error.h" |
| 27 | #include "arm_compute/core/Helpers.h" |
| 28 | #include "arm_compute/core/ITensor.h" |
| 29 | #include "arm_compute/core/TensorInfo.h" |
| 30 | #include "arm_compute/core/Validate.h" |
| 31 | #include "arm_compute/core/Window.h" |
| 32 | |
| 33 | using namespace arm_compute; |
| 34 | |
| 35 | NECopyKernel::NECopyKernel() |
| 36 | : _input(nullptr), _output(nullptr) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | void NECopyKernel::configure(const ITensor *input, ITensor *output) |
| 41 | { |
| 42 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
| 43 | |
| 44 | _input = input; |
| 45 | _output = output; |
| 46 | |
| 47 | INEKernel::configure(calculate_max_window(*output->info())); |
| 48 | } |
| 49 | |
| 50 | Status NECopyKernel::validate(const arm_compute::ITensorInfo *input, const arm_compute::ITensorInfo *output) |
| 51 | { |
| 52 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); |
Michalis Spyrou | 1d38259 | 2018-08-13 17:28:04 +0100 | [diff] [blame] | 53 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
| 54 | return Status{}; |
| 55 | } |
| 56 | |
| 57 | void NECopyKernel::run(const Window &window, const ThreadInfo &info) |
| 58 | { |
| 59 | ARM_COMPUTE_UNUSED(info); |
| 60 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 61 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); |
| 62 | |
| 63 | Window output_window{ window }; |
| 64 | output_window.set(Window::DimX, Window::Dimension(output_window.x().start(), output_window.x().end(), _input->info()->dimension(0))); |
| 65 | |
| 66 | Window out_slice = output_window.first_slice_window_1D(); |
| 67 | |
| 68 | do |
| 69 | { |
| 70 | Iterator input_it(_input, out_slice); |
| 71 | Iterator output_it(_output, out_slice); |
| 72 | |
| 73 | execute_window_loop(out_slice, [&](const Coordinates & id) |
| 74 | { |
| 75 | memcpy(output_it.ptr(), input_it.ptr(), _output->info()->dimension(0) * _output->info()->element_size()); |
| 76 | }, |
| 77 | input_it, output_it); |
| 78 | |
| 79 | } |
| 80 | while(output_window.slide_window_slice_1D(out_slice)); |
| 81 | } |