# heliaCORE.Pooling

Perform max and average pooling operations

## arm_max_pool_f32

`function` · `c`

```c
arm_cmsis_nn_status arm_max_pool_f32(
    const cmsis_nn_context *ctx,
    const cmsis_nn_pool_params_f32 *pool_params,
    const cmsis_nn_dims *input_dims,
    const float32_t *src,
    const cmsis_nn_dims *filter_dims,
    const cmsis_nn_dims *output_dims,
    float32_t *dst
)
```

Max pooling.

**Parameters**

| Name | Type | Direction | Description |
| --- | --- | --- | --- |
| ctx | const cmsis_nn_context * | in, out | Function context that may hold a temporary scratch buffer. |
| pool_params | const cmsis_nn_pool_params_f32 * | in | Pooling parameters (stride, padding and activation clamp). |
| input_dims | const cmsis_nn_dims * | in | Input tensor dimensions. |
| src | const float32_t * | in | Pointer to the input tensor data. |
| filter_dims | const cmsis_nn_dims * | in | Pooling kernel dimensions. |
| output_dims | const cmsis_nn_dims * | in | Output tensor dimensions. |
| dst | float32_t * | out | Pointer to the output tensor data. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  |  | `ARM_CMSIS_NN_SUCCESS` on success, including an output with no rows or no columns (an extent of 0 or less), which writes nothing; `ARM_CMSIS_NN_ARG_ERROR` on invalid arguments: a NULL pointer argument other than ctx, a batch count below 1, a pooling window that does not overlap the input, or window positions (output index * stride - padding, including one stride past the last window, plus the filter extent, and input size minus position) that do not fit in an int32_t. Nothing is written to dst then. |

Source: `Include/arm_nnfunctions_flt.h:540`

## arm_avg_pool_f32

`function` · `c`

```c
arm_cmsis_nn_status arm_avg_pool_f32(
    const cmsis_nn_context *ctx,
    const cmsis_nn_pool_params_f32 *pool_params,
    const cmsis_nn_dims *input_dims,
    const float32_t *src,
    const cmsis_nn_dims *filter_dims,
    const cmsis_nn_dims *output_dims,
    float32_t *dst
)
```

Average pooling.

**Parameters**

| Name | Type | Direction | Description |
| --- | --- | --- | --- |
| ctx | const cmsis_nn_context * | in, out | Function context that may hold a temporary scratch buffer. |
| pool_params | const cmsis_nn_pool_params_f32 * | in | Pooling parameters (stride, padding and activation clamp). |
| input_dims | const cmsis_nn_dims * | in | Input tensor dimensions. |
| src | const float32_t * | in | Pointer to the input tensor data. |
| filter_dims | const cmsis_nn_dims * | in | Pooling kernel dimensions. |
| output_dims | const cmsis_nn_dims * | in | Output tensor dimensions. |
| dst | float32_t * | out | Pointer to the output tensor data. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  |  | `ARM_CMSIS_NN_SUCCESS` on success, including an output with no rows or no columns (an extent of 0 or less), which writes nothing; `ARM_CMSIS_NN_ARG_ERROR` on invalid arguments: a NULL pointer argument other than ctx, a batch count below 1, a pooling window that does not overlap the input, or window positions (output index * stride - padding, including one stride past the last window, plus the filter extent, and input size minus position) that do not fit in an int32_t. Nothing is written to dst then. |

Source: `Include/arm_nnfunctions_flt.h:565`

## arm_max_pool_f16

`function` · `c`

```c
arm_cmsis_nn_status arm_max_pool_f16(
    const cmsis_nn_context *ctx,
    const cmsis_nn_pool_params_f16 *pool_params,
    const cmsis_nn_dims *input_dims,
    const float16_t *src,
    const cmsis_nn_dims *filter_dims,
    const cmsis_nn_dims *output_dims,
    float16_t *dst
)
```

Max pooling.

:::note
The output activation clamp on the scalar (non-MVE) build path is the bit-classified clamp of #380, so a NaN that reaches the clamp comes back as NaN at every optimization level on the gated toolchains rather than as a bound. A NaN rarely reaches it, though: the scalar max reduction uses an ordered compare that drops a NaN window element (and its NaN behavior at the shipped -Ofast is unspecified), and the MVE path's vmaxnmq reduction and vmaxnmq/vminnmq clamp suppress NaN, so this kernel does not promise NaN propagation end to end.

:::

**Parameters**

| Name | Type | Direction | Description |
| --- | --- | --- | --- |
| ctx | const cmsis_nn_context * | in, out | Function context that may hold a temporary scratch buffer. |
| pool_params | const cmsis_nn_pool_params_f16 * | in | Pooling parameters (stride, padding and activation clamp). |
| input_dims | const cmsis_nn_dims * | in | Input tensor dimensions. |
| src | const float16_t * | in | Pointer to the input tensor data. |
| filter_dims | const cmsis_nn_dims * | in | Pooling kernel dimensions. |
| output_dims | const cmsis_nn_dims * | in | Output tensor dimensions. |
| dst | float16_t * | out | Pointer to the output tensor data. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  |  | `ARM_CMSIS_NN_SUCCESS` on success, including an output with no rows or no columns (an extent of 0 or less), which writes nothing; `ARM_CMSIS_NN_ARG_ERROR` on invalid arguments: a NULL pointer argument other than ctx, a batch count below 1, a pooling window that does not overlap the input, or window positions (output index * stride - padding, including one stride past the last window, plus the filter extent, and input size minus position) that do not fit in an int32_t. Nothing is written to dst then. |

Source: `Include/arm_nnfunctions_flt.h:2695`

## arm_avg_pool_f16

`function` · `c`

```c
arm_cmsis_nn_status arm_avg_pool_f16(
    const cmsis_nn_context *ctx,
    const cmsis_nn_pool_params_f16 *pool_params,
    const cmsis_nn_dims *input_dims,
    const float16_t *src,
    const cmsis_nn_dims *filter_dims,
    const cmsis_nn_dims *output_dims,
    float16_t *dst
)
```

Average pooling.

:::note
On non-MVE builds every output element goes through the bit-classified scalar clamp of #380, so a NaN in the pooling window propagates through the window sum and the output activation clamp to the output element at every optimization level on the gated toolchains, including the shipped -Ofast. On MVE builds the clamp is vmaxnmq/vminnmq with no NaN restore, so a NaN resolves to a clamp bound there instead.

:::

**Parameters**

| Name | Type | Direction | Description |
| --- | --- | --- | --- |
| ctx | const cmsis_nn_context * | in, out | Function context that may hold a temporary scratch buffer. |
| pool_params | const cmsis_nn_pool_params_f16 * | in | Pooling parameters (stride, padding and activation clamp). |
| input_dims | const cmsis_nn_dims * | in | Input tensor dimensions. |
| src | const float16_t * | in | Pointer to the input tensor data. |
| filter_dims | const cmsis_nn_dims * | in | Pooling kernel dimensions. |
| output_dims | const cmsis_nn_dims * | in | Output tensor dimensions. |
| dst | float16_t * | out | Pointer to the output tensor data. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  |  | `ARM_CMSIS_NN_SUCCESS` on success, including an output with no rows or no columns (an extent of 0 or less), which writes nothing; `ARM_CMSIS_NN_ARG_ERROR` on invalid arguments: a NULL pointer argument other than ctx, a batch count below 1, a pooling window that does not overlap the input, or window positions (output index * stride - padding, including one stride past the last window, plus the filter extent, and input size minus position) that do not fit in an int32_t. Nothing is written to dst then. |

Source: `Include/arm_nnfunctions_flt.h:2712`
