diff options
Diffstat (limited to 'src/runtime/CL/functions/CLPReluLayer.cpp')
-rw-r--r-- | src/runtime/CL/functions/CLPReluLayer.cpp | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/src/runtime/CL/functions/CLPReluLayer.cpp b/src/runtime/CL/functions/CLPReluLayer.cpp index 6543ab922e..ce6d285ebe 100644 --- a/src/runtime/CL/functions/CLPReluLayer.cpp +++ b/src/runtime/CL/functions/CLPReluLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 ARM Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,45 +21,63 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/core/CL/kernels/CLElementwiseOperationKernel.h" +#include "arm_compute/runtime/CL/functions/CLPReluLayer.h" +#include "arm_compute/core/CL/CLKernelLibrary.h" #include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/runtime/CL/functions/CLPReluLayer.h" -#include "support/MemorySupport.h" + +#include "src/gpu/cl/IClKernel.h" +#include "src/gpu/cl/operators/ClPRelu.h" namespace arm_compute { -namespace -{ -void configure_border_handler(const CLCompileContext &compile_context, CLFillBorderKernel &border_handler, BorderSize border_size, ICLTensor *input1, ICLTensor *input2, const ICLTensor *output) +using OperatorType = opencl::ClPRelu; + +struct CLPReluLayer::Impl { - if(output->info()->dimension(0) > 1) - { - ICLTensor *broadcasted_info = (input1->info()->dimension(0) == 1) ? input1 : input2; + const ICLTensor *src_0{nullptr}; + const ICLTensor *src_1{nullptr}; + ICLTensor *dst{nullptr}; + std::unique_ptr<OperatorType> op{nullptr}; +}; - if(broadcasted_info->info()->dimension(0) == 1) - { - border_handler.configure(compile_context, broadcasted_info, border_size, BorderMode::REPLICATE); - } - } +CLPReluLayer::CLPReluLayer() : _impl(std::make_unique<Impl>()) +{ } -} // namespace +CLPReluLayer::CLPReluLayer(CLPReluLayer &&) = default; +CLPReluLayer &CLPReluLayer::operator=(CLPReluLayer &&) = default; +CLPReluLayer::~CLPReluLayer() = default; void CLPReluLayer::configure(ICLTensor *input, ICLTensor *alpha, ICLTensor *output) { configure(CLKernelLibrary::get().get_compile_context(), input, alpha, output); } -void CLPReluLayer::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *alpha, ICLTensor *output) +void CLPReluLayer::configure(const CLCompileContext &compile_context, + ICLTensor *input, + ICLTensor *alpha, + ICLTensor *output) { - auto k = arm_compute::support::cpp14::make_unique<CLArithmeticOperationKernel>(); - k->configure(compile_context, ArithmeticOperation::PRELU, input, alpha, output); - _kernel = std::move(k); - configure_border_handler(compile_context, _border_handler, _kernel->border_size(), input, alpha, output); + _impl->src_0 = input; + _impl->src_1 = alpha; + _impl->dst = output; + _impl->op = std::make_unique<OperatorType>(); + _impl->op->configure(compile_context, input->info(), alpha->info(), + (output == nullptr ? input->info() : output->info())); } Status CLPReluLayer::validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output) { - return CLArithmeticOperationKernel::validate(ArithmeticOperation::PRELU, input, alpha, output); + return OperatorType::validate(input, alpha, output); +} + +void CLPReluLayer::run() +{ + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + + _impl->op->run(pack); } } // namespace arm_compute |