From f1c2bf0971dd1c996da149faf3dd669d566074c7 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Wed, 13 Jun 2018 14:05:54 +0100 Subject: COMPMID-1201 - Implementing Winograd Convolution Layer 1x3 and 3x1 kernels on OpenCL Change-Id: I39667bab49daa4da009694163274a59fd3574c73 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/137595 Tested-by: Jenkins Reviewed-by: Giorgio Arena Reviewed-by: Georgios Pinitas --- arm_compute/core/Helpers.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'arm_compute/core/Helpers.h') diff --git a/arm_compute/core/Helpers.h b/arm_compute/core/Helpers.h index 7d922ae187..a3cbfb94e3 100644 --- a/arm_compute/core/Helpers.h +++ b/arm_compute/core/Helpers.h @@ -111,6 +111,28 @@ struct is_contained> : is_contained }; } +/** Calculate the number of output tiles required by Winograd Convolution layer. This utility function can be used by the Winograd input transform + * to know the number of tiles on the x and y direction + * + * @param[in] in_dims Spatial dimensions of the input tensor of convolution layer + * @param[in] kernel_size Kernel size + * @param[in] output_tile_size Size of a single output tile + * @param[in] conv_info Convolution info (i.e. pad, stride,...) + * + * @return the number of output tiles along the x and y directions of size "output_tile_size" + */ +inline Size2D compute_winograd_convolution_tiles(const Size2D &in_dims, const Size2D &kernel_size, const Size2D &output_tile_size, const PadStrideInfo &conv_info) +{ + int num_tiles_x = std::ceil((in_dims.width - (kernel_size.width - 1) + conv_info.pad_left() + conv_info.pad_right()) / static_cast(output_tile_size.width)); + int num_tiles_y = std::ceil((in_dims.height - (kernel_size.height - 1) + conv_info.pad_top() + conv_info.pad_bottom()) / static_cast(output_tile_size.height)); + + // Clamp in case we provide paddings but we have 1D convolution + num_tiles_x = std::min(num_tiles_x, static_cast(in_dims.width)); + num_tiles_y = std::min(num_tiles_y, static_cast(in_dims.height)); + + return Size2D(num_tiles_x, num_tiles_y); +} + /** Computes bilinear interpolation using the pointer to the top-left pixel and the pixel's distance between * the real coordinates and the smallest following integer coordinates. Input must be in single channel format. * -- cgit v1.2.1