CMSIS-NN: Pooling Functions

| CMSIS-NN Version 3.1.0 CMSIS NN Software Library

- Main Page
- Usage and Description
- Reference

All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Functions
Pooling Functions
Neural Network Functions

## Functions

arm_status | arm_avgpool_s16 (const cmsis_nn_context *ctx, const cmsis_nn_pool_params *pool_params, const cmsis_nn_dims *input_dims, const q15_t *src, const cmsis_nn_dims *filter_dims, const cmsis_nn_dims *output_dims, q15_t *dst)
int32_t | arm_avgpool_s16_get_buffer_size (const int output_x, const int ch_src)
| Get the required buffer size for S16 average pooling function. More...
arm_status | arm_avgpool_s8 (const cmsis_nn_context *ctx, const cmsis_nn_pool_params *pool_params, const cmsis_nn_dims *input_dims, const q7_t *src, const cmsis_nn_dims *filter_dims, const cmsis_nn_dims *output_dims, q7_t *dst)
| s8 average pooling function. More...
int32_t | arm_avgpool_s8_get_buffer_size (const int output_x, const int ch_src)
| Get the required buffer size for S8 average pooling function. More...
arm_status | arm_max_pool_s16 (const cmsis_nn_context *ctx, const cmsis_nn_pool_params *pool_params, const cmsis_nn_dims *input_dims, const int16_t *src, const cmsis_nn_dims *filter_dims, const cmsis_nn_dims *output_dims, int16_t *dst)
| s16 max pooling function. More...
arm_status | arm_max_pool_s8 (const cmsis_nn_context *ctx, const cmsis_nn_pool_params *pool_params, const cmsis_nn_dims *input_dims, const q7_t *src, const cmsis_nn_dims *filter_dims, const cmsis_nn_dims *output_dims, q7_t *dst)
| s8 max pooling function. More...
void | arm_maxpool_q7_HWC (q7_t *Im_in, const uint16_t dim_im_in, const uint16_t ch_im_in, const uint16_t dim_kernel, const uint16_t padding, const uint16_t stride, const uint16_t dim_im_out, q7_t *bufferA, q7_t *Im_out)
| Q7 max pooling function. More...
void | arm_avepool_q7_HWC (q7_t *Im_in, const uint16_t dim_im_in, const uint16_t ch_im_in, const uint16_t dim_kernel, const uint16_t padding, const uint16_t stride, const uint16_t dim_im_out, q7_t *bufferA, q7_t *Im_out)
| Q7 average pooling function. More...

## Description

Perform pooling functions, including max pooling and average pooling

## Function Documentation

void arm_avepool_q7_HWC | ( | q7_t * | Im_in,
|  | const uint16_t | dim_im_in,
|  | const uint16_t | ch_im_in,
|  | const uint16_t | dim_kernel,
|  | const uint16_t | padding,
|  | const uint16_t | stride,
|  | const uint16_t | dim_im_out,
|  | q7_t * | bufferA,
|  | q7_t * | Im_out
| ) |  |

Parameters

  [in,out] | Im_in | pointer to input tensor
  [in] | dim_im_in | input tensor dimention
  [in] | ch_im_in | number of input tensor channels
  [in] | dim_kernel | filter kernel size
  [in] | padding | padding sizes
  [in] | stride | convolution stride
  [in] | dim_im_out | output tensor dimension
  [in,out] | bufferA | pointer to buffer space for input
  [in,out] | Im_out | pointer to output tensor

Buffer size:

bufferA size: 2*dim_im_out*ch_im_in

The pooling function is implemented as split x-pooling then y-pooling.

This pooling function is input-destructive. Input data is undefined after calling this function.

References arm_q7_to_q15_no_shift().

arm_status arm_avgpool_s16 | ( | const cmsis_nn_context * | ctx,
|  | const cmsis_nn_pool_params * | pool_params,
|  | const cmsis_nn_dims * | input_dims,
|  | const q15_t * | src,
|  | const cmsis_nn_dims * | filter_dims,
|  | const cmsis_nn_dims * | output_dims,
|  | q15_t * | dst
| ) |  |

References cmsis_nn_pool_params::activation, cmsis_nn_dims::c, cmsis_nn_tile::h, cmsis_nn_dims::h, MAX, cmsis_nn_activation::max, MIN, cmsis_nn_activation::min, cmsis_nn_pool_params::padding, cmsis_nn_pool_params::stride, cmsis_nn_tile::w, and cmsis_nn_dims::w.

int32_t arm_avgpool_s16_get_buffer_size | ( | const int | dim_dst_width,
|  | const int | ch_src
| ) |  |

Parameters

  [in] | dim_dst_width | output tensor dimension
  [in] | ch_src | number of input tensor channels

Returns
  The function returns required buffer size in bytes

arm_status arm_avgpool_s8 | ( | const cmsis_nn_context * | ctx,
|  | const cmsis_nn_pool_params * | pool_params,
|  | const cmsis_nn_dims * | input_dims,
|  | const q7_t * | input_data,
|  | const cmsis_nn_dims * | filter_dims,
|  | const cmsis_nn_dims * | output_dims,
|  | q7_t * | output_data
| ) |  |

Parameters

  [in,out] | ctx | Function context (e.g. temporary buffer). Check the function definition file to see if an additional buffer is required. Optional function {API}_get_buffer_size() provides the buffer size if an additional buffer is required.
  [in] | pool_params | Pooling parameters
  [in] | input_dims | Input (activation) tensor dimensions. Format: [H, W, C_IN] Argument 'N' is not used.
  [in] | input_data | Input (activation) data pointer. Data type: int8
  [in] | filter_dims | Filter tensor dimensions. Format: [H, W] Argument N and C are not used.
  [in] | output_dims | Output tensor dimensions. Format: [H, W, C_OUT] Argument N is not used. C_OUT equals C_IN.
  [in,out] | output_data | Output data pointer. Data type: int8

Returns
  The function returns `ARM_MATH_SUCCESS` - Successful operation

- Supported Framework: TensorFlow Lite

References cmsis_nn_pool_params::activation, arm_avgpool_s8_get_buffer_size(), cmsis_nn_context::buf, cmsis_nn_dims::c, cmsis_nn_tile::h, cmsis_nn_dims::h, MAX, cmsis_nn_activation::max, MIN, cmsis_nn_activation::min, cmsis_nn_pool_params::padding, cmsis_nn_pool_params::stride, cmsis_nn_tile::w, and cmsis_nn_dims::w.

int32_t arm_avgpool_s8_get_buffer_size | ( | const int | dim_dst_width,
|  | const int | ch_src
| ) |  |

Parameters

  [in] | dim_dst_width | output tensor dimension
  [in] | ch_src | number of input tensor channels

Returns
  The function returns required buffer size in bytes

Referenced by arm_avgpool_s8().

arm_status arm_max_pool_s16 | ( | const cmsis_nn_context * | ctx,
|  | const cmsis_nn_pool_params * | pool_params,
|  | const cmsis_nn_dims * | input_dims,
|  | const int16_t * | src,
|  | const cmsis_nn_dims * | filter_dims,
|  | const cmsis_nn_dims * | output_dims,
|  | int16_t * | dst
| ) |  |

Parameters

  [in,out] | ctx | Function context (e.g. temporary buffer). Check the function definition file to see if an additional buffer is required. Optional function {API}_get_buffer_size() provides the buffer size if an additional buffer is required.
  [in] | pool_params | Pooling parameters
  [in] | input_dims | Input (activation) tensor dimensions. Format: [H, W, C_IN] Argument 'N' is not used.
  [in] | src | Input (activation) data pointer. The input tensor must not overlap with the output tensor. Data type: int16
  [in] | filter_dims | Filter tensor dimensions. Format: [H, W] Argument N and C are not used.
  [in] | output_dims | Output tensor dimensions. Format: [H, W, C_OUT] Argument N is not used. C_OUT equals C_IN.
  [in,out] | dst | Output data pointer. Data type: int16

Returns
  The function returns `ARM_MATH_SUCCESS` - Successful operation

- Supported Framework: TensorFlow Lite

References cmsis_nn_pool_params::activation, cmsis_nn_dims::c, clamp_output(), compare_and_replace_if_larger(), cmsis_nn_tile::h, cmsis_nn_dims::h, MAX, cmsis_nn_activation::max, MIN, cmsis_nn_activation::min, cmsis_nn_pool_params::padding, cmsis_nn_pool_params::stride, cmsis_nn_tile::w, and cmsis_nn_dims::w.

arm_status arm_max_pool_s8 | ( | const cmsis_nn_context * | ctx,
|  | const cmsis_nn_pool_params * | pool_params,
|  | const cmsis_nn_dims * | input_dims,
|  | const q7_t * | input_data,
|  | const cmsis_nn_dims * | filter_dims,
|  | const cmsis_nn_dims * | output_dims,
|  | q7_t * | output_data
| ) |  |

Parameters

  [in,out] | ctx | Function context (e.g. temporary buffer). Check the function definition file to see if an additional buffer is required. Optional function {API}_get_buffer_size() provides the buffer size if an additional buffer is required.
  [in] | pool_params | Pooling parameters
  [in] | input_dims | Input (activation) tensor dimensions. Format: [H, W, C_IN] Argument 'N' is not used.
  [in] | input_data | Input (activation) data pointer. The input tensor must not overlap with the output tensor. Data type: int8
  [in] | filter_dims | Filter tensor dimensions. Format: [H, W] Argument N and C are not used.
  [in] | output_dims | Output tensor dimensions. Format: [H, W, C_OUT] Argument N is not used. C_OUT equals C_IN.
  [in,out] | output_data | Output data pointer. Data type: int8

Returns
  The function returns `ARM_MATH_SUCCESS` - Successful operation

- Supported Framework: TensorFlow Lite

References cmsis_nn_pool_params::activation, arm_memcpy_q7(), cmsis_nn_dims::c, clamp_output(), compare_and_replace_if_larger_q7(), cmsis_nn_tile::h, cmsis_nn_dims::h, MAX, cmsis_nn_activation::max, MIN, cmsis_nn_activation::min, cmsis_nn_pool_params::padding, cmsis_nn_pool_params::stride, cmsis_nn_tile::w, and cmsis_nn_dims::w.

void arm_maxpool_q7_HWC | ( | q7_t * | Im_in,
|  | const uint16_t | dim_im_in,
|  | const uint16_t | ch_im_in,
|  | const uint16_t | dim_kernel,
|  | const uint16_t | padding,
|  | const uint16_t | stride,
|  | const uint16_t | dim_im_out,
|  | q7_t * | bufferA,
|  | q7_t * | Im_out
| ) |  |

Parameters

  [in,out] | Im_in | pointer to input tensor
  [in] | dim_im_in | input tensor dimention
  [in] | ch_im_in | number of input tensor channels
  [in] | dim_kernel | filter kernel size
  [in] | padding | padding sizes
  [in] | stride | convolution stride
  [in] | dim_im_out | output tensor dimension
  [in,out] | bufferA | Not used
  [in,out] | Im_out | pointer to output tensor

The pooling function is implemented as split x-pooling then y-pooling.

This pooling function is input-destructive. Input data is undefined after calling this function.

References compare_and_replace_if_larger_q7().