blob: 2c9ebd5f299f450e0de00380006ed2feb9f5b678 [file] [log] [blame]
Georgios Pinitas58bce682020-11-13 11:38:58 +00001/*
2 * Copyright (c) 2020 Arm Limited.
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"
28#include "src/core/NEON/kernels/NELogicalKernel.h"
Georgios Pinitas58bce682020-11-13 11:38:58 +000029
30namespace arm_compute
31{
32struct LogicalArgs
33{
34 std::unique_ptr<kernels::NELogicalKernel> kernel{ nullptr };
35 ITensorPack pack{};
36};
37
38struct NELogicalAnd::Impl : public LogicalArgs
39{
40};
41NELogicalAnd::NELogicalAnd()
Georgios Pinitas40f51a62020-11-21 03:04:18 +000042 : _impl(std::make_unique<Impl>())
Georgios Pinitas58bce682020-11-13 11:38:58 +000043{
44}
45NELogicalAnd &NELogicalAnd::operator=(NELogicalAnd &&) = default;
46NELogicalAnd::~NELogicalAnd() = default;
47
48void NELogicalAnd::configure(const ITensor *input1, const ITensor *input2, ITensor *output)
49{
50 ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
51
Georgios Pinitas40f51a62020-11-21 03:04:18 +000052 _impl->kernel = std::make_unique<kernels::NELogicalKernel>();
Georgios Pinitas58bce682020-11-13 11:38:58 +000053 _impl->kernel->configure(input1->info(), input2->info(), output->info(), kernels::LogicalOperation::And);
54
55 _impl->pack = ITensorPack();
56 _impl->pack.add_tensor(TensorType::ACL_SRC_0, input1);
57 _impl->pack.add_tensor(TensorType::ACL_SRC_1, input2);
58 _impl->pack.add_tensor(TensorType::ACL_DST, output);
59}
60
61Status NELogicalAnd::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
62{
63 return kernels::NELogicalKernel::validate(input1, input2, output, kernels::LogicalOperation::And);
64}
65
66void NELogicalAnd::run()
67{
68 NEScheduler::get().schedule_op(_impl->kernel.get(), Window::DimY, _impl->pack);
69}
70
71struct NELogicalOr::Impl : public LogicalArgs
72{
73};
74NELogicalOr::NELogicalOr()
Georgios Pinitas40f51a62020-11-21 03:04:18 +000075 : _impl(std::make_unique<Impl>())
Georgios Pinitas58bce682020-11-13 11:38:58 +000076{
77}
78NELogicalOr &NELogicalOr::operator=(NELogicalOr &&) = default;
79NELogicalOr::~NELogicalOr() = default;
80
81void NELogicalOr::configure(const ITensor *input1, const ITensor *input2, ITensor *output)
82{
83 ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
84
Georgios Pinitas40f51a62020-11-21 03:04:18 +000085 _impl->kernel = std::make_unique<kernels::NELogicalKernel>();
Georgios Pinitas58bce682020-11-13 11:38:58 +000086 _impl->kernel->configure(input1->info(), input2->info(), output->info(), kernels::LogicalOperation::Or);
87
88 _impl->pack = ITensorPack();
89 _impl->pack.add_tensor(TensorType::ACL_SRC_0, input1);
90 _impl->pack.add_tensor(TensorType::ACL_SRC_1, input2);
91 _impl->pack.add_tensor(TensorType::ACL_DST, output);
92}
93
94Status NELogicalOr::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
95{
96 return kernels::NELogicalKernel::validate(input1, input2, output, kernels::LogicalOperation::Or);
97}
98
99void NELogicalOr::run()
100{
101 NEScheduler::get().schedule_op(_impl->kernel.get(), Window::DimY, _impl->pack);
102}
103
104struct NELogicalNot::Impl : public LogicalArgs
105{
106};
107NELogicalNot::NELogicalNot()
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000108 : _impl(std::make_unique<Impl>())
Georgios Pinitas58bce682020-11-13 11:38:58 +0000109{
110}
111NELogicalNot &NELogicalNot::operator=(NELogicalNot &&) = default;
112NELogicalNot::~NELogicalNot() = default;
113
114void NELogicalNot::configure(const ITensor *input, ITensor *output)
115{
116 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
117
Georgios Pinitas40f51a62020-11-21 03:04:18 +0000118 _impl->kernel = std::make_unique<kernels::NELogicalKernel>();
Georgios Pinitas58bce682020-11-13 11:38:58 +0000119 _impl->kernel->configure(input->info(), nullptr, output->info(), kernels::LogicalOperation::Not);
120
121 _impl->pack = ITensorPack();
122 _impl->pack.add_tensor(TensorType::ACL_SRC_0, input);
123 _impl->pack.add_tensor(TensorType::ACL_DST, output);
124}
125
126Status NELogicalNot::validate(const ITensorInfo *input, const ITensorInfo *output)
127{
128 return kernels::NELogicalKernel::validate(input, nullptr, output, kernels::LogicalOperation::Not);
129}
130
131void NELogicalNot::run()
132{
133 NEScheduler::get().schedule_op(_impl->kernel.get(), Window::DimY, _impl->pack);
134}
135} // namespace arm_compute