Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 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 | */ |
Jakub Sujak | ee301b3 | 2021-06-04 09:46:08 +0100 | [diff] [blame] | 24 | #include "arm_compute/runtime/CL/functions/CLElementwiseUnaryLayer.h" |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 25 | |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
| 27 | #include "arm_compute/core/CL/ICLTensor.h" |
| 28 | #include "src/core/CL/ICLKernel.h" |
| 29 | #include "src/runtime/gpu/cl/operators/ClElementwiseUnary.h" |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 33 | struct CLRsqrtLayer::Impl |
| 34 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 35 | const ICLTensor *src{ nullptr }; |
| 36 | ICLTensor *dst{ nullptr }; |
| 37 | std::unique_ptr<opencl::ClRsqrt> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | CLRsqrtLayer::CLRsqrtLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 41 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 42 | { |
| 43 | } |
| 44 | |
| 45 | CLRsqrtLayer::CLRsqrtLayer(CLRsqrtLayer &&) = default; |
| 46 | CLRsqrtLayer &CLRsqrtLayer::operator=(CLRsqrtLayer &&) = default; |
| 47 | CLRsqrtLayer::~CLRsqrtLayer() = default; |
| 48 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 49 | void CLRsqrtLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 50 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 51 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 52 | } |
| 53 | |
| 54 | void CLRsqrtLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 55 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 56 | _impl->src = input; |
| 57 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 58 | _impl->op = std::make_unique<opencl::ClRsqrt>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 59 | _impl->op->configure(compile_context, input->info(), output->info()); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 60 | } |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 61 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 62 | Status CLRsqrtLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 63 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 64 | return opencl::ClRsqrt::validate(input, output); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 67 | void CLRsqrtLayer::run() |
| 68 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 69 | ITensorPack pack; |
| 70 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 71 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 72 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | struct CLExpLayer::Impl |
| 76 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 77 | const ICLTensor *src{ nullptr }; |
| 78 | ICLTensor *dst{ nullptr }; |
| 79 | std::unique_ptr<opencl::ClExp> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | CLExpLayer::CLExpLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 83 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 84 | { |
| 85 | } |
| 86 | |
| 87 | CLExpLayer::CLExpLayer(CLExpLayer &&) = default; |
| 88 | CLExpLayer &CLExpLayer::operator=(CLExpLayer &&) = default; |
| 89 | CLExpLayer::~CLExpLayer() = default; |
| 90 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 91 | void CLExpLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 92 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 93 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 94 | } |
| 95 | |
| 96 | void CLExpLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 97 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 98 | _impl->src = input; |
| 99 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 100 | _impl->op = std::make_unique<opencl::ClExp>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 101 | _impl->op->configure(compile_context, input->info(), output->info()); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 102 | } |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 103 | |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 104 | Status CLExpLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 105 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 106 | return opencl::ClExp::validate(input, output); |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 107 | } |
Usama Arif | eb312ef | 2019-05-13 17:45:54 +0100 | [diff] [blame] | 108 | |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 109 | void CLExpLayer::run() |
| 110 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 111 | ITensorPack pack; |
| 112 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 113 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 114 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | struct CLNegLayer::Impl |
| 118 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 119 | const ICLTensor *src{ nullptr }; |
| 120 | ICLTensor *dst{ nullptr }; |
| 121 | std::unique_ptr<opencl::ClNeg> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | CLNegLayer::CLNegLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 125 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 126 | { |
| 127 | } |
| 128 | |
| 129 | CLNegLayer::CLNegLayer(CLNegLayer &&) = default; |
| 130 | CLNegLayer &CLNegLayer::operator=(CLNegLayer &&) = default; |
| 131 | CLNegLayer::~CLNegLayer() = default; |
| 132 | |
Usama Arif | eb312ef | 2019-05-13 17:45:54 +0100 | [diff] [blame] | 133 | void CLNegLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 134 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 135 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 136 | } |
| 137 | |
| 138 | void CLNegLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 139 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 140 | _impl->src = input; |
| 141 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 142 | _impl->op = std::make_unique<opencl::ClNeg>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 143 | _impl->op->configure(compile_context, input->info(), output->info()); |
Usama Arif | eb312ef | 2019-05-13 17:45:54 +0100 | [diff] [blame] | 144 | } |
| 145 | Status CLNegLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 146 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 147 | return opencl::ClNeg::validate(input, output); |
Usama Arif | eb312ef | 2019-05-13 17:45:54 +0100 | [diff] [blame] | 148 | } |
| 149 | |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 150 | void CLNegLayer::run() |
| 151 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 152 | ITensorPack pack; |
| 153 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 154 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 155 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | struct CLSinLayer::Impl |
| 159 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 160 | const ICLTensor *src{ nullptr }; |
| 161 | ICLTensor *dst{ nullptr }; |
| 162 | std::unique_ptr<opencl::ClSin> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | CLSinLayer::CLSinLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 166 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 167 | { |
| 168 | } |
| 169 | |
| 170 | CLSinLayer::CLSinLayer(CLSinLayer &&) = default; |
| 171 | CLSinLayer &CLSinLayer::operator=(CLSinLayer &&) = default; |
| 172 | CLSinLayer::~CLSinLayer() = default; |
| 173 | |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 174 | void CLSinLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 175 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 176 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 177 | } |
| 178 | |
| 179 | void CLSinLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 180 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 181 | _impl->src = input; |
| 182 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 183 | _impl->op = std::make_unique<opencl::ClSin>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 184 | _impl->op->configure(compile_context, input->info(), output->info()); |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 185 | } |
| 186 | Status CLSinLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 187 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 188 | return opencl::ClSin::validate(input, output); |
Michalis Spyrou | 0af4418 | 2019-05-17 14:04:47 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 191 | void CLSinLayer::run() |
| 192 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 193 | ITensorPack pack; |
| 194 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 195 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 196 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | struct CLAbsLayer::Impl |
| 200 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 201 | const ICLTensor *src{ nullptr }; |
| 202 | ICLTensor *dst{ nullptr }; |
| 203 | std::unique_ptr<opencl::ClAbs> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | CLAbsLayer::CLAbsLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 207 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 208 | { |
| 209 | } |
| 210 | |
| 211 | CLAbsLayer::CLAbsLayer(CLAbsLayer &&) = default; |
| 212 | CLAbsLayer &CLAbsLayer::operator=(CLAbsLayer &&) = default; |
| 213 | CLAbsLayer::~CLAbsLayer() = default; |
| 214 | |
giuros01 | f24411f | 2019-05-16 11:47:13 +0100 | [diff] [blame] | 215 | void CLAbsLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 216 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 217 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 218 | } |
| 219 | |
| 220 | void CLAbsLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 221 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 222 | _impl->src = input; |
| 223 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 224 | _impl->op = std::make_unique<opencl::ClAbs>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 225 | _impl->op->configure(compile_context, input->info(), output->info()); |
giuros01 | f24411f | 2019-05-16 11:47:13 +0100 | [diff] [blame] | 226 | } |
| 227 | Status CLAbsLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 228 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 229 | return opencl::ClAbs::validate(input, output); |
giuros01 | f24411f | 2019-05-16 11:47:13 +0100 | [diff] [blame] | 230 | } |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 231 | |
| 232 | void CLAbsLayer::run() |
| 233 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 234 | ITensorPack pack; |
| 235 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 236 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 237 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | struct CLLogLayer::Impl |
| 241 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 242 | const ICLTensor *src{ nullptr }; |
| 243 | ICLTensor *dst{ nullptr }; |
| 244 | std::unique_ptr<opencl::ClLog> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | CLLogLayer::CLLogLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 248 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 249 | { |
| 250 | } |
| 251 | |
| 252 | CLLogLayer::CLLogLayer(CLLogLayer &&) = default; |
| 253 | CLLogLayer &CLLogLayer::operator=(CLLogLayer &&) = default; |
| 254 | CLLogLayer::~CLLogLayer() = default; |
| 255 | |
Usama Arif | ac33d7e | 2019-05-20 14:21:40 +0100 | [diff] [blame] | 256 | void CLLogLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 257 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 258 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 259 | } |
| 260 | |
| 261 | void CLLogLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 262 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 263 | _impl->src = input; |
| 264 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 265 | _impl->op = std::make_unique<opencl::ClLog>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 266 | _impl->op->configure(compile_context, input->info(), output->info()); |
Usama Arif | ac33d7e | 2019-05-20 14:21:40 +0100 | [diff] [blame] | 267 | } |
| 268 | Status CLLogLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 269 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 270 | return opencl::ClLog::validate(input, output); |
Usama Arif | ac33d7e | 2019-05-20 14:21:40 +0100 | [diff] [blame] | 271 | } |
giuros01 | f24411f | 2019-05-16 11:47:13 +0100 | [diff] [blame] | 272 | |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 273 | void CLLogLayer::run() |
| 274 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 275 | ITensorPack pack; |
| 276 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 277 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 278 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | struct CLRoundLayer::Impl |
| 282 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 283 | const ICLTensor *src{ nullptr }; |
| 284 | ICLTensor *dst{ nullptr }; |
| 285 | std::unique_ptr<opencl::ClRound> op{ nullptr }; |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | CLRoundLayer::CLRoundLayer() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 289 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 290 | { |
| 291 | } |
| 292 | |
| 293 | CLRoundLayer::CLRoundLayer(CLRoundLayer &&) = default; |
| 294 | CLRoundLayer &CLRoundLayer::operator=(CLRoundLayer &&) = default; |
| 295 | CLRoundLayer::~CLRoundLayer() = default; |
| 296 | |
Usama Arif | 6a4d542 | 2019-05-24 14:53:59 +0100 | [diff] [blame] | 297 | void CLRoundLayer::configure(const ICLTensor *input, ICLTensor *output) |
| 298 | { |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 299 | configure(CLKernelLibrary::get().get_compile_context(), input, output); |
| 300 | } |
| 301 | |
| 302 | void CLRoundLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) |
| 303 | { |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 304 | _impl->src = input; |
| 305 | _impl->dst = output; |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 306 | _impl->op = std::make_unique<opencl::ClRound>(); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 307 | _impl->op->configure(compile_context, input->info(), output->info()); |
Usama Arif | 6a4d542 | 2019-05-24 14:53:59 +0100 | [diff] [blame] | 308 | } |
| 309 | Status CLRoundLayer::validate(const ITensorInfo *input, const ITensorInfo *output) |
| 310 | { |
Michele Di Giorgio | c9c8905 | 2021-01-26 10:20:17 +0000 | [diff] [blame] | 311 | return opencl::ClRound::validate(input, output); |
Usama Arif | 6a4d542 | 2019-05-24 14:53:59 +0100 | [diff] [blame] | 312 | } |
| 313 | |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 314 | void CLRoundLayer::run() |
| 315 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 316 | ITensorPack pack; |
| 317 | pack.add_tensor(TensorType::ACL_SRC, _impl->src); |
| 318 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
| 319 | _impl->op->run(pack); |
Michalis Spyrou | f738fe6 | 2020-07-15 18:10:17 +0100 | [diff] [blame] | 320 | } |
Michalis Spyrou | e936262 | 2018-11-23 17:41:37 +0000 | [diff] [blame] | 321 | } // namespace arm_compute |