NMSIS-NN  Version 1.0.2
NMSIS NN Software Library
Pooling Functions

Perform pooling functions, including max pooling and average pooling. More...

Functions

riscv_status riscv_avgpool_s8 (const nmsis_nn_context *ctx, const nmsis_nn_pool_params *pool_params, const nmsis_nn_dims *input_dims, const q7_t *src, const nmsis_nn_dims *filter_dims, const nmsis_nn_dims *output_dims, q7_t *dst)
 s8 average pooling function. More...
 
int32_t riscv_avgpool_s8_get_buffer_size (const int output_x, const int ch_src)
 Get the required buffer size for S8 average pooling function. More...
 
riscv_status riscv_max_pool_s8 (const nmsis_nn_context *ctx, const nmsis_nn_pool_params *pool_params, const nmsis_nn_dims *input_dims, const q7_t *src, const nmsis_nn_dims *filter_dims, const nmsis_nn_dims *output_dims, q7_t *dst)
 s8 max pooling function. More...
 
void riscv_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 riscv_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...
 

Detailed Description

Perform pooling functions, including max pooling and average pooling.

Function Documentation

◆ riscv_avepool_q7_HWC()

void riscv_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.

Parameters
[in,out]Im_inpointer to input tensor
[in]dim_im_ininput tensor dimention
[in]ch_im_innumber of input tensor channels
[in]dim_kernelfilter kernel size
[in]paddingpadding sizes
[in]strideconvolution stride
[in]dim_im_outoutput tensor dimension
[in,out]bufferApointer to buffer space for input
[in,out]Im_outpointer 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.

◆ riscv_avgpool_s8()

riscv_status riscv_avgpool_s8 ( const nmsis_nn_context ctx,
const nmsis_nn_pool_params pool_params,
const nmsis_nn_dims input_dims,
const q7_t *  input_data,
const nmsis_nn_dims filter_dims,
const nmsis_nn_dims output_dims,
q7_t *  output_data 
)

s8 average pooling function.

Parameters
[in,out]ctxFunction 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_paramsPooling parameters
[in]input_dimsInput (activation) tensor dimensions. Format: [H, W, C_IN] Argument 'N' is not used.
[in]input_dataInput (activation) data pointer. Data type: int8
[in]filter_dimsFilter tensor dimensions. Format: [H, W] Argument N and C are not used.
[in]output_dimsOutput tensor dimensions. Format: [H, W, C_OUT] Argument N is not used. C_OUT equals C_IN.
[in,out]output_dataOutput data pointer. Data type: int8
Returns
The function returns RISCV_MATH_SUCCESS - Successful operation
  • Supported Framework: TensorFlow Lite

◆ riscv_avgpool_s8_get_buffer_size()

int32_t riscv_avgpool_s8_get_buffer_size ( const int  dim_dst_width,
const int  ch_src 
)

Get the required buffer size for S8 average pooling function.

Parameters
[in]dim_dst_widthoutput tensor dimension
[in]ch_srcnumber of input tensor channels
Returns
The function returns required buffer size in bytes

◆ riscv_max_pool_s8()

riscv_status riscv_max_pool_s8 ( const nmsis_nn_context ctx,
const nmsis_nn_pool_params pool_params,
const nmsis_nn_dims input_dims,
const q7_t *  input_data,
const nmsis_nn_dims filter_dims,
const nmsis_nn_dims output_dims,
q7_t *  output_data 
)

s8 max pooling function.

Parameters
[in,out]ctxFunction 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_paramsPooling parameters
[in]input_dimsInput (activation) tensor dimensions. Format: [H, W, C_IN] Argument 'N' is not used.
[in]input_dataInput (activation) data pointer. Data type: int8
[in]filter_dimsFilter tensor dimensions. Format: [H, W] Argument N and C are not used.
[in]output_dimsOutput tensor dimensions. Format: [H, W, C_OUT] Argument N is not used. C_OUT equals C_IN.
[in,out]output_dataOutput data pointer. Data type: int8
Returns
The function returns RISCV_MATH_SUCCESS - Successful operation
  • Supported Framework: TensorFlow Lite

◆ riscv_maxpool_q7_HWC()

void riscv_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.

Parameters
[in,out]Im_inpointer to input tensor
[in]dim_im_ininput tensor dimention
[in]ch_im_innumber of input tensor channels
[in]dim_kernelfilter kernel size
[in]paddingpadding sizes
[in]strideconvolution stride
[in]dim_im_outoutput tensor dimension
[in,out]bufferANot used
[in,out]Im_outpointer 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.