From 247f52cfe337f7b2542b900e3d8cf122e9d4f11c Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Thu, 22 Mar 2018 11:24:56 +0000 Subject: COMPMID-1013 - Create WinogradInfo data structure COMPMID-1014 - Refactoring Winograd's dataset Change-Id: I6abdcbf9a90d663f4db666cd410afece9f1d034d Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/125899 Tested-by: Jenkins Reviewed-by: Anthony Barbier --- .../CL/kernels/CLWinogradFilterTransformKernel.h | 28 +++++++++++------ .../CL/kernels/CLWinogradInputTransformKernel.h | 30 ++++++++++++------ .../CL/kernels/CLWinogradOutputTransformKernel.h | 36 +++++++++++++--------- 3 files changed, 60 insertions(+), 34 deletions(-) (limited to 'arm_compute/core/CL') diff --git a/arm_compute/core/CL/kernels/CLWinogradFilterTransformKernel.h b/arm_compute/core/CL/kernels/CLWinogradFilterTransformKernel.h index c4ae5745b8..7115710d59 100644 --- a/arm_compute/core/CL/kernels/CLWinogradFilterTransformKernel.h +++ b/arm_compute/core/CL/kernels/CLWinogradFilterTransformKernel.h @@ -48,22 +48,30 @@ public: ~CLWinogradFilterTransformKernel() = default; /** Set the input and output tensor. * - * @param[in] input Source tensor. The input is a 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] (NCHW data layout). - * kernel_x must be 3 and equal to kernel_y. Data types supported: F32. - * @param[out] output Destination tensor. The output is a 3D tensor with dimensions [OFM, IFM, 16]. Data type supported: same as @p input - * @param[in] output_tile Output tile. Currently only 2x2 and 4x4 tiles are supported. + * @note Winograd filter transform supports the following configurations: + * Output tile size: 2x2, 4x4 + * Kernel size: 3x3 + * Strides: only unit strides + * + * @param[in] input Source tensor. The input is a 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] (NCHW data layout). Data types supported: F32. + * @param[out] output The output tensor. The shape for this tensor can be calculated using the utility function @p compute_winograd_filter_transform_shape. Data types supported: Same as @p input + * @param[in] winograd_info Contains Winograd's information described in @ref WinogradInfo */ - void configure(const ICLTensor *input, ICLTensor *output, const Size2D &output_tile); + void configure(const ICLTensor *input, ICLTensor *output, const WinogradInfo &winograd_info); /** Static function to check if given info will lead to a valid configuration of @ref CLWinogradFilterTransformKernel * - * @param[in] input Source tensor info. The input is a 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] (NCHW data layout). - * kernel_x must be 3 and equal to kernel_y. Data types supported: F32. - * @param[in] output Destination tensor info. The output is a 3D tensor with dimensions [OFM, IFM, 16]. Data type supported: same as @p input - * @param[in] output_tile Output tile. Currently only 2x2 and 4x4 tiles are supported. + * @note Winograd filter transform supports the following configurations: + * Output tile size: 2x2, 4x4 + * Kernel size: 3x3 + * Strides: only unit strides + * + * @param[in] input Source tensor. The input is a 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] (NCHW data layout). Data types supported: F32. + * @param[out] output The output tensor. The shape for this tensor can be calculated using the utility function @p compute_winograd_filter_transform_shape. Data types supported: Same as @p input + * @param[in] winograd_info Contains Winograd's information described in @ref WinogradInfo * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &output_tile); + static Status validate(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; diff --git a/arm_compute/core/CL/kernels/CLWinogradInputTransformKernel.h b/arm_compute/core/CL/kernels/CLWinogradInputTransformKernel.h index 15cd6e2649..2d1eadf3cf 100644 --- a/arm_compute/core/CL/kernels/CLWinogradInputTransformKernel.h +++ b/arm_compute/core/CL/kernels/CLWinogradInputTransformKernel.h @@ -46,28 +46,38 @@ public: CLWinogradInputTransformKernel &operator=(CLWinogradInputTransformKernel &&) = default; /** Set the input and output of the kernel. * - * @param[in] input The input tensor to permute. Data types supported: F32 - * @param[in] output The output tensor. Data types supported: Same as @p input - * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. Currently only unit strides are supported. - * @param[in] kernel_dims Kernel dimensions. Currently only 3x3 kernels are supported + * @note Winograd input transform supports the following configurations: + * Output tile size: 2x2 + * Kernel size: 3x3 + * Strides: only unit strides + * + * @param[in] input The input tensor to transform. Data types supported: F32 + * @param[in] output The output tensor. The shape for this tensor can be calculated using the utility function @p compute_winograd_input_transform_shape. Data types supported: Same as @p input + * @param[in] winograd_info Contains Winograd's information described in @ref WinogradInfo. */ - void configure(const ICLTensor *input, ICLTensor *output, const PadStrideInfo &conv_info, const Size2D &kernel_dims); + void configure(const ICLTensor *input, ICLTensor *output, const WinogradInfo &winograd_info); /** Static function to check if given info will lead to a valid configuration of @ref CLWinogradInputTransformKernel * - * @param[in] input First tensor input info. Data types supported: F32. - * @param[in] output Output tensor info. Data types supported: same as @p input. - * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. Currently only unit strides are supported. - * @param[in] kernel_dims Kernel dimensions. Currently only 3x3 kernels are supported + * @note Winograd input transform supports the following configurations: + * Output tile size: 2x2 + * Kernel size: 3x3 + * Strides: only unit strides + * + * @param[in] input The input tensor to transform. Data types supported: F32 + * @param[in] output The output tensor. The shape for this tensor can be calculated using the utility function @p compute_winograd_input_transform_shape. Data types supported: Same as @p input + * @param[in] winograd_info Contains Winograd's information described in @ref WinogradInfo. * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PadStrideInfo &conv_info, const Size2D &kernel_dims); + static Status validate(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; BorderSize border_size() const override; private: + using WinogradKey = std::pair, std::pair>; + BorderSize _border_size; const ICLTensor *_input; ICLTensor *_output; diff --git a/arm_compute/core/CL/kernels/CLWinogradOutputTransformKernel.h b/arm_compute/core/CL/kernels/CLWinogradOutputTransformKernel.h index 35117c65db..b0d0bbeeaa 100644 --- a/arm_compute/core/CL/kernels/CLWinogradOutputTransformKernel.h +++ b/arm_compute/core/CL/kernels/CLWinogradOutputTransformKernel.h @@ -48,31 +48,39 @@ public: ~CLWinogradOutputTransformKernel() = default; /** Set the input and output tensor. * - * @param[in] input Source tensor with shape [C, N, 16, batches]. Data types supported: F32. - * @param[in] bias Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. It can be a nullptr. Data type supported: as @p input - * @param[out] output Destination tensor with shape [output_convolved_dims.width, output_convolved_dims.height, C, batches]. Data type supported: same as @p input - * @param[in] kernel_dims Kernel dimensions (Width and height). Currently only supported 3x3 kernels - * @param[in] output_convolved_dims Output dimensions after the convolution (Width and height) - * @param[in] num_tiles Number of tiles of size 2x2 in the output tensor along the X and Y direction + * @note Winograd output transform supports the following configurations: + * Output tile size: 2x2 + * Kernel size: 3x3 + * Strides: only unit strides + * + * @param[in] input Source tensor with shape [C, N, 16, batches]. Data types supported: F32. + * @param[in] bias Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. It can be a nullptr. Data type supported: as @p input + * @param[out] output The output tensor. The shape for this tensor can be calculated using the utility function @p compute_winograd_output_transform_shape. Data types supported: Same as @p input + * @param[in] winograd_info Contains Winograd's information described in @ref WinogradInfo */ - void configure(const ICLTensor *input, const ICLTensor *bias, ICLTensor *output, const Size2D &kernel_dims, const Size2D &output_convolved_dims, const Size2D &num_tiles); + void configure(const ICLTensor *input, const ICLTensor *bias, ICLTensor *output, const WinogradInfo &winograd_info); /** Static function to check if given info will lead to a valid configuration of @ref CLWinogradOutputTransformKernel * - * @param[in] input Source tensor with shape [C, N, 16, batches]. Data types supported: F32. - * @param[in] bias Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. It can be a nullptr. Data type supported: as @p input - * @param[out] output Destination tensor with shape [output_convolved_dims.width, output_convolved_dims.height, C, batches]. Data type supported: same as @p input - * @param[in] kernel_dims Kernel dimensions (Width and height). Currently only supported 3x3 kernels - * @param[in] output_convolved_dims Output dimensions after the convolution (Width and height) - * @param[in] num_tiles Number of tiles of size 2x2 in the output tensor along the X and Y direction + * @note Winograd output transform supports the following configurations: + * Output tile size: 2x2 + * Kernel size: 3x3 + * Strides: only unit strides + * + * @param[in] input Source tensor with shape [C, N, 16, batches]. Data types supported: F32. + * @param[in] bias Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. It can be a nullptr. Data type supported: as @p input + * @param[out] output The output tensor. The shape for this tensor can be calculated using the utility function @p compute_winograd_output_transform_shape. Data types supported: Same as @p input + * @param[in] winograd_info Contains Winograd's information described in @ref WinogradInfo * * @return a status */ - static Status validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const Size2D &kernel_dims, const Size2D &output_convolved_dims, const Size2D &num_tiles); + static Status validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const WinogradInfo &winograd_info); // Inherited methods overridden: void run(const Window &window, cl::CommandQueue &queue) override; private: + using WinogradKey = std::pair, std::pair>; + const ICLTensor *_input; const ICLTensor *_bias; ICLTensor *_output; -- cgit v1.2.1