Rate This Document
Findability
Accuracy
Completeness
Readability

conv2d_winograd_?

2D convolution interface for Winograd algorithm, supporting only non-dilated convolution computation with a stride of 1 and a dilation coefficient of 1.

Interface Definition

C interface:

void conv2d_winograd_fp32(const float *input, const int batch, const int inputChannels, const int inputHeight, const int inputWidth, const float *kernel, const int kernelHeight, const int kernelWidth,const int padHeight, const int padWidth, const float *bias, float *output, const int outputChannels);

void conv2d_winograd_fp16(const __fp16 *input, const int batch, const int inputChannels, const int inputHeight, const int inputWidth, const __fp16 *kernel, const int kernelHeight, const int kernelWidth, const int padHeight, const int padWidth, const __fp16 *bias, __fp16 *output, const int outputChannels);

Parameters

Parameter

Type

Description

Input/Output

input

  • conv2d_winograd_fp32: float
  • conv2d_winograd_fp16: __fp16

Input data

Input

batch

Int

Number of batches of input data

Input

inputChannels

Int

Number of input channels

Input

inputHeight

Int

Height of the input data.

Input

inputWidth

Int

Width of the input data.

Input

kernel

  • conv2d_winograd_fp32: float
  • conv2d_winograd_fp16: __fp16

Convolution kernel.

Input

kernelHeight

Int

Height of the convolution kernel.

Input

kernelWidth

Int

Width of the convolution kernel.

Input

padHeight

Int

Zero-padding length at both ends of the original input data's height.

Input

padWidth

Int

Zero-padding length at both ends of the original input data's width.

Input

bias

  • conv2d_winograd_fp32: float
  • conv2d_winograd_fp16: __fp16

Bias. The value NULL indicates that there is no bias.

Input

output

  • conv2d_winograd_fp32: float
  • conv2d_winograd_fp16: __fp16

Output result data.

Output

outputChannels

Int

Number of output channels.

Input

Dependencies

#include "conv.h"

Examples

C interface:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    int batch = 1;
    int inputChannels = 1;
    int inputHeight = 6;
    int inputWidth = 6;
    int kernelHeight = 3;
    int kernelWidth = 3;
    int strideY = 1;
    int strideX = 1;
    int padHeight = 0;
    int padWidth = 0;
    int dilationY = 1;
    int dilationX = 1;
    int outputChannels = 1;
    float input[36] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
                       7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
                       13.0, 14.0, 15.0, 16.0, 17.0, 18.0,
                       19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
                       25.0, 26.0, 27.0, 28.0, 29.0, 30.0,
                       31.0, 32.0, 33.0, 34.0, 35.0, 36.0};
    float kernel[9] = {1.0, 2.0, 3.0,
                       4.0, 5.0, 6.0,
                       7.0, 8.0, 9.0};

    float *bias = NULL;
    int outputHeight = (inputHeight + 2 * padHeight - (kernelHeight - 1) - 1) + 1;
    int outputWidth = (inputWidth + 2 * padWidth - (kernelWidth - 1) - 1) + 1;
    /*
     *   outputHeight x outputWidth = 4 x 4
     */

    float output[16] = {0.0};
    conv2d_winograd_fp32(input, batch, inputChannels, inputHeight, inputWidth, kernel, kernelHeight, kernelWidth, padHeight, padWidth, bias, output, outputChannels);
    /*
     * output = [474.0 519.0 564.0 609.0,
     *           744.0 789.0 834.0 879.0, 
     *           1014.0 1059.0 1104.0 1149.0, 
     *           1284.0 1329.0 1374.0 1419.0]
     */