Rate This Document
Findability
Accuracy
Completeness
Readability

conv2d_separable_?

2D convolution interface implemented by the separable algorithm. It supports only non-dilated convolution computations with a stride of 1 and a dilation rate of 1, provided that the convolution kernel matrix equals the outer product of two vectors.

Interface Definition

C interface:

void conv2d_separable_fp32(const float *input, const int inputHeight, const int inputWidth, const float *fx, const int fxlength, const float *fy, const int fylength, const int padHeight, const int padWidth, const float *bias, float *output);

Parameters

Parameter

Type

Description

Input/Output

input

Float

Input data.

Input

inputHeight

Int

Height of the input data.

Input

inputWidth

Int

Width of the input data.

Input

fx

Float

Convolution kernel row direction.

Input

fxLength

Int

Convolution kernel row size.

Input

fy

Float

Convolution kernel column direction.

Input

fyLength

Int

Convolution kernel column size.

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

Float

Bias value, which is not supported currently. The value NULL indicates that there is no bias.

Input

output

Float

Output result data.

Output

Dependencies

#include "conv.h"

Examples

C interface:
    int inputHeight = 6;
    int inputWidth = 6;
    int kernelHeight = 3;
    int kernelWidth = 3;
    int padHeight = 0;
    int padWidth = 0;
    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 fx[3] = {1.0, 2.0, 3.0};
    float fy[3] = {4.0, 5.0, 6.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_separable_fp32(input, inputHeight, inputWidth, fx, kernelWidth, fy, kernelHeight, padHeight, padWidth, bias, output);
    /*
     * output = [822.000000, 912.000000, 1002.000000, 1092.000000,
     *           1362.000000, 1452.000000, 1542.000000, 1632.000000, 
     *           1902.000000, 1992.000000, 2082.000000, 2172.000000,
     *           2442.000000, 2532.000000, 2622.000000, 2712.000000]
     */