|  | AIfES 2
    2.0.0
    | 
General layer structure. More...
#include <ailayer_maxpool2d.h>
| Data Fields | |
| ailayer_t | base | 
| Inherited field members from general ailayer struct. | |
| uint16_t | result_shape [4] | 
| The shape of the result. | |
| Layer configuration | |
| Required configuration parameters for the layer These fields have to be configured by the user before calling the initializer function. | |
| uint16_t | pool_size [2] | 
| Size of the pooling kernel ( \( [H_{pool}, W_{pool}] \)). | |
| uint16_t | stride [2] | 
| The stride in the direction of height and width ( \( [S_{h}, S_{w}] \)). | |
| uint16_t | padding [2] | 
| The (symmetric) minus infinity padding in the direction of height and width ( \( [P_{h}, P_{w}], \; 0 \leq P_h < H_{pool}, 0 \leq P_w < W_{pool} \)). | |
| int8_t | channel_axis | 
| Index of the channel axis (1 for channels first and -1 or 3 for channels last). | |
| Training parameters | |
| Data fields required for the training of the layer | |
| uint32_t * | max_locations | 
| Pointer to memory section where the indices of the maximum values per pooling window are stored. | |
| void * | optimem [2] | 
| Memory field used by the optimizer for training. | |
| Math functions | |
| Required data type specific math functions | |
| void(* | maxpool2d_fwd )(const aitensor_t *input, const uint16_t pool_size[2], const uint16_t stride[2], const uint16_t padding[2], int8_t channel_axis, void *work_space, uint32_t *max_locations, aitensor_t *output) | 
| Required math function: 2D Max-Pooling.  More... | |
| void(* | maxpool2d_bwd )(const aitensor_t *delta_out, const uint16_t pool_size[2], const uint16_t stride[2], const uint16_t padding[2], int8_t channel_axis, void *work_space, const uint32_t *max_locations, aitensor_t *delta_in) | 
| Required math function: Gradients of 2D Max-Pooling with respect to the input.  More... | |
General layer structure.
| void(* maxpool2d_bwd) (const aitensor_t *delta_out, const uint16_t pool_size[2], const uint16_t stride[2], const uint16_t padding[2], int8_t channel_axis, void *work_space, const uint32_t *max_locations, aitensor_t *delta_in) | 
Required math function: Gradients of 2D Max-Pooling with respect to the input.
Requires a math function that calculates the gradients with respect to the input \( delta_{in} = \mathrm{d} L / \mathrm{d} x_{in} \).
This is done by simply copying the output gradient to the position in the input gradients depicted by max_locations.
An element of max_locations consist of the concatenated 16-bit indices for height and width in the pooling window.
| delta_out | Gradients backpropagated from the following layer with dimension \( [N,C,H_{out},W_{out}] \) (channels first) or \( [N,H_{out},W_{out},C] \) (channels last) | 
| pool_size | The size of the pooling window (height and width) | 
| stride | The stride in the direction of height and width. | 
| padding | The (symmetric) minus infinity padding in the direction of height and width | 
| channel_axis | Index of the channel axis (1 for channels first and -1 or 3 for channels last). | 
| workspace | Pointer to a work space buffer for intermediate results. | 
| max_locations | Pointer to memory section where the indices of the maximum values per pooling window are stored. | 
| delta_in | Resulting input gradients for backpropagation to the previous layer \( [N,C,H_{in},W_{in}] \) (channels first) or \( [N,H_{in},W_{in},C] \) (channels last) | 
| void(* maxpool2d_fwd) (const aitensor_t *input, const uint16_t pool_size[2], const uint16_t stride[2], const uint16_t padding[2], int8_t channel_axis, void *work_space, uint32_t *max_locations, aitensor_t *output) | 
Required math function: 2D Max-Pooling.
Requires a math function that extracts the maximum from a kernel window.
For training (max_locations != 0), the index of the max-value in the kernel window must be stored in max_locations.
An element of max_locations simply consist of the concatenated 16-bit indices for height and width in the pooling window.
| input | Input data with dimension \( [N,C,H_{in},W_{in}] \) (channels first) or \( [N,H_{in},W_{in},C] \) (channels last) | 
| pool_size | The size of the pooling window (height and width) | 
| stride | The stride in the direction of height and width. | 
| padding | The (symmetric) minus infinity padding in the direction of height and width | 
| channel_axis | Index of the channel axis (1 for channels first and -1 or 3 for channels last). | 
| workspace | Pointer to a work space buffer for intermediate results. | 
| max_locations | Pointer to memory section where the indices of the maximum values per pooling window are stored. | 
| output | Output after max-pooling with dimension \( [N,C,H_{out},W_{out}] \) (channels first) or \( [N,H_{out},W_{out},C] \) (channels last) |