AIfES 2  2.0.0
ailayer_template.h
Go to the documentation of this file.
1 
28 #ifndef TEMPLATE_LAYER
29 #define TEMPLATE_LAYER
30 
31 #include "core/aifes_core.h"
32 
34 
39  ailayer_t base; // The base or super "class" of the layer.
42  // Configurations of the layer, that can be configured by the user when creating the layer
43  uint32_t example_configuration;
44 
45  // Tensor pointer for trainable parameters [DEPRECATED]
46  aitensor_t *params;
47  aitensor_t *d_params; // Gradients
48 
49  // If the shape of the result differs from the input shape, this array can be used for the result.
50  // If not, the result shape array of the input tensor can be used for the result tensor too.
51  uint16_t result_shape[2];
55  void *optimem[2];
57  // Make the math functions accessable for expert developers
58  void (*copy_tensor)(const aitensor_t *from, aitensor_t *to);
59  void (*tensor_add)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result);
60 };
61 
62 extern const aicore_layertype_t *ailayer_template_type;
73 
79 
85 
91 
99 
105 void ailayer_template_set_paramem(ailayer_t *self, void *memory_ptr);
106 
114 
120 void ailayer_template_set_trainmem(ailayer_t *self, void *memory_ptr);
121 
122 #ifdef AIDEBUG_PRINT_MODULE_SPECS
128 void ailayer_template_print_specs(const ailayer_t *self, int (*print)(const char *format, ...));
129 #endif
130 
131 #endif // TEMPLATE_LAYER
AIfES 2 core interface.
void ailayer_template_calc_result_shape(ailayer_t *self)
Calculate the shape of the result tensor.
void ailayer_template_set_trainmem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the training gradients pointers - mandatory for hidden layers
uint32_t ailayer_template_sizeof_paramem(const ailayer_t *self)
Calculate and return the parameter memory size needed for this layer - mandatory for hidden layers
void ailayer_template_set_paramem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the parameter pointers - mandatory for hidden layers
ailayer_t * ailayer_template(ailayer_template_t *layer, ailayer_t *input_layer)
Initialize the given layer struct - mandatory
void ailayer_template_forward(ailayer_t *self)
Calculate the forward path for given layer - mandatory
void ailayer_template_backward(ailayer_t *self)
Calculate the backward (training) path for the given layer - depends on usability in training
uint32_t ailayer_template_sizeof_trainmem(const ailayer_t *self)
Calculate and return the necessary memory size needed by this layer for training - mandatory for hidd...
void ailayer_template_print_specs(const ailayer_t *self, int(*print)(const char *format,...))
Print the layer specification.
Type indicator of the layer.
Definition: aifes_core.h:81
Template for general AIfES layers.
Definition: ailayer_template.h:38
aitensor_t * gradients[2]
Gradients structure for the back propagation algorithm.
Definition: ailayer_template.h:54
void * optimem[2]
Memory field used by the trainings optimizer.
Definition: ailayer_template.h:55
void(* tensor_add)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Function pointer to the used tensor addition.
Definition: ailayer_template.h:59
void(* copy_tensor)(const aitensor_t *from, aitensor_t *to)
Function pointer to the used tensor copy function.
Definition: ailayer_template.h:58
ailayer_t base
Inherited field members from general ailayer struct.
Definition: ailayer_template.h:39
uint16_t result_shape[2]
Inference result tensor shape (n x m matrix).
Definition: ailayer_template.h:51
const aimath_dtype_t * dtype
Datatype of the inference result values.
Definition: ailayer_template.h:40
aitensor_t * trainable_params[2]
Pointer to the weights and biases (which are the trainable parameters).
Definition: ailayer_template.h:53
AIfES layer interface.
Definition: aifes_core.h:251
Indicator for the used datatype.
Definition: aifes_math.h:53
A tensor in AIfES.
Definition: aifes_math.h:98