60 #define DENSE_WEIGHTS_SIZE(INPUTS, OUTPUTS) ((INPUTS) * (OUTPUTS))
61 #define DENSE_BIAS_SIZE(OUTPUTS) (OUTPUTS)
63 #define DENSE_WEIGHTS_SHAPE(INPUTS, OUTPUTS) {INPUTS, OUTPUTS}
64 #define DENSE_BIAS_SHAPE(OUTPUTS) {1, OUTPUTS}
258 uint32_t ailayer_dense_sizeof_bwdmem(
const ailayer_t *
self);
307 #ifdef AIDEBUG_PRINT_MODULE_SPECS
const aicore_layertype_t * ailayer_dense_type
Dense layer type.
void ailayer_dense_print_specs(const ailayer_t *self)
Print the layer specification.
void ailayer_dense_set_paramem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the parameter pointers.
ailayer_t * ailayer_dense(ailayer_dense_t *layer, ailayer_t *input_layer)
Initialize and connect the given Dense layer.
void ailayer_dense_backward(ailayer_t *self)
Calculate the backward pass for the given Dense layer.
void ailayer_dense_forward(ailayer_t *self)
Calculate the forward pass for given Dense layer.
void ailayer_dense_set_trainmem(ailayer_t *self, void *memory_ptr)
Distribute provided memory to the gradients pointers.
uint32_t ailayer_dense_sizeof_trainmem(const ailayer_t *self)
Calculate and return the memory size needed by this layer for training.
uint32_t ailayer_dense_sizeof_paramem(const ailayer_t *self)
Calculate and return the parameter memory size needed for this layer.
void ailayer_dense_calc_result_shape(ailayer_t *self)
Calculate the shape of the result tensor (ailayer.result)
Math functions for F32 data type, default implementation.
Definition of the Q31 (aiq31) data-type.
Math functions for Q7 data type, default implementation.
Type indicator of the layer.
Definition: aifes_core.h:82
General Dense layer structure.
Definition: ailayer_dense.h:71
uint16_t weights_shape[2]
Weights tensor shape (n x m matrix).
Definition: ailayer_dense.h:90
uint16_t bias_shape[1]
Bias weights tensor shape (n x m matrix).
Definition: ailayer_dense.h:91
aitensor_t * gradients[2]
Gradients structure for the back propagation algorithm.
Definition: ailayer_dense.h:94
void(* mat_mul_bt)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Required math function: Matrix multiplication with transposed b.
Definition: ailayer_dense.h:141
void(* sum_channelwise)(const aitensor_t *a, int8_t channel_axis, aitensor_t *result)
Required math function: Channel-wise sum.
Definition: ailayer_dense.h:159
void * optimem[2]
Memory field used by the trainings optimizer.
Definition: ailayer_dense.h:95
void(* linear)(const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result)
Required math function: Linear transformation.
Definition: ailayer_dense.h:115
void(* tensor_add)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Required math function: Element wise tensor addition.
Definition: ailayer_dense.h:150
aitensor_t bias
Tensor containing the layer bias weights.
Definition: ailayer_dense.h:88
void(* mat_mul_at)(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Required math function: Matrix multiplication with transposed a.
Definition: ailayer_dense.h:128
uint32_t neurons
Layer neurons count (number of outputs).
Definition: ailayer_dense.h:80
ailayer_t base
Inherited field members from general ailayer struct.
Definition: ailayer_dense.h:72
uint16_t result_shape[2]
Inference result tensor (ailayer.result) shape.
Definition: ailayer_dense.h:163
aitensor_t weights
Tensor containing the layer weights.
Definition: ailayer_dense.h:87
aitensor_t * trainable_params[2]
Pointer to the weights and biases (which are the trainable parameters).
Definition: ailayer_dense.h:93
AIfES layer interface.
Definition: aifes_core.h:252
A tensor in AIfES.
Definition: aifes_math.h:89