Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | 0094c02 | 2021-01-20 18:16:47 +0000 | [diff] [blame] | 2 | * Copyright (c) 2020-2021 Arm Limited. |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [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/runtime/NEON/functions/NELogical.h" |
| 25 | |
| 26 | #include "arm_compute/runtime/NEON/NEScheduler.h" |
| 27 | #include "arm_compute/runtime/Tensor.h" |
ramelg01 | cbbb038 | 2021-09-17 17:36:57 +0100 | [diff] [blame] | 28 | #include "src/common/utils/Log.h" |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 29 | #include "src/core/NEON/kernels/NELogicalKernel.h" |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | struct LogicalArgs |
| 34 | { |
| 35 | std::unique_ptr<kernels::NELogicalKernel> kernel{ nullptr }; |
| 36 | ITensorPack pack{}; |
| 37 | }; |
| 38 | |
| 39 | struct NELogicalAnd::Impl : public LogicalArgs |
| 40 | { |
| 41 | }; |
| 42 | NELogicalAnd::NELogicalAnd() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 43 | : _impl(std::make_unique<Impl>()) |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 44 | { |
| 45 | } |
Michele Di Giorgio | 13c497a | 2021-05-13 12:54:31 +0100 | [diff] [blame] | 46 | NELogicalAnd::~NELogicalAnd() = default; |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 47 | |
| 48 | void NELogicalAnd::configure(const ITensor *input1, const ITensor *input2, ITensor *output) |
| 49 | { |
| 50 | ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); |
ramelg01 | cbbb038 | 2021-09-17 17:36:57 +0100 | [diff] [blame] | 51 | ARM_COMPUTE_LOG_PARAMS(input1, input2, output); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 52 | |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 53 | _impl->kernel = std::make_unique<kernels::NELogicalKernel>(); |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 54 | _impl->kernel->configure(input1->info(), input2->info(), output->info(), LogicalOperation::And); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 55 | |
| 56 | _impl->pack = ITensorPack(); |
| 57 | _impl->pack.add_tensor(TensorType::ACL_SRC_0, input1); |
| 58 | _impl->pack.add_tensor(TensorType::ACL_SRC_1, input2); |
| 59 | _impl->pack.add_tensor(TensorType::ACL_DST, output); |
| 60 | } |
| 61 | |
| 62 | Status NELogicalAnd::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
| 63 | { |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 64 | return kernels::NELogicalKernel::validate(input1, input2, output, LogicalOperation::And); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void NELogicalAnd::run() |
| 68 | { |
Sang-Hoon Park | 0094c02 | 2021-01-20 18:16:47 +0000 | [diff] [blame] | 69 | NEScheduler::get().schedule_op(_impl->kernel.get(), Window::DimY, _impl->kernel->window(), _impl->pack); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | struct NELogicalOr::Impl : public LogicalArgs |
| 73 | { |
| 74 | }; |
| 75 | NELogicalOr::NELogicalOr() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 76 | : _impl(std::make_unique<Impl>()) |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 77 | { |
| 78 | } |
Michele Di Giorgio | 13c497a | 2021-05-13 12:54:31 +0100 | [diff] [blame] | 79 | NELogicalOr::~NELogicalOr() = default; |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 80 | |
| 81 | void NELogicalOr::configure(const ITensor *input1, const ITensor *input2, ITensor *output) |
| 82 | { |
| 83 | ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); |
ramelg01 | cbbb038 | 2021-09-17 17:36:57 +0100 | [diff] [blame] | 84 | ARM_COMPUTE_LOG_PARAMS(input1, input2, output); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 85 | |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 86 | _impl->kernel = std::make_unique<kernels::NELogicalKernel>(); |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 87 | _impl->kernel->configure(input1->info(), input2->info(), output->info(), LogicalOperation::Or); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 88 | |
| 89 | _impl->pack = ITensorPack(); |
| 90 | _impl->pack.add_tensor(TensorType::ACL_SRC_0, input1); |
| 91 | _impl->pack.add_tensor(TensorType::ACL_SRC_1, input2); |
| 92 | _impl->pack.add_tensor(TensorType::ACL_DST, output); |
| 93 | } |
| 94 | |
| 95 | Status NELogicalOr::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output) |
| 96 | { |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 97 | return kernels::NELogicalKernel::validate(input1, input2, output, LogicalOperation::Or); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | void NELogicalOr::run() |
| 101 | { |
Sang-Hoon Park | 0094c02 | 2021-01-20 18:16:47 +0000 | [diff] [blame] | 102 | NEScheduler::get().schedule_op(_impl->kernel.get(), Window::DimY, _impl->kernel->window(), _impl->pack); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | struct NELogicalNot::Impl : public LogicalArgs |
| 106 | { |
| 107 | }; |
| 108 | NELogicalNot::NELogicalNot() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 109 | : _impl(std::make_unique<Impl>()) |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 110 | { |
| 111 | } |
Michele Di Giorgio | 13c497a | 2021-05-13 12:54:31 +0100 | [diff] [blame] | 112 | NELogicalNot::~NELogicalNot() = default; |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 113 | |
| 114 | void NELogicalNot::configure(const ITensor *input, ITensor *output) |
| 115 | { |
| 116 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
ramelg01 | cbbb038 | 2021-09-17 17:36:57 +0100 | [diff] [blame] | 117 | ARM_COMPUTE_LOG_PARAMS(input, output); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 118 | |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 119 | _impl->kernel = std::make_unique<kernels::NELogicalKernel>(); |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 120 | _impl->kernel->configure(input->info(), nullptr, output->info(), LogicalOperation::Not); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 121 | |
| 122 | _impl->pack = ITensorPack(); |
| 123 | _impl->pack.add_tensor(TensorType::ACL_SRC_0, input); |
| 124 | _impl->pack.add_tensor(TensorType::ACL_DST, output); |
| 125 | } |
| 126 | |
| 127 | Status NELogicalNot::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 128 | { |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 129 | return kernels::NELogicalKernel::validate(input, nullptr, output, LogicalOperation::Not); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | void NELogicalNot::run() |
| 133 | { |
Sang-Hoon Park | 0094c02 | 2021-01-20 18:16:47 +0000 | [diff] [blame] | 134 | NEScheduler::get().schedule_op(_impl->kernel.get(), Window::DimY, _impl->kernel->window(), _impl->pack); |
Georgios Pinitas | 58bce68 | 2020-11-13 11:38:58 +0000 | [diff] [blame] | 135 | } |
| 136 | } // namespace arm_compute |