conv1d_gemm_?
General 1D convolution interface implemented by the GEMM algorithm.
Interface Definition
C interface:
void conv1d_gemm_fp32(const float *input, const int batch, const int inputChannels, const int inputLength, const float* kernel, const int kernelLength, const int stride, const int padLength, const int dilation, const float *bias, float *output, const int outputChannels);
void conv1d_gemm_fp16(const __fp16 *input, const int batch, const int inputChannels, const int inputLength, const __fp16 *kernel, const int kernelLength, const int stride, const int padLength, const int dilation, const __fp16 *bias, __fp16 *output, const int outputChannels);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
input |
|
Input data. |
Input |
batch |
Int |
Number of batches of input data. |
Input |
inputChannels |
Int |
Number of input channels. |
Input |
inputLength |
Int |
Length of the input data. |
Input |
kernel |
|
Convolution kernel. |
Input |
kernelLength |
Int |
Convolution kernel length. |
Input |
stride |
Int |
Stride. |
Input |
padLength |
Int |
Zero-padding length at both ends of the original input data. |
Input |
dilation |
Int |
Dilation rate. |
Input |
bias |
|
Bias. The value NULL indicates that there is no bias. |
Input |
output |
|
Output result data. |
Output |
outputChannels |
Int |
Number of output channels. |
Input |
Dependencies
#include "conv.h"
Examples
C interface:
int batch = 1;
int inputChannels = 1;
int inputLength = 10;
int kernelLength = 3;
int stride = 1;
int padLength = 0;
int dilation = 1;
int outputChannels = 1;
float input[10] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
float kernel[3] = {1.0, 2.0, 3.0};
float *bias = NULL;
int outputLength = (inputLength + 2 * padLength - dilation * (kernelLength - 1) - 1) / stride + 1;
/*
* outputLength = 8
*/
float output[8] = {0.0};
conv1d_gemm_fp32(input, batch, inputChannels, inputLength, kernel, kernelLength, stride, padLength, dilation, bias, output, outputChannels);
/*
* output = [14.0 20.0 26.0 32.0 38.0 44.0 50.0 56.0]
*/