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/CLPermute.cpp | 47 +++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'src/runtime/CL/functions/CLPermute.cpp') diff --git a/src/runtime/CL/functions/CLPermute.cpp b/src/runtime/CL/functions/CLPermute.cpp index 31b152c553..eeb0169241 100644 --- a/src/runtime/CL/functions/CLPermute.cpp +++ b/src/runtime/CL/functions/CLPermute.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,12 +23,30 @@ */ #include "arm_compute/runtime/CL/functions/CLPermute.h" +#include "arm_compute/core/CL/CLKernelLibrary.h" #include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/Error.h" -#include "src/core/CL/kernels/CLPermuteKernel.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/core/Validate.h" +#include "src/core/CL/ICLKernel.h" +#include "src/runtime/gpu/cl/operators/ClPermute.h" namespace arm_compute { +struct CLPermute::Impl +{ + const ICLTensor *src{ nullptr }; + ICLTensor *dst{ nullptr }; + std::unique_ptr op{ nullptr }; +}; + +CLPermute::CLPermute() + : _impl(std::make_unique()) +{ +} +CLPermute::CLPermute(CLPermute &&) = default; +CLPermute &CLPermute::operator=(CLPermute &&) = default; +CLPermute::~CLPermute() = default; + void CLPermute::configure(const ICLTensor *input, ICLTensor *output, const PermutationVector &perm) { configure(CLKernelLibrary::get().get_compile_context(), input, output, perm); @@ -36,14 +54,25 @@ void CLPermute::configure(const ICLTensor *input, ICLTensor *output, const Permu void CLPermute::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const PermutationVector &perm) { - auto k = std::make_unique(); - k->configure(compile_context, input, output, perm); - _kernel = std::move(k); + ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); + + _impl->src = input; + _impl->dst = output; + + _impl->op = std::make_unique(); + _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), perm); } Status CLPermute::validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm) { - ARM_COMPUTE_RETURN_ON_ERROR(CLPermuteKernel::validate(input, output, perm)); - return Status{}; + return opencl::ClPermute::validate(input, output, perm); +} + +void CLPermute::run() +{ + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } -} // namespace arm_compute +} // namespace arm_compute \ No newline at end of file -- cgit v1.2.1