AIfES 2  2.0.0
ailayer_maxpool2d.h
Go to the documentation of this file.
1 
38 #ifndef AILAYER_MAXPOOL2D_H
39 #define AILAYER_MAXPOOL2D_H
40 
41 #include "core/aifes_core.h"
42 
43 #define AIFES_CHANNELS_FIRST 1
44 #define AIFES_CHANNELS_LAST -1
45 
47 
60  // Values (configurable)
61  uint16_t pool_size[2];
62  uint16_t stride[2];
63  uint16_t padding[2]; // Must be 0 >= padding < pool_size; -inf padding
64 
65  int8_t channel_axis;
67 
72  // Values (autogenerated)
73  uint32_t *max_locations;
75  void *optimem[2];
77 
82 
99  void (*maxpool2d_fwd)(
100  const aitensor_t *input,
101  const uint16_t pool_size[2],
102  const uint16_t stride[2],
103  const uint16_t padding[2],
104  int8_t channel_axis,
105  void *work_space,
106  uint32_t *max_locations,
107  aitensor_t *output
108  );
109 
126  void (*maxpool2d_bwd)(
127  const aitensor_t *delta_out,
128  const uint16_t pool_size[2],
129  const uint16_t stride[2],
130  const uint16_t padding[2],
131  int8_t channel_axis,
132  void *work_space,
133  const uint32_t *max_locations,
134  aitensor_t *delta_in
135  );
137 
138  uint16_t result_shape[4];
139 };
140 
147 
160 
174 
188 
205 
216 
226 void ailayer_maxpool2d_set_trainmem(ailayer_t *self, void *memory_ptr);
227 
228 #ifdef AIDEBUG_PRINT_MODULE_SPECS
234 #endif // AIDEBUG_PRINT_MODULE_SPECS
235 
236 #endif // AILAYER_MAXPOOL2D_H
AIfES 2 core interface.
void ailayer_maxpool2d_set_trainmem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the gradients pointers.
ailayer_t * ailayer_maxpool2d(ailayer_maxpool2d_t *layer, ailayer_t *input_layer)
Initialize and connect the given MaxPool2D layer.
void ailayer_maxpool2d_forward(ailayer_t *self)
Calculate the forward pass for given MaxPool2D layer.
uint32_t ailayer_maxpool2d_sizeof_trainmem(const ailayer_t *self)
Calculate and return the memory size needed by this layer for training.
const aicore_layertype_t * ailayer_maxpool2d_type
MaxPool2D layer type.
void ailayer_maxpool2d_backward(ailayer_t *self)
Calculate the backward pass for given MaxPool2D layer.
void ailayer_maxpool2d_calc_result_shape(ailayer_t *self)
Calculate the shape of the result tensor (ailayer.result)
void ailayer_maxpool2d_print_specs(const ailayer_t *self)
Print the layer specification.
Type indicator of the layer.
Definition: aifes_core.h:82
General layer structure.
Definition: ailayer_maxpool2d.h:51
uint16_t result_shape[4]
The shape of the result.
Definition: ailayer_maxpool2d.h:138
uint32_t * max_locations
Pointer to memory section where the indices of the maximum values per pooling window are stored.
Definition: ailayer_maxpool2d.h:73
void * optimem[2]
Memory field used by the optimizer for training.
Definition: ailayer_maxpool2d.h:75
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.
Definition: ailayer_maxpool2d.h:99
uint16_t padding[2]
The (symmetric) minus infinity padding in the direction of height and width ( ).
Definition: ailayer_maxpool2d.h:63
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.
Definition: ailayer_maxpool2d.h:126
uint16_t stride[2]
The stride in the direction of height and width ( ).
Definition: ailayer_maxpool2d.h:62
ailayer_t base
Inherited field members from general ailayer struct.
Definition: ailayer_maxpool2d.h:52
uint16_t pool_size[2]
Size of the pooling kernel ( ).
Definition: ailayer_maxpool2d.h:61
int8_t channel_axis
Index of the channel axis (1 for channels first and -1 or 3 for channels last).
Definition: ailayer_maxpool2d.h:65
AIfES layer interface.
Definition: aifes_core.h:252
A tensor in AIfES.
Definition: aifes_math.h:89