AIfES 2  2.0.0
ailayer_dense Struct Reference

General Dense layer structure. More...

#include <ailayer_dense.h>

Data Fields

ailayer_t base
 Inherited field members from general ailayer struct.
 
uint16_t result_shape [2]
 Inference result tensor (ailayer.result) shape.
 
Layer configuration

Required configuration parameters for the layer

These fields have to be configured by the user before calling the initializer function.

uint32_t neurons
 Layer neurons count (number of outputs).
 
Trainable parameters

Data fields for the trainable parameters (weights, bias) of the layer

aitensor_t weights
 Tensor containing the layer weights.
 
aitensor_t bias
 Tensor containing the layer bias weights.
 
uint16_t weights_shape [2]
 Weights tensor shape (n x m matrix).
 
uint16_t bias_shape [1]
 Bias weights tensor shape (n x m matrix).
 
aitensor_ttrainable_params [2]
 Pointer to the weights and biases (which are the trainable parameters).
 
aitensor_tgradients [2]
 Gradients structure for the back propagation algorithm.
 
void * optimem [2]
 Memory field used by the trainings optimizer.
 
Math functions

Required data type specific math functions

void(* linear )(const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result)
 Required math function: Linear transformation. More...
 
void(* mat_mul_at )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Required math function: Matrix multiplication with transposed a. More...
 
void(* mat_mul_bt )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Required math function: Matrix multiplication with transposed b. More...
 
void(* tensor_add )(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Required math function: Element wise tensor addition. More...
 
void(* sum_channelwise )(const aitensor_t *a, int8_t channel_axis, aitensor_t *result)
 Required math function: Channel-wise sum. More...
 

Detailed Description

General Dense layer structure.

Field Documentation

◆ linear

void(* linear) (const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result)

Required math function: Linear transformation.

Requires a math function that performs a linear transformation:

\[ result = a \cdot b \oplus c = a \cdot b + \left( \begin{array}{c} 1 \\ \vdots \\ 1 \\ \end{array}\right) \cdot c \]

Parameters
aMatrix with dimension \( N \times K \) (input)
bMatrix with dimension \( K \times M \) (input)
cLaying vektor with dimension \( 1 \times M \) (input)
resultMatrix with dimension \( N \times M \) (output)

◆ mat_mul_at

void(* mat_mul_at) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)

Required math function: Matrix multiplication with transposed a.

Requires a math function that performs a matrix multiplication on two 2D tensors:

\[ result = a^T \cdot b \]

Parameters
aMatrix with dimension \( K \times N \) (input)
bMatrix with dimension \( K \times M \) (input)
resultMatrix with dimension \( N \times M \) (output)

◆ mat_mul_bt

void(* mat_mul_bt) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)

Required math function: Matrix multiplication with transposed b.

Requires a math function that performs a matrix multiplication on two 2D tensors:

\[ result = a \cdot b^T \]

Parameters
aMatrix with dimension \( N \times K \) (input)
bMatrix with dimension \( M \times K \) (input)
resultMatrix with dimension \( N \times M \) (output)

◆ sum_channelwise

void(* sum_channelwise) (const aitensor_t *a, int8_t channel_axis, aitensor_t *result)

Required math function: Channel-wise sum.

Requires a math function that calculates the sum of all elements of each channel c. The result tensor is 1D.:

\[ result_c = \sum_i(a_{ci}) \]

◆ tensor_add

void(* tensor_add) (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)

Required math function: Element wise tensor addition.

Requires a math function that adds two tensors element-wise:

\[ result = a + b \]


The documentation for this struct was generated from the following file: