Average Pooling Prototype and Function List¶
Description¶
Average pooling computes each value of the output tensor as the average of all values in the related perception area of a single channel of the input tensor. The perception area size is defined as \(kernel\_width * kernel\_height\) (see Figure Example for 2x2 Average pooling).
Example for 2x2 Average pooling¶
For example, in a HWC data layout, if the in feature map is \((Hi, Wi, Ci)\),
the out feature map is \((Ho, Wo, Ci)\) tensor where the spatial dimensions
comply with the system of equations (1).
Functions¶
Kernels which implement average pooling functions have the following prototype:
mli_status mli_krn_avepool_hwc_<data_format>(
const mli_tensor *in,
const mli_pool_cfg *cfg,
mli_tensor *out);
Parameter |
Type |
Description |
|---|---|---|
|
|
[IN] Pointer to constant input tensor |
|
|
[IN] Pointer to pooling parameters structure |
|
|
[IN | OUT] Pointer to output feature map tensor. Result is stored here |
Function Name |
Details |
|---|---|
|
In/out layout: HWC In/out data format: sa8 Supports any kernel size |
|
In/out layout: HWC In/out data format: fx16 Supports any kernel size |
|
In/out layout: HWC In/out data format: sa8 Kernel width: 2 Kernel height: 2 |
|
In/out layout: HWC In/out data format: sa8 Kernel width: 2 Kernel height: 2 |
|
In/out layout: HWC In/out data format: sa8 Kernel width: 3 Kernel height: 3 |
|
In/out layout: HWC In/out data format: sa8 Kernel width: 3 Kernel height: 3 |
Conditions¶
Ensure that you satisfy the following general conditions before calling the function:
inandouttensors must be valid (see mli_tensor Structure Field Descriptions) and satisfy data requirements of the selected version of the kernel.Shapes of
inandouttensors must be compatible, which implies the following requirements:
inandoutare 3-dimensional tensors (rank==3). Dimensions meaning, and order (layout) is aligned with the specific version of kernel.Channel \(Ci\) dimension of
inandouttensors must be equal.Shapes of
inandouttensors together withcfgstructure must satisfy the equations (1)
inandouttensors must not point to overlapped memory regions.
mem_strideof the innermost dimension must be equal to 1 for all the tensors.
padding_topandpadding_bottomparameters must be in range of [0,kernel_height).
padding_leftandpadding_rightparameters must be in range of [0,kernel_width).
stride_widthandstride_heightparameters must not be equal to 0.
For sa8 versions of kernel, in addition to the general conditions, ensure that you satisfy the following quantization conditions before calling the function:
inandouttensors must be quantized on the tensor level. This implies that each tensor contains a single scale factor and a single zero offset.zero offset of
inandouttensors must be within [-128, 127] range.
Ensure that you satisfy the platform-specific conditions in addition to those listed above (see the Platform Specific Details chapter).
Result¶
These functions only modify the memory pointed by out.data.mem field.
It is assumed that all the other fields of out tensor are properly populated
to be used in calculations and are not modified by the kernel.
Depending on the debug level (see section Error Codes) this function performs a parameter
check and returns the result as an mli_status code as described in section Kernel Specific Configuration Structures.