AIfES 2
2.0.0
|
Default implementation of the Dense layer . More...
Go to the source code of this file.
Typedefs | |
typedef struct ailayer_dense | ailayer_dense_f32_t |
typedef struct ailayer_dense | ailayer_dense_q31_t |
typedef struct ailayer_dense | ailayer_dense_q7_t |
Functions | |
ailayer_t * | ailayer_dense_f32_default (ailayer_dense_f32_t *layer, ailayer_t *input_layer) |
Initializes and connect a Dense layer with the F32 default implementation. More... | |
ailayer_t * | ailayer_dense_wt_f32_default (ailayer_dense_f32_t *layer, ailayer_t *input_layer) |
Initializes and connect a Dense layer with the F32 default implementation. More... | |
ailayer_t * | ailayer_dense_q31_default (ailayer_dense_q31_t *layer, ailayer_t *input_layer) |
Initializes and connect a Dense layer with the Q31 default implementation. More... | |
ailayer_t * | ailayer_dense_q7_default (ailayer_dense_q7_t *layer, ailayer_t *input_layer) |
Initializes and connect a Dense layer with the Q7 default implementation. More... | |
ailayer_t * | ailayer_dense_wt_q7_default (ailayer_dense_q7_t *layer, ailayer_t *input_layer) |
Initializes and connect a Dense layer with the Q7 default implementation for transposed weights tensor. More... | |
void | ailayer_dense_init_params_f32_default (ailayer_t *self) |
F32 default implementation of the ailayer.init_params function for the Conv2D layer More... | |
void | ailayer_dense_init_params_q31_default (ailayer_t *self) |
Q31 default implementation of the ailayer.init_params function for the Conv2D layer More... | |
void | ailayer_dense_quantize_q7_from_f32 (ailayer_dense_f32_t *f32_layer_ptr, ailayer_dense_q7_t *q7_layer_ptr) |
Convert a F32 dense layer to a Q7 representation. More... | |
Default implementation of the Dense layer .
Hardware independent implementations of the Dense layer in F32 , Q31 and Q7 data-type. For more information about the Dense layer refer to ailayer_dense.h.
ailayer_t* ailayer_dense_f32_default | ( | ailayer_dense_f32_t * | layer, |
ailayer_t * | input_layer | ||
) |
Initializes and connect a Dense layer with the F32 default implementation.
Example: Create the layer structure with pretrained weights:
In C:
In C, C++ and on Arduino:
Example: Create the layer structure for automatic parameter distribution:
In C:
In C, C++ and on Arduino:
Example: Initialize and connect the layer:
*layer | The layer structure to initialize. |
*input_layer | The prior layer. |
void ailayer_dense_init_params_f32_default | ( | ailayer_t * | self | ) |
F32 default implementation of the ailayer.init_params function for the Conv2D layer
Implementation of ailayer.init_params.
The function will initialize the weights and bias depending on the following activation function.
Activation function | Weights-init | Bias-init |
---|---|---|
None, tanh, logistic, softmax | Glorot | Zeros |
ReLu and variants | He | Zeros |
*self | The layer structure |
void ailayer_dense_init_params_q31_default | ( | ailayer_t * | self | ) |
Q31 default implementation of the ailayer.init_params function for the Conv2D layer
Implementation of ailayer.init_params.
The function will initialize the weights and bias depending on the following activation function.
Activation function | Weights-init | Bias-init |
---|---|---|
None, tanh, logistic, softmax | Glorot | Zeros |
ReLu and variants | He | Zeros |
*self | The layer structure |
ailayer_t* ailayer_dense_q31_default | ( | ailayer_dense_q31_t * | layer, |
ailayer_t * | input_layer | ||
) |
Initializes and connect a Dense layer with the Q31 default implementation.
Example: Create the layer structure with pretrained weights:
In C:
In C, C++ and on Arduino:
Example: Create the layer structure for automatic parameter distribution:
In C:
In C, C++ and on Arduino:
Example: Initialize and connect the layer:
*layer | The layer structure to initialize. |
*input_layer | The prior layer. |
ailayer_t* ailayer_dense_q7_default | ( | ailayer_dense_q7_t * | layer, |
ailayer_t * | input_layer | ||
) |
Initializes and connect a Dense layer with the Q7 default implementation.
Example: Create the layer structure with pretrained weights:
In C:
In C, C++ and on Arduino:
Example: Create the layer structure for automatic parameter distribution:
In C:
In C, C++ and on Arduino:
Example: Initialize and connect the layer:
*layer | The layer structure to initialize. |
*input_layer | The prior layer. |
void ailayer_dense_quantize_q7_from_f32 | ( | ailayer_dense_f32_t * | f32_layer_ptr, |
ailayer_dense_q7_t * | q7_layer_ptr | ||
) |
Convert a F32 dense layer to a Q7 representation.
The weights get 8 bit quantied and the bias gets 32 bit quantized for optimal results.
Quantizsation parameters for the previous layer need to be calculated before calling this function.
*f32_layer_ptr | The source layer structure. |
*q7_layer_ptr | The destination layer structure. |
ailayer_t* ailayer_dense_wt_f32_default | ( | ailayer_dense_f32_t * | layer, |
ailayer_t * | input_layer | ||
) |
Initializes and connect a Dense layer with the F32 default implementation.
This implementation is the same as ailayer_dense_f32_default() but with a transposed weights matrix/tensor. This may lead to a speedup in runtime and makes hardware accelerator usage easier.
Example: Create the layer structure with pretrained weights:
In C:
In C, C++ and on Arduino:
Example: Create the layer structure for automatic parameter distribution:
In C:
In C, C++ and on Arduino:
Example: Initialize and connect the layer:
*layer | The layer structure to initialize. |
*input_layer | The prior layer. |
ailayer_t* ailayer_dense_wt_q7_default | ( | ailayer_dense_q7_t * | layer, |
ailayer_t * | input_layer | ||
) |
Initializes and connect a Dense layer with the Q7 default implementation for transposed weights tensor.
This implementation is the same as ailayer_dense_q7_default() but with a transposed weights matrix/tensor. This may lead to a speedup in runtime and makes hardware accelerator usage easier.
Example: Create the layer structure with pretrained weights:
In C:
In C, C++ and on Arduino:
Example: Create the layer structure for automatic parameter distribution:
In C:
In C, C++ and on Arduino:
Example: Initialize and connect the layer:
*layer | The layer structure to initialize. |
*input_layer | The prior layer. |