blob: ce6d285ebe354a5480e5fad915b6bf38b63355e2 [file] [log] [blame]
giuros011e6e1b82019-05-14 16:12:53 +01001/*
Michele Di Giorgio1e0208a2021-01-22 15:42:59 +00002 * Copyright (c) 2019-2021 Arm Limited.
giuros011e6e1b82019-05-14 16:12:53 +01003 *
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 */
giuros011e6e1b82019-05-14 16:12:53 +010024#include "arm_compute/runtime/CL/functions/CLPReluLayer.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010025
Sang-Hoon Park5ff38da2021-03-02 09:41:13 +000026#include "arm_compute/core/CL/CLKernelLibrary.h"
27#include "arm_compute/core/CL/ICLTensor.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Georgios Pinitas7891a732021-08-20 21:39:25 +010029#include "src/gpu/cl/IClKernel.h"
30#include "src/gpu/cl/operators/ClPRelu.h"
giuros011e6e1b82019-05-14 16:12:53 +010031
32namespace arm_compute
33{
Sang-Hoon Park5ff38da2021-03-02 09:41:13 +000034using OperatorType = opencl::ClPRelu;
Michalis Spyrouad7515d2020-07-24 00:02:23 +010035
36struct CLPReluLayer::Impl
37{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010038 const ICLTensor *src_0{nullptr};
39 const ICLTensor *src_1{nullptr};
40 ICLTensor *dst{nullptr};
41 std::unique_ptr<OperatorType> op{nullptr};
Michalis Spyrouad7515d2020-07-24 00:02:23 +010042};
43
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010044CLPReluLayer::CLPReluLayer() : _impl(std::make_unique<Impl>())
Michalis Spyrouad7515d2020-07-24 00:02:23 +010045{
46}
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010047CLPReluLayer::CLPReluLayer(CLPReluLayer &&) = default;
Michalis Spyrouad7515d2020-07-24 00:02:23 +010048CLPReluLayer &CLPReluLayer::operator=(CLPReluLayer &&) = default;
49CLPReluLayer::~CLPReluLayer() = default;
50
51void CLPReluLayer::configure(ICLTensor *input, ICLTensor *alpha, ICLTensor *output)
52{
53 configure(CLKernelLibrary::get().get_compile_context(), input, alpha, output);
54}
55
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010056void CLPReluLayer::configure(const CLCompileContext &compile_context,
57 ICLTensor *input,
58 ICLTensor *alpha,
59 ICLTensor *output)
Michalis Spyrouad7515d2020-07-24 00:02:23 +010060{
61 _impl->src_0 = input;
62 _impl->src_1 = alpha;
63 _impl->dst = output;
Sang-Hoon Park5ff38da2021-03-02 09:41:13 +000064 _impl->op = std::make_unique<OperatorType>();
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010065 _impl->op->configure(compile_context, input->info(), alpha->info(),
66 (output == nullptr ? input->info() : output->info()));
Michalis Spyrouad7515d2020-07-24 00:02:23 +010067}
68
69Status CLPReluLayer::validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output)
70{
Sang-Hoon Park5ff38da2021-03-02 09:41:13 +000071 return OperatorType::validate(input, alpha, output);
Michalis Spyrouad7515d2020-07-24 00:02:23 +010072}
73
74void CLPReluLayer::run()
75{
Georgios Pinitas0499dff2020-07-31 22:21:38 +010076 ITensorPack pack;
77 pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0);
78 pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1);
79 pack.add_tensor(TensorType::ACL_DST, _impl->dst);
Michalis Spyrouad7515d2020-07-24 00:02:23 +010080
Georgios Pinitas0499dff2020-07-31 22:21:38 +010081 _impl->op->run(pack);
Michalis Spyrouad7515d2020-07-24 00:02:23 +010082}
giuros011e6e1b82019-05-14 16:12:53 +010083} // namespace arm_compute