Convolution Kernels Group

The Convolution Group describes operations related to convolution layers, where input features are convolved with a set of trained filters. For a comprehensive guide on convolution arithmetic details for various cases, see A guide to convolution arithmetic for deep learning.

Functions in this group use the mli_conv2d_cfg structure, defined as:

typedef struct {
   mli_relu_cfg relu;
   uint8_t stride_width;
   uint8_t stride_height;
   uint8_t dilation_width;
   uint8_t dilation_height;
   uint8_t padding_left;
   uint8_t padding_right;
   uint8_t padding_top;
   uint8_t padding_bottom;
} mli_conv2d_cfg;
mli_conv2d_cfg Structure Field Description

Field Name

Type

Description

relu

mli_relu_cfg

Type of ReLU activation applied to output values. See ReLU Prototype and Function List for more details.

stride_width

uint8_t

Stride of filter across width dimension of input

stride_ height

uint8_t

Stride of filter across height dimension of input

dilation_width

uint8_t

If set to k>1, there are k-1 implicitly added zero points between each filter point across width dimension. If set to 1, no dilation logic is used. Zero dilation is forbidden.

dilation_height

uint8_t

If set to k>1, there are k-1 implicitly added zero points between each filter point across height dimension. If set to 1, no dilation logic is used. Zero dilation is forbidden.

padding_left

uint8_t

Number of zero points implicitly added to the left of input (width dimension)

padding_right

uint8_t

Number of zero points implicitly added to the right of input (width dimension)

padding_top

uint8_t

Number of zero points implicitly added to the top of input (height dimension)

padding_bottom

uint8_t

Number of zero points implicitly added to the bottom of input (height dimension)

Note

For more information on dilation rate, see chapter 5.1 of A guide to convolution arithmetic for deep learning.

For all kernels in this group except the transpose convolution, spatial dimensions of in, weights and out tensors (Width and Height) must comply with the following system of equations:

(1)\[ \begin{align}\begin{aligned}\begin{cases} \hat{Wk} = ({Wk}-1)*dilation\_width+1\\\hat{Hk} = ({Hk}-1)*dilation\_height+1\\\hat{Wi} = {Wi}+padding\_left+padding\_right\\\hat{Hi} = {Hi}+padding\_top+padding\_bottom\\{Wo}*{stride\_width} = \hat{Wi}-\hat{Wk}+{stride\_width}\\{Ho}*{stride\_height} = \hat{Hi}-\hat{Hk}+{stride\_height}\\\end{cases}\end{aligned}\end{align} \]

Where:

  • \(\hat{Wk}\), \(\hat{Hk}\) - effective weights kernel width and height after applying \(dilation\_width\) and \(dilation\_height\) factors on the original kernel width (\(Wk\)) and height (\(Hk\)).

  • \(\hat{Wi}\), \(\hat{Hi}\) - effective in feature map width and height after applying \(padding\_*\) to the original width (\(Wi\)) and height (\(Hi\)).

  • \(Wo\), \(Ho\) - out feature map width and height.