blob: ce615327a95a049bd44234969fbb414ac93ce507 [file] [log] [blame]
Michalis Spyroue9362622018-11-23 17:41:37 +00001/*
Matthew Bentham92046462020-03-07 22:15:55 +00002 * Copyright (c) 2018-2020 ARM Limited.
Michalis Spyroue9362622018-11-23 17:41:37 +00003 *
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/CL/functions/CLElementWiseUnaryLayer.h"
25
26#include "arm_compute/core/CL/kernels/CLElementWiseUnaryLayerKernel.h"
Matthew Bentham92046462020-03-07 22:15:55 +000027#include "support/MemorySupport.h"
Michalis Spyroue9362622018-11-23 17:41:37 +000028
29#include <utility>
30
31namespace arm_compute
32{
33void CLRsqrtLayer::configure(const ICLTensor *input, ICLTensor *output)
34{
Manuel Bottini2b84be52020-04-08 10:15:51 +010035 configure(CLKernelLibrary::get().get_compile_context(), input, output);
36}
37
38void CLRsqrtLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
39{
Michalis Spyroue9362622018-11-23 17:41:37 +000040 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010041 k->configure(compile_context, input, output, ElementWiseUnary::RSQRT);
Michalis Spyroue9362622018-11-23 17:41:37 +000042 _kernel = std::move(k);
43}
44Status CLRsqrtLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
45{
46 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::RSQRT);
47}
48
49void CLExpLayer::configure(const ICLTensor *input, ICLTensor *output)
50{
Manuel Bottini2b84be52020-04-08 10:15:51 +010051 configure(CLKernelLibrary::get().get_compile_context(), input, output);
52}
53
54void CLExpLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
55{
Michalis Spyroue9362622018-11-23 17:41:37 +000056 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010057 k->configure(compile_context, input, output, ElementWiseUnary::EXP);
Michalis Spyroue9362622018-11-23 17:41:37 +000058 _kernel = std::move(k);
59}
60Status CLExpLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
61{
62 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::EXP);
63}
Usama Arifeb312ef2019-05-13 17:45:54 +010064
65void CLNegLayer::configure(const ICLTensor *input, ICLTensor *output)
66{
Manuel Bottini2b84be52020-04-08 10:15:51 +010067 configure(CLKernelLibrary::get().get_compile_context(), input, output);
68}
69
70void CLNegLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
71{
Usama Arifeb312ef2019-05-13 17:45:54 +010072 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010073 k->configure(compile_context, input, output, ElementWiseUnary::NEG);
Usama Arifeb312ef2019-05-13 17:45:54 +010074 _kernel = std::move(k);
75}
76Status CLNegLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
77{
78 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::NEG);
79}
80
Michalis Spyrou0af44182019-05-17 14:04:47 +010081void CLSinLayer::configure(const ICLTensor *input, ICLTensor *output)
82{
Manuel Bottini2b84be52020-04-08 10:15:51 +010083 configure(CLKernelLibrary::get().get_compile_context(), input, output);
84}
85
86void CLSinLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
87{
Michalis Spyrou0af44182019-05-17 14:04:47 +010088 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +010089 k->configure(compile_context, input, output, ElementWiseUnary::SIN);
Michalis Spyrou0af44182019-05-17 14:04:47 +010090 _kernel = std::move(k);
91}
92Status CLSinLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
93{
94 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::SIN);
95}
96
giuros01f24411f2019-05-16 11:47:13 +010097void CLAbsLayer::configure(const ICLTensor *input, ICLTensor *output)
98{
Manuel Bottini2b84be52020-04-08 10:15:51 +010099 configure(CLKernelLibrary::get().get_compile_context(), input, output);
100}
101
102void CLAbsLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
103{
giuros01f24411f2019-05-16 11:47:13 +0100104 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100105 k->configure(compile_context, input, output, ElementWiseUnary::ABS);
giuros01f24411f2019-05-16 11:47:13 +0100106 _kernel = std::move(k);
107}
108Status CLAbsLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
109{
110 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::ABS);
111}
Usama Arifac33d7e2019-05-20 14:21:40 +0100112void CLLogLayer::configure(const ICLTensor *input, ICLTensor *output)
113{
Manuel Bottini2b84be52020-04-08 10:15:51 +0100114 configure(CLKernelLibrary::get().get_compile_context(), input, output);
115}
116
117void CLLogLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
118{
Usama Arifac33d7e2019-05-20 14:21:40 +0100119 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100120 k->configure(compile_context, input, output, ElementWiseUnary::LOG);
Usama Arifac33d7e2019-05-20 14:21:40 +0100121 _kernel = std::move(k);
122}
123Status CLLogLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
124{
125 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::LOG);
126}
giuros01f24411f2019-05-16 11:47:13 +0100127
Usama Arif6a4d5422019-05-24 14:53:59 +0100128void CLRoundLayer::configure(const ICLTensor *input, ICLTensor *output)
129{
Manuel Bottini2b84be52020-04-08 10:15:51 +0100130 configure(CLKernelLibrary::get().get_compile_context(), input, output);
131}
132
133void CLRoundLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
134{
Usama Arif6a4d5422019-05-24 14:53:59 +0100135 auto k = arm_compute::support::cpp14::make_unique<CLElementWiseUnaryLayerKernel>();
Manuel Bottini2b84be52020-04-08 10:15:51 +0100136 k->configure(compile_context, input, output, ElementWiseUnary::ROUND);
Usama Arif6a4d5422019-05-24 14:53:59 +0100137 _kernel = std::move(k);
138}
139Status CLRoundLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
140{
141 return CLElementWiseUnaryLayerKernel::validate(input, output, ElementWiseUnary::ROUND);
142}
143
Michalis Spyroue9362622018-11-23 17:41:37 +0000144} // namespace arm_compute