diff options
author | Manuel Bottini <manuel.bottini@arm.com> | 2021-03-02 17:40:42 +0000 |
---|---|---|
committer | Manuel Bottini <manuel.bottini@arm.com> | 2021-03-11 18:24:52 +0000 |
commit | 9e73c93bbd49fdd648d8f8cb77df46e7bbc9526d (patch) | |
tree | 67f94008f7a8afbd95f00a0093d83af009aca87c /src/runtime/CL/functions | |
parent | 6b0bf9972975aff01e42e5790f7b7c98cd835afb (diff) | |
download | ComputeLibrary-9e73c93bbd49fdd648d8f8cb77df46e7bbc9526d.tar.gz |
Port OpenCL Dequantization to new API
Partially resolves: COMPMID-4193
Change-Id: I4e14149d5b0a7f9c0dd3bfce800eaddca1e4d885
Signed-off-by: Manuel Bottini <manuel.bottini@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5238
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/CL/functions')
-rw-r--r-- | src/runtime/CL/functions/CLDequantizationLayer.cpp | 39 | ||||
-rw-r--r-- | src/runtime/CL/functions/CLGenerateProposalsLayer.cpp | 14 |
2 files changed, 40 insertions, 13 deletions
diff --git a/src/runtime/CL/functions/CLDequantizationLayer.cpp b/src/runtime/CL/functions/CLDequantizationLayer.cpp index d358813724..e0381f90ae 100644 --- a/src/runtime/CL/functions/CLDequantizationLayer.cpp +++ b/src/runtime/CL/functions/CLDequantizationLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,10 +23,27 @@ */ #include "arm_compute/runtime/CL/functions/CLDequantizationLayer.h" -#include "src/core/CL/kernels/CLDequantizationLayerKernel.h" +#include "arm_compute/core/CL/CLKernelLibrary.h" +#include "arm_compute/core/CL/ICLTensor.h" +#include "arm_compute/core/KernelDescriptors.h" +#include "src/core/CL/ICLKernel.h" +#include "src/runtime/gpu/cl/operators/ClDequantization.h" namespace arm_compute { +struct CLDequantizationLayer::Impl +{ + const ICLTensor *src{ nullptr }; + ICLTensor *dst{ nullptr }; + std::unique_ptr<opencl::ClDequantization> op{ nullptr }; +}; + +CLDequantizationLayer::CLDequantizationLayer() + : _impl(std::make_unique<Impl>()) +{ +} +CLDequantizationLayer::~CLDequantizationLayer() = default; + void CLDequantizationLayer::configure(const ICLTensor *input, ICLTensor *output) { configure(CLKernelLibrary::get().get_compile_context(), input, output); @@ -34,13 +51,23 @@ void CLDequantizationLayer::configure(const ICLTensor *input, ICLTensor *output) void CLDequantizationLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) { - auto k = std::make_unique<CLDequantizationLayerKernel>(); - k->configure(compile_context, input, output); - _kernel = std::move(k); + _impl->src = input; + _impl->dst = output; + + _impl->op = std::make_unique<opencl::ClDequantization>(); + _impl->op->configure(compile_context, input->info(), output->info()); } Status CLDequantizationLayer::validate(const ITensorInfo *input, const ITensorInfo *output) { - return CLDequantizationLayerKernel::validate(input, output); + return opencl::ClDequantization::validate(input, output); +} + +void CLDequantizationLayer::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 diff --git a/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp b/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp index fb698d5b88..81e24dba08 100644 --- a/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp +++ b/src/runtime/CL/functions/CLGenerateProposalsLayer.cpp @@ -25,9 +25,9 @@ #include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLDequantizationLayer.h" #include "arm_compute/runtime/CL/functions/CLQuantizationLayer.h" #include "src/core/CL/kernels/CLBoundingBoxTransformKernel.h" -#include "src/core/CL/kernels/CLDequantizationLayerKernel.h" #include "src/core/CL/kernels/CLGenerateProposalsLayerKernel.h" #include "src/core/CL/kernels/CLPadLayerKernel.h" #include "src/core/helpers/AutoConfiguration.h" @@ -43,8 +43,8 @@ CLGenerateProposalsLayer::CLGenerateProposalsLayer(std::shared_ptr<IMemoryManage _compute_anchors_kernel(std::make_unique<CLComputeAllAnchorsKernel>()), _bounding_box_kernel(std::make_unique<CLBoundingBoxTransformKernel>()), _pad_kernel(std::make_unique<CLPadLayerKernel>()), - _dequantize_anchors(std::make_unique<CLDequantizationLayerKernel>()), - _dequantize_deltas(std::make_unique<CLDequantizationLayerKernel>()), + _dequantize_anchors(std::make_unique<CLDequantizationLayer>()), + _dequantize_deltas(std::make_unique<CLDequantizationLayer>()), _quantize_all_proposals(std::make_unique<CLQuantizationLayer>()), _cpp_nms(memory_manager), _is_nhwc(false), @@ -261,10 +261,10 @@ Status CLGenerateProposalsLayer::validate(const ITensorInfo *scores, const ITens if(is_qasymm8) { TensorInfo all_anchors_f32_info(anchors->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true).set_data_type(DataType::F32)); - ARM_COMPUTE_RETURN_ON_ERROR(CLDequantizationLayerKernel::validate(&all_anchors_info, &all_anchors_f32_info)); + ARM_COMPUTE_RETURN_ON_ERROR(CLDequantizationLayer::validate(&all_anchors_info, &all_anchors_f32_info)); TensorInfo deltas_flattened_f32_info(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true).set_data_type(DataType::F32)); - ARM_COMPUTE_RETURN_ON_ERROR(CLDequantizationLayerKernel::validate(&deltas_flattened_info, &deltas_flattened_f32_info)); + ARM_COMPUTE_RETURN_ON_ERROR(CLDequantizationLayer::validate(&deltas_flattened_info, &deltas_flattened_f32_info)); TensorInfo proposals_4_roi_values_f32(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true).set_data_type(DataType::F32)); ARM_COMPUTE_RETURN_ON_ERROR(CLBoundingBoxTransformKernel::validate(&all_anchors_f32_info, &proposals_4_roi_values_f32, &deltas_flattened_f32_info, @@ -363,8 +363,8 @@ void CLGenerateProposalsLayer::run() if(_is_qasymm8) { - CLScheduler::get().enqueue(*_dequantize_anchors, false); - CLScheduler::get().enqueue(*_dequantize_deltas, false); + _dequantize_anchors->run(); + _dequantize_deltas->run(); } // Build the boxes |