From 7e20e29904c98adae5a91c6492fd78da88b7a9bf Mon Sep 17 00:00:00 2001 From: Sheri Zhang Date: Tue, 2 Feb 2021 11:49:34 +0000 Subject: Make memset/copy functions state-less Port following functions: - CLCopy - CLFill - CLPermute - CLReshapeLayer - CLCropResize Resolves: COMPMID-4002 Signed-off-by: Sheri Zhang Change-Id: I8392aa515aaeb5b44dab6122be6a795d08376d5f Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5003 Comments-Addressed: Arm Jenkins Reviewed-by: Michele Di Giorgio Tested-by: Arm Jenkins --- src/runtime/CL/functions/CLFill.cpp | 50 +++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'src/runtime/CL/functions/CLFill.cpp') diff --git a/src/runtime/CL/functions/CLFill.cpp b/src/runtime/CL/functions/CLFill.cpp index 30843d8cc0..b22d79fea4 100644 --- a/src/runtime/CL/functions/CLFill.cpp +++ b/src/runtime/CL/functions/CLFill.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,22 +23,56 @@ */ #include "arm_compute/runtime/CL/functions/CLFill.h" +#include "arm_compute/core/CL/CLKernelLibrary.h" +#include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/Types.h" -#include "src/core/CL/kernels/CLMemsetKernel.h" +#include "arm_compute/core/Validate.h" +#include "src/core/CL/ICLKernel.h" +#include "src/runtime/gpu/cl/operators/ClFill.h" #include namespace arm_compute { -void CLFill::configure(ICLTensor *tensor, PixelValue constant_value) +struct CLFill::Impl { - configure(CLKernelLibrary::get().get_compile_context(), tensor, constant_value); + const ICLTensor *src{ nullptr }; + ICLTensor *dst{ nullptr }; + std::unique_ptr op{ nullptr }; +}; + +CLFill::CLFill() + : _impl(std::make_unique()) +{ +} +CLFill::CLFill(CLFill &&) = default; +CLFill &CLFill::operator=(CLFill &&) = default; +CLFill::~CLFill() = default; + +void CLFill::configure(ICLTensor *tensor, const PixelValue &constant_value, Window *dst_window) +{ + configure(CLKernelLibrary::get().get_compile_context(), tensor, constant_value, dst_window); +} + +void CLFill::configure(const CLCompileContext &compile_context, ICLTensor *tensor, const PixelValue &constant_value, Window *dst_window) +{ + ARM_COMPUTE_ERROR_ON_NULLPTR(tensor); + + _impl->src = tensor; + + _impl->op = std::make_unique(); + _impl->op->configure(compile_context, _impl->src->info(), constant_value, dst_window); +} + +Status CLFill::validate(const ITensorInfo *tensor, const PixelValue &constant_value, Window *dst_window) +{ + return opencl::ClFill::validate(tensor, constant_value, dst_window); } -void CLFill::configure(const CLCompileContext &compile_context, ICLTensor *tensor, PixelValue constant_value) +void CLFill::run() { - auto k = std::make_unique(); - k->configure(compile_context, tensor, constant_value); - _kernel = std::move(k); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + _impl->op->run(pack); } } // namespace arm_compute -- cgit v1.2.1