From 4c6bd514a8d424a29b776754f1b3426fa3a8c339 Mon Sep 17 00:00:00 2001 From: Manuel Bottini Date: Wed, 8 Apr 2020 10:15:51 +0100 Subject: COMPMID-3280: Make all ML primitives for CL use the new interface - Part 1 - Only CLKernels have been updated Change-Id: Ife55b847c2e39e712a186eb6ca452503d5b66937 Signed-off-by: Manuel Bottini Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3001 Reviewed-by: Michele Di Giorgio Reviewed-by: Michalis Spyrou Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/core/CL/kernels/CLConvolutionKernel.cpp | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src/core/CL/kernels/CLConvolutionKernel.cpp') diff --git a/src/core/CL/kernels/CLConvolutionKernel.cpp b/src/core/CL/kernels/CLConvolutionKernel.cpp index 2e1c56c3ba..3cc6d24de2 100644 --- a/src/core/CL/kernels/CLConvolutionKernel.cpp +++ b/src/core/CL/kernels/CLConvolutionKernel.cpp @@ -59,6 +59,12 @@ BorderSize CLConvolutionKernel::border_size() const template void CLConvolutionKernel::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, bool border_undefined) +{ + configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, scale, border_undefined); +} + +template +void CLConvolutionKernel::configure(CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, bool border_undefined) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16); @@ -92,7 +98,7 @@ void CLConvolutionKernel::configure(const ICLTensor *input, ICLTens out_type << "-DDATA_TYPE_OUT=" << get_cl_type_from_data_type(output->info()->data_type()); build_opts.add_option(out_type.str()); - _kernel = static_cast(CLKernelLibrary::get().create_kernel(kernel_name.str(), build_opts.options())); + _kernel = create_kernel(compile_context, kernel_name.str(), build_opts.options()); // Configure kernel window constexpr unsigned int num_elems_processed_per_iteration = 8; @@ -129,6 +135,12 @@ BorderSize CLSeparableConvolutionHorKernel::border_size template void CLSeparableConvolutionHorKernel::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, bool border_undefined) +{ + configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, border_undefined); +} + +template +void CLSeparableConvolutionHorKernel::configure(CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const int16_t *conv, bool border_undefined) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U16, DataType::S16, DataType::S32); @@ -156,7 +168,7 @@ void CLSeparableConvolutionHorKernel::configure(const ICLTensor *in // Create kernel const std::string kernel_name = "convolution_separable1x" + support::cpp11::to_string(matrix_size) + "_static"; - _kernel = static_cast(CLKernelLibrary::get().create_kernel(kernel_name, build_opts)); + _kernel = create_kernel(compile_context, kernel_name, build_opts); // Configure kernel window constexpr unsigned int num_elems_processed_per_iteration = 8; @@ -199,6 +211,13 @@ BorderSize CLSeparableConvolutionVertKernel::border_siz template void CLSeparableConvolutionVertKernel::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, bool border_undefined, DataType data_type) +{ + configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, scale, border_undefined, data_type); +} + +template +void CLSeparableConvolutionVertKernel::configure(CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, + const int16_t *conv, uint32_t scale, bool border_undefined, DataType data_type) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U16, DataType::S16, DataType::S32); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16); @@ -230,7 +249,7 @@ void CLSeparableConvolutionVertKernel::configure(const ICLTensor *i // Create kernel const std::string kernel_name = "convolution_separable" + support::cpp11::to_string(matrix_size) + "x1_static"; - _kernel = static_cast(CLKernelLibrary::get().create_kernel(kernel_name, build_opts)); + _kernel = create_kernel(compile_context, kernel_name, build_opts); // Configure kernel window constexpr unsigned int num_elems_processed_per_iteration = 8; @@ -280,6 +299,12 @@ BorderSize CLConvolutionRectangleKernel::border_size() const } void CLConvolutionRectangleKernel::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t width, uint32_t height, uint32_t scale, bool border_undefined) +{ + configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, width, height, scale, border_undefined); +} + +void CLConvolutionRectangleKernel::configure(CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t width, uint32_t height, uint32_t scale, + bool border_undefined) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16); @@ -317,7 +342,7 @@ void CLConvolutionRectangleKernel::configure(const ICLTensor *input, ICLTensor * options.insert("-DMATRIX_WIDTH=" + support::cpp11::to_string(width)); options.insert("-DMATRIX_HEIGHT=" + support::cpp11::to_string(height)); - _kernel = static_cast(CLKernelLibrary::get().create_kernel("convolution_rectangle", options)); + _kernel = create_kernel(compile_context, "convolution_rectangle", options); // Configure kernel window constexpr unsigned int num_elems_processed_per_iteration = 8; -- cgit v1.2.1