Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 1 | /* |
| 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 Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 24 | #include "src/gpu/cl/operators/ClElementwiseUnary.h" |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 25 | |
ramelg01 | 2e53f17 | 2021-09-22 10:48:25 +0100 | [diff] [blame] | 26 | #include "src/common/utils/Log.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 27 | #include "src/gpu/cl/kernels/ClElementwiseUnaryKernel.h" |
ramelg01 | 2e53f17 | 2021-09-22 10:48:25 +0100 | [diff] [blame] | 28 | |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 29 | namespace arm_compute |
| 30 | { |
| 31 | namespace opencl |
| 32 | { |
| 33 | void ClRsqrt::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 34 | { |
ramelg01 | 2e53f17 | 2021-09-22 10:48:25 +0100 | [diff] [blame] | 35 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 36 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 37 | k->configure(compile_context, src, dst, ElementWiseUnary::RSQRT); |
| 38 | _kernel = std::move(k); |
| 39 | } |
| 40 | |
| 41 | Status ClRsqrt::validate(const ITensorInfo *src, const ITensorInfo *dst) |
| 42 | { |
| 43 | return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::RSQRT); |
| 44 | } |
| 45 | |
| 46 | void ClExp::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 47 | { |
ramelg01 | 6d89157 | 2021-09-29 10:05:09 +0100 | [diff] [blame] | 48 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 49 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 50 | k->configure(compile_context, src, dst, ElementWiseUnary::EXP); |
| 51 | _kernel = std::move(k); |
| 52 | } |
| 53 | |
| 54 | Status ClExp::validate(const ITensorInfo *src, const ITensorInfo *dst) |
| 55 | { |
| 56 | return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::EXP); |
| 57 | } |
| 58 | |
| 59 | void ClNeg::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 60 | { |
ramelg01 | 6d89157 | 2021-09-29 10:05:09 +0100 | [diff] [blame] | 61 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 62 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 63 | k->configure(compile_context, src, dst, ElementWiseUnary::NEG); |
| 64 | _kernel = std::move(k); |
| 65 | } |
| 66 | |
| 67 | Status ClNeg::validate(const ITensorInfo *src, const ITensorInfo *dst) |
| 68 | { |
| 69 | return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::NEG); |
| 70 | } |
| 71 | |
| 72 | void ClSin::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 73 | { |
ramelg01 | 6d89157 | 2021-09-29 10:05:09 +0100 | [diff] [blame] | 74 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 75 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 76 | k->configure(compile_context, src, dst, ElementWiseUnary::SIN); |
| 77 | _kernel = std::move(k); |
| 78 | } |
| 79 | |
| 80 | Status ClSin::validate(const ITensorInfo *src, const ITensorInfo *dst) |
| 81 | { |
| 82 | return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::SIN); |
| 83 | } |
| 84 | |
| 85 | void ClAbs::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 86 | { |
ramelg01 | 6d89157 | 2021-09-29 10:05:09 +0100 | [diff] [blame] | 87 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 88 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 89 | k->configure(compile_context, src, dst, ElementWiseUnary::ABS); |
| 90 | _kernel = std::move(k); |
| 91 | } |
| 92 | |
| 93 | Status ClAbs::validate(const ITensorInfo *src, const ITensorInfo *dst) |
| 94 | { |
| 95 | return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::ABS); |
| 96 | } |
| 97 | |
| 98 | void ClLog::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 99 | { |
ramelg01 | 6d89157 | 2021-09-29 10:05:09 +0100 | [diff] [blame] | 100 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 101 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 102 | k->configure(compile_context, src, dst, ElementWiseUnary::LOG); |
| 103 | _kernel = std::move(k); |
| 104 | } |
| 105 | |
| 106 | Status ClLog::validate(const ITensorInfo *src, const ITensorInfo *dst) |
| 107 | { |
| 108 | return kernels::ClElementWiseUnaryKernel::validate(src, dst, ElementWiseUnary::LOG); |
| 109 | } |
| 110 | |
| 111 | void ClRound::configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst) |
| 112 | { |
ramelg01 | 6d89157 | 2021-09-29 10:05:09 +0100 | [diff] [blame] | 113 | ARM_COMPUTE_LOG_PARAMS(src, dst); |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 114 | auto k = std::make_unique<kernels::ClElementWiseUnaryKernel>(); |
| 115 | k->configure(compile_context, src, dst, ElementWiseUnary::ROUND); |
| 116 | _kernel = std::move(k); |
| 117 | } |
| 118 | |
| 119 | Status 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 |