鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

conv2d_separable_?

Separable算法实现的2D卷积接口,仅支持步长为1、膨胀系数为1的非膨胀卷积计算,并且满足卷积核kernel矩阵等于两个向量外积的情况。

接口定义

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);

参数

参数名

类型

描述

输入/输出

input

float类型

输入数据

输入

inputHeight

int类型

输入数据的高度

输入

inputWidth

int类型

输入数据的宽度

输入

fx

float类型

卷积核行方向

输入

fxLength

int类型

卷积核行方向大小

输入

fy

float类型

卷积核列方向

输入

fyLength

int类型

卷积核列方向大小

输入

padHeight

int类型

在原始input数据高度方向两端分别置零的长度

输入

padWidth

int类型

在原始input数据宽度方向两端分别置零的长度

输入

bias

float类型

偏置值,暂不支持, 值为NULL时表示无偏置

输入

output

float类型

输出结果数据

输出

依赖

#include "conv.h"

示例

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]
     */