From bef7fa27b0d231a8649952f60808132d109b6345 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Wed, 21 Oct 2020 15:58:54 +0100 Subject: COMPMID-3639: (3RDPARTY_UPDATE) Move CL kernels to src Change-Id: I10d27db788e5086adae1841e3e2441cd9b76ef84 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4310 Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- .../CL/functions/CLLocallyConnectedLayer.cpp | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/runtime/CL/functions/CLLocallyConnectedLayer.cpp') diff --git a/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp b/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp index 74cb47347f..04e59ac4a6 100644 --- a/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp +++ b/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp @@ -27,6 +27,11 @@ #include "arm_compute/core/Utils.h" #include "arm_compute/core/Validate.h" #include "arm_compute/runtime/CL/CLScheduler.h" +#include "src/core/CL/kernels/CLCol2ImKernel.h" +#include "src/core/CL/kernels/CLIm2ColKernel.h" +#include "src/core/CL/kernels/CLLocallyConnectedMatrixMultiplyKernel.h" +#include "src/core/CL/kernels/CLWeightsReshapeKernel.h" +#include "support/MemorySupport.h" #include #include @@ -78,8 +83,16 @@ void calculate_shapes(const ITensorInfo *input, const ITensorInfo *weights, cons } // namespace CLLocallyConnectedLayer::CLLocallyConnectedLayer(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), _input_im2col_kernel(), _weights_reshape_kernel(), _mm_kernel(), _output_col2im_kernel(), _input_im2col_reshaped(), _weights_reshaped(), _gemm_output(), - _is_prepared(false), _original_weights(nullptr) + : _memory_group(std::move(memory_manager)), + _input_im2col_kernel(support::cpp14::make_unique()), + _weights_reshape_kernel(support::cpp14::make_unique()), + _mm_kernel(support::cpp14::make_unique()), + _output_col2im_kernel(support::cpp14::make_unique()), + _input_im2col_reshaped(), + _weights_reshaped(), + _gemm_output(), + _is_prepared(false), + _original_weights(nullptr) { } @@ -169,16 +182,16 @@ void CLLocallyConnectedLayer::configure(const CLCompileContext &compile_context, _memory_group.manage(&_gemm_output); // Configure kernels - _input_im2col_kernel.configure(compile_context, input, &_input_im2col_reshaped, Size2D(kernel_width, kernel_height), conv_info, _has_bias); - _weights_reshape_kernel.configure(compile_context, weights, biases, &_weights_reshaped); - _mm_kernel.configure(compile_context, &_input_im2col_reshaped, &_weights_reshaped, &_gemm_output); - _output_col2im_kernel.configure(compile_context, &_gemm_output, output, Size2D(conv_w, conv_h)); + _input_im2col_kernel->configure(compile_context, input, &_input_im2col_reshaped, Size2D(kernel_width, kernel_height), conv_info, _has_bias); + _weights_reshape_kernel->configure(compile_context, weights, biases, &_weights_reshaped); + _mm_kernel->configure(compile_context, &_input_im2col_reshaped, &_weights_reshaped, &_gemm_output); + _output_col2im_kernel->configure(compile_context, &_gemm_output, output, Size2D(conv_w, conv_h)); // Allocate intermediate tensors _input_im2col_reshaped.allocator()->allocate(); _gemm_output.allocator()->allocate(); - CLScheduler::get().tune_kernel_static(_input_im2col_kernel); + CLScheduler::get().tune_kernel_static(*_input_im2col_kernel); } void CLLocallyConnectedLayer::run() @@ -188,13 +201,13 @@ void CLLocallyConnectedLayer::run() MemoryGroupResourceScope scope_mg(_memory_group); // Run input reshaping - CLScheduler::get().enqueue(_input_im2col_kernel); + CLScheduler::get().enqueue(*_input_im2col_kernel); // Runs vector matrix multiply on reshaped matrices - CLScheduler::get().enqueue(_mm_kernel); + CLScheduler::get().enqueue(*_mm_kernel); // Reshape output matrix - CLScheduler::get().enqueue(_output_col2im_kernel, false); + CLScheduler::get().enqueue(*_output_col2im_kernel.get(), false); } void CLLocallyConnectedLayer::prepare() @@ -205,7 +218,7 @@ void CLLocallyConnectedLayer::prepare() // Run weights reshaping and mark original weights tensor as unused _weights_reshaped.allocator()->allocate(); - CLScheduler::get().enqueue(_weights_reshape_kernel); + CLScheduler::get().enqueue(*_weights_reshape_kernel); _original_weights->mark_as_unused(); CLScheduler::get().queue().finish(); -- cgit v1.2.1