From 4411e1f1d49efb78fb07a3c183f386307f951bad Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Thu, 1 Jul 2021 15:36:44 +0100 Subject: Change CLConvolution selection to run Direct approach on large kernels Consider selection of the Direct Conv2d approach on GPU for floating point inputs when kernel size is greater or equal to 7x7. Resolves: COMPMID-4595 Signed-off-by: Georgios Pinitas Change-Id: If851b2e5241dab51127bf9051aa79d210d3f4421 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5894 Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/runtime/CL/functions/CLConvolutionLayer.cpp | 30 +++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'src/runtime/CL/functions/CLConvolutionLayer.cpp') diff --git a/src/runtime/CL/functions/CLConvolutionLayer.cpp b/src/runtime/CL/functions/CLConvolutionLayer.cpp index 2480276d79..500bc4d8e0 100644 --- a/src/runtime/CL/functions/CLConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLConvolutionLayer.cpp @@ -231,30 +231,22 @@ ConvolutionMethod CLConvolutionLayer::get_convolution_method(const ITensorInfo * // Floating-point case: GeMM/Direct/Winograd if(is_data_type_float(input->data_type())) { - const bool is_large_kernel_sz = (weights->dimension(idx_w) >= 5) && (weights->dimension(idx_h) >= 5); - const bool is_ifm_gt_eq_16 = input->dimension(idx_c) >= 16; + const bool is_large_kernel_sz = (weights->dimension(idx_w) >= 7) && (weights->dimension(idx_h) >= 7); + const bool is_ifm_ge_16 = input->dimension(idx_c) >= 16; - // Large kernel size with IFMs >= OFMs - if(is_large_kernel_sz) + // Run Winograd if valid and IFM >= 16 + if(is_wino_valid && is_ifm_ge_16) { - // First check if we can use Winograd - if(is_wino_valid && is_ifm_gt_eq_16) - { - return ConvolutionMethod::WINOGRAD; - } - - if(is_direct_valid) - { - return ConvolutionMethod::DIRECT; - } - - // Default implementation for floating-point-data-type - return ConvolutionMethod::GEMM; + return ConvolutionMethod::WINOGRAD; } - else // Small kernel size + // Run Direct for Large kernel size + if(is_large_kernel_sz && is_ifm_ge_16 && is_direct_valid) { - return is_wino_valid && is_ifm_gt_eq_16 ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + return ConvolutionMethod::DIRECT; } + + // Default case + return ConvolutionMethod::GEMM; } // Generic case for quantized. Only GeMM -- cgit v1.2.1