From 211a55d8218764c0a20d69d4cbdaea1906291c6b Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Wed, 31 Aug 2022 11:47:08 +0100 Subject: Optimize depthwise convolution on OpenCL The optimization concerns the case where the depth multiplier is > 1. The depth multiplier for loop has been removed from the OpenCL kernel and the GWS has been mapped to the output shape. In this way, we can still perform a tile with N0 columns and improve the performance of depthwise conv over 80% when depth multiplier is > 1. Resolves COMPMID-5568 Change-Id: I604e287d4eeb31c54b9cc6c3072a698cd0e3e136 Signed-off-by: Gian Marco Iodice Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8184 Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Benchmark: Arm Jenkins --- .../CL/functions/CLDepthwiseConvolutionLayer.cpp | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/runtime/CL/functions') diff --git a/src/runtime/CL/functions/CLDepthwiseConvolutionLayer.cpp b/src/runtime/CL/functions/CLDepthwiseConvolutionLayer.cpp index e821726d0e..8546471fdd 100644 --- a/src/runtime/CL/functions/CLDepthwiseConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLDepthwiseConvolutionLayer.cpp @@ -54,19 +54,22 @@ bool export_weights_to_cl_image_heuristic(const ITensorInfo *weights, unsigned i const size_t kernel_w = weights->tensor_shape()[idx_w]; const size_t kernel_h = weights->tensor_shape()[idx_h]; - if((kernel_w == 1) && (kernel_h == 1)) + if(gpu_target == GPUTarget::G71 || get_arch_from_target(gpu_target) == GPUTarget::MIDGARD) { return false; } - if(depth_multiplier > 1) + if((kernel_w == 1) && (kernel_h == 1)) { return false; } - if(gpu_target == GPUTarget::G71 || get_arch_from_target(gpu_target) == GPUTarget::MIDGARD) + if(depth_multiplier > 1) { - return false; + if((depth_multiplier % 4) != 0) + { + return false; + } } return true; @@ -110,7 +113,18 @@ void initialize_dwc_native_compute_info(DWCComputeKernelInfo &dwc_compute_info, } else { - dwc_compute_info.n0 = 1; + if((depth_multiplier % 4) == 0) + { + dwc_compute_info.n0 = 4; + } + else if((depth_multiplier % 2) == 0) + { + dwc_compute_info.n0 = 2; + } + else + { + dwc_compute_info.n0 = 1; + } } dwc_compute_info.n0 = adjust_vec_size(dwc_compute_info.n0, weights->dimension(0)); -- cgit v1.2.1