giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
giuros01 | 164a272 | 2018-11-20 18:34:46 +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 | */ |
giuros01 | 1e6e1b8 | 2019-05-14 16:12:53 +0100 | [diff] [blame] | 24 | #include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h" |
| 25 | |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/CL/ICLTensor.h" |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/Types.h" |
| 29 | #include "src/core/CL/ICLKernel.h" |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 30 | |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 31 | #include "src/gpu/cl/operators/ClAdd.h" |
| 32 | #include "src/gpu/cl/operators/ClElementwiseOperations.h" |
| 33 | #include "src/gpu/cl/operators/ClSub.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 34 | |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 35 | namespace arm_compute |
| 36 | { |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 37 | struct CLArithmeticAddition::Impl |
| 38 | { |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 39 | const ICLTensor *src_0{ nullptr }; |
| 40 | const ICLTensor *src_1{ nullptr }; |
| 41 | ICLTensor *dst{ nullptr }; |
| 42 | std::unique_ptr<opencl::ClAdd> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | CLArithmeticAddition::CLArithmeticAddition() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 46 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 47 | { |
| 48 | } |
| 49 | CLArithmeticAddition::CLArithmeticAddition(CLArithmeticAddition &&) = default; |
| 50 | CLArithmeticAddition &CLArithmeticAddition::operator=(CLArithmeticAddition &&) = default; |
| 51 | CLArithmeticAddition::~CLArithmeticAddition() = default; |
| 52 | |
| 53 | void CLArithmeticAddition::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 54 | { |
| 55 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info); |
| 56 | } |
| 57 | |
| 58 | void CLArithmeticAddition::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, |
| 59 | const ActivationLayerInfo &act_info) |
| 60 | { |
| 61 | _impl->src_0 = input1; |
| 62 | _impl->src_1 = input2; |
| 63 | _impl->dst = output; |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 64 | _impl->op = std::make_unique<opencl::ClAdd>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 65 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info); |
| 66 | } |
| 67 | |
| 68 | Status CLArithmeticAddition::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 69 | { |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 70 | return opencl::ClAdd::validate(input1, input2, output, policy, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void CLArithmeticAddition::run() |
| 74 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 75 | ITensorPack pack; |
| 76 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 77 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 78 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 79 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 80 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | struct CLArithmeticSubtraction::Impl |
| 84 | { |
Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 85 | const ICLTensor *src_0{ nullptr }; |
| 86 | const ICLTensor *src_1{ nullptr }; |
| 87 | ICLTensor *dst{ nullptr }; |
| 88 | std::unique_ptr<opencl::ClSub> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | CLArithmeticSubtraction::CLArithmeticSubtraction() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 92 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 93 | { |
| 94 | } |
| 95 | CLArithmeticSubtraction::CLArithmeticSubtraction(CLArithmeticSubtraction &&) = default; |
| 96 | CLArithmeticSubtraction &CLArithmeticSubtraction::operator=(CLArithmeticSubtraction &&) = default; |
| 97 | CLArithmeticSubtraction::~CLArithmeticSubtraction() = default; |
| 98 | |
| 99 | void CLArithmeticSubtraction::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 100 | { |
| 101 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, policy, act_info); |
| 102 | } |
| 103 | |
| 104 | void CLArithmeticSubtraction::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy, |
| 105 | const ActivationLayerInfo &act_info) |
| 106 | { |
| 107 | _impl->src_0 = input1; |
| 108 | _impl->src_1 = input2; |
| 109 | _impl->dst = output; |
Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 110 | _impl->op = std::make_unique<opencl::ClSub>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 111 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), policy, act_info); |
| 112 | } |
| 113 | |
| 114 | Status CLArithmeticSubtraction::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info) |
| 115 | { |
Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 116 | return opencl::ClSub::validate(input1, input2, output, policy, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | void CLArithmeticSubtraction::run() |
| 120 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 121 | ITensorPack pack; |
| 122 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 123 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 124 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 125 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 126 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | struct CLArithmeticDivision::Impl |
| 130 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 131 | const ICLTensor *src_0{ nullptr }; |
| 132 | const ICLTensor *src_1{ nullptr }; |
| 133 | ICLTensor *dst{ nullptr }; |
| 134 | std::unique_ptr<opencl::ClElementwiseDivision> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | CLArithmeticDivision::CLArithmeticDivision() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 138 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 139 | { |
| 140 | } |
| 141 | CLArithmeticDivision::CLArithmeticDivision(CLArithmeticDivision &&) = default; |
| 142 | CLArithmeticDivision &CLArithmeticDivision::operator=(CLArithmeticDivision &&) = default; |
| 143 | CLArithmeticDivision::~CLArithmeticDivision() = default; |
| 144 | |
| 145 | void CLArithmeticDivision::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 146 | { |
| 147 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 148 | } |
| 149 | |
| 150 | void CLArithmeticDivision::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 151 | { |
| 152 | _impl->src_0 = input1; |
| 153 | _impl->src_1 = input2; |
| 154 | _impl->dst = output; |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 155 | _impl->op = std::make_unique<opencl::ClElementwiseDivision>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 156 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 157 | } |
| 158 | |
| 159 | Status CLArithmeticDivision::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 160 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 161 | return opencl::ClElementwiseDivision::validate(input1, input2, output, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | void CLArithmeticDivision::run() |
| 165 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 166 | ITensorPack pack; |
| 167 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 168 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 169 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 170 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 171 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | struct CLElementwiseMax::Impl |
| 175 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 176 | const ICLTensor *src_0{ nullptr }; |
| 177 | const ICLTensor *src_1{ nullptr }; |
| 178 | ICLTensor *dst{ nullptr }; |
| 179 | std::unique_ptr<opencl::ClElementwiseMax> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | CLElementwiseMax::CLElementwiseMax() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 183 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 184 | { |
| 185 | } |
| 186 | CLElementwiseMax::CLElementwiseMax(CLElementwiseMax &&) = default; |
| 187 | CLElementwiseMax &CLElementwiseMax::operator=(CLElementwiseMax &&) = default; |
| 188 | CLElementwiseMax::~CLElementwiseMax() = default; |
| 189 | |
| 190 | void CLElementwiseMax::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 191 | { |
| 192 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 193 | } |
| 194 | |
| 195 | void CLElementwiseMax::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 196 | { |
| 197 | _impl->src_0 = input1; |
| 198 | _impl->src_1 = input2; |
| 199 | _impl->dst = output; |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 200 | _impl->op = std::make_unique<opencl::ClElementwiseMax>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 201 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 202 | } |
| 203 | |
| 204 | Status CLElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 205 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 206 | return opencl::ClElementwiseMax::validate(input1, input2, output, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | void CLElementwiseMax::run() |
| 210 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 211 | ITensorPack pack; |
| 212 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 213 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 214 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 215 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 216 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | struct CLElementwiseMin::Impl |
| 220 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 221 | const ICLTensor *src_0{ nullptr }; |
| 222 | const ICLTensor *src_1{ nullptr }; |
| 223 | ICLTensor *dst{ nullptr }; |
| 224 | std::unique_ptr<opencl::ClElementwiseMin> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | CLElementwiseMin::CLElementwiseMin() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 228 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 229 | { |
| 230 | } |
| 231 | CLElementwiseMin::CLElementwiseMin(CLElementwiseMin &&) = default; |
| 232 | CLElementwiseMin &CLElementwiseMin::operator=(CLElementwiseMin &&) = default; |
| 233 | CLElementwiseMin::~CLElementwiseMin() = default; |
| 234 | |
| 235 | void CLElementwiseMin::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 236 | { |
| 237 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 238 | } |
| 239 | |
| 240 | void CLElementwiseMin::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 241 | { |
| 242 | _impl->src_0 = input1; |
| 243 | _impl->src_1 = input2; |
| 244 | _impl->dst = output; |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 245 | _impl->op = std::make_unique<opencl::ClElementwiseMin>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 246 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 247 | } |
| 248 | |
| 249 | Status CLElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 250 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 251 | return opencl::ClElementwiseMin::validate(input1, input2, output, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | void CLElementwiseMin::run() |
| 255 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 256 | ITensorPack pack; |
| 257 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 258 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 259 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 260 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 261 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | struct CLElementwiseSquaredDiff::Impl |
| 265 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 266 | const ICLTensor *src_0{ nullptr }; |
| 267 | const ICLTensor *src_1{ nullptr }; |
| 268 | ICLTensor *dst{ nullptr }; |
| 269 | std::unique_ptr<opencl::ClElementwiseSquaredDiff> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 270 | }; |
| 271 | |
| 272 | CLElementwiseSquaredDiff::CLElementwiseSquaredDiff() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 273 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 274 | { |
| 275 | } |
| 276 | CLElementwiseSquaredDiff::CLElementwiseSquaredDiff(CLElementwiseSquaredDiff &&) = default; |
| 277 | CLElementwiseSquaredDiff &CLElementwiseSquaredDiff::operator=(CLElementwiseSquaredDiff &&) = default; |
| 278 | CLElementwiseSquaredDiff::~CLElementwiseSquaredDiff() = default; |
| 279 | |
| 280 | void CLElementwiseSquaredDiff::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 281 | { |
| 282 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 283 | } |
| 284 | |
| 285 | void CLElementwiseSquaredDiff::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 286 | { |
| 287 | _impl->src_0 = input1; |
| 288 | _impl->src_1 = input2; |
| 289 | _impl->dst = output; |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 290 | _impl->op = std::make_unique<opencl::ClElementwiseSquaredDiff>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 291 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 292 | } |
| 293 | |
| 294 | Status CLElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 295 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 296 | return opencl::ClElementwiseSquaredDiff::validate(input1, input2, output, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | void CLElementwiseSquaredDiff::run() |
| 300 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 301 | ITensorPack pack; |
| 302 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 303 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 304 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 305 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 306 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | struct CLElementwisePower::Impl |
| 310 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 311 | const ICLTensor *src_0{ nullptr }; |
| 312 | const ICLTensor *src_1{ nullptr }; |
| 313 | ICLTensor *dst{ nullptr }; |
| 314 | std::unique_ptr<opencl::ClElementwisePower> op{ nullptr }; |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | CLElementwisePower::CLElementwisePower() |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 318 | : _impl(std::make_unique<Impl>()) |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 319 | { |
| 320 | } |
| 321 | CLElementwisePower::CLElementwisePower(CLElementwisePower &&) = default; |
| 322 | CLElementwisePower &CLElementwisePower::operator=(CLElementwisePower &&) = default; |
| 323 | CLElementwisePower::~CLElementwisePower() = default; |
| 324 | |
| 325 | void CLElementwisePower::configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 326 | { |
| 327 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 328 | } |
| 329 | |
| 330 | void CLElementwisePower::configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info) |
| 331 | { |
| 332 | _impl->src_0 = input1; |
| 333 | _impl->src_1 = input2; |
| 334 | _impl->dst = output; |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 335 | _impl->op = std::make_unique<opencl::ClElementwisePower>(); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 336 | _impl->op->configure(compile_context, input1->info(), input2->info(), output->info(), act_info); |
| 337 | } |
| 338 | |
| 339 | Status CLElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
| 340 | { |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 341 | return opencl::ClElementwisePower::validate(input1, input2, output, act_info); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | void CLElementwisePower::run() |
| 345 | { |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 346 | ITensorPack pack; |
| 347 | pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); |
| 348 | pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); |
| 349 | pack.add_tensor(TensorType::ACL_DST, _impl->dst); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 350 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 351 | _impl->op->run(pack); |
Michalis Spyrou | ad7515d | 2020-07-24 00:02:23 +0100 | [diff] [blame] | 352 | } |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 353 | } // namespace arm_compute |