blob: 914621183e1bdf5179306b5c7eb7ddaf22384b36 [file] [log] [blame]
Michele Di Giorgioc9c89052021-01-26 10:20:17 +00001/*
2 * Copyright (c) 2021 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 */
Georgios Pinitas7891a732021-08-20 21:39:25 +010024#include "src/gpu/cl/operators/ClElementwiseUnary.h"
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000025
ramelg012e53f172021-09-22 10:48:25 +010026#include "src/common/utils/Log.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010027#include "src/gpu/cl/kernels/ClElementwiseUnaryKernel.h"
ramelg012e53f172021-09-22 10:48:25 +010028
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000029namespace arm_compute
30{
31namespace opencl
32{
33void ClRsqrt::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
34{
ramelg012e53f172021-09-22 10:48:25 +010035 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000036 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
37 k->configure(compile_context, src, dst, ElementWiseUnary::RSQRT);
38 _kernel = std::move(k);
39}
40
41Status ClRsqrt::validate(const ITensorInfo *src, const ITensorInfo *dst)
42{
43 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::RSQRT);
44}
45
46void ClExp::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
47{
ramelg016d891572021-09-29 10:05:09 +010048 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000049 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
50 k->configure(compile_context, src, dst, ElementWiseUnary::EXP);
51 _kernel = std::move(k);
52}
53
54Status ClExp::validate(const ITensorInfo *src, const ITensorInfo *dst)
55{
56 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::EXP);
57}
58
59void ClNeg::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
60{
ramelg016d891572021-09-29 10:05:09 +010061 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000062 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
63 k->configure(compile_context, src, dst, ElementWiseUnary::NEG);
64 _kernel = std::move(k);
65}
66
67Status ClNeg::validate(const ITensorInfo *src, const ITensorInfo *dst)
68{
69 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::NEG);
70}
71
72void ClSin::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
73{
ramelg016d891572021-09-29 10:05:09 +010074 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000075 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
76 k->configure(compile_context, src, dst, ElementWiseUnary::SIN);
77 _kernel = std::move(k);
78}
79
80Status ClSin::validate(const ITensorInfo *src, const ITensorInfo *dst)
81{
82 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::SIN);
83}
84
85void ClAbs::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
86{
ramelg016d891572021-09-29 10:05:09 +010087 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +000088 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
89 k->configure(compile_context, src, dst, ElementWiseUnary::ABS);
90 _kernel = std::move(k);
91}
92
93Status ClAbs::validate(const ITensorInfo *src, const ITensorInfo *dst)
94{
95 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::ABS);
96}
97
98void ClLog::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
99{
ramelg016d891572021-09-29 10:05:09 +0100100 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000101 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
102 k->configure(compile_context, src, dst, ElementWiseUnary::LOG);
103 _kernel = std::move(k);
104}
105
106Status ClLog::validate(const ITensorInfo *src, const ITensorInfo *dst)
107{
108 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::LOG);
109}
110
111void ClRound::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst)
112{
ramelg016d891572021-09-29 10:05:09 +0100113 ARM_COMPUTE_LOG_PARAMS(src, dst);
Michele Di Giorgioc9c89052021-01-26 10:20:17 +0000114 auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>();
115 k->configure(compile_context, src, dst, ElementWiseUnary::ROUND);
116 _kernel = std::move(k);
117}
118
119Status ClRound::validate(const ITensorInfo *src, const ITensorInfo *dst)
120{
121 return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::ROUND);
122}
123} // namespace opencl
124} // namespace arm_compute