AIfES 2  2.0.0
ailayer_leaky_relu_default.h File Reference

Default implementation of the Leaky ReLU layer . More...

Go to the source code of this file.

Data Structures

struct  ailayer_leaky_relu_f32
 Data-type specific Leaky ReLU layer struct for F32 . More...
 
struct  ailayer_leaky_relu_q31
 Data-type specific Leaky ReLU layer struct for Q31 . More...
 
struct  ailayer_leaky_relu_q7
 Data-type specific Leaky ReLU layer struct for Q7 . More...
 

Typedefs

typedef struct ailayer_leaky_relu_f32 ailayer_leaky_relu_f32_t
 
typedef struct ailayer_leaky_relu_q31 ailayer_leaky_relu_q31_t
 
typedef struct ailayer_leaky_relu_q7 ailayer_leaky_relu_q7_t
 

Functions

ailayer_tailayer_leaky_relu_f32_default (ailayer_leaky_relu_f32_t *layer, ailayer_t *input_layer)
 Initializes and connect a Leaky ReLU layer with the F32 default implementation. More...
 
ailayer_tailayer_leaky_relu_q31_default (ailayer_leaky_relu_q31_t *layer, ailayer_t *input_layer)
 Initializes and connect a Leaky ReLU layer with the Q31 default implementation. More...
 
ailayer_tailayer_leaky_relu_q7_default (ailayer_leaky_relu_q7_t *layer, ailayer_t *input_layer)
 Initializes and connect a Leaky ReLU layer with the Q7 default implementation. More...
 
void ailayer_leaky_relu_calc_result_tensor_params_q31_default (ailayer_t *self)
 Calculate and set the quantization parameters for the result tensor of the Leaky ReLU Q31 default implementation. More...
 
void ailayer_leaky_relu_calc_result_tensor_params_q7_default (ailayer_t *self)
 Calculate and set the quantization parameters for the result tensor of the Leaky ReLU Q7 default implementation. More...
 

Detailed Description

Default implementation of the Leaky ReLU layer .

Version
2.2.0

Hardware independent implementations of the Leaky ReLU layer in F32 data-type. For more information about the Leaky ReLU layer refer to ailayer_leaky_relu.h.

Function Documentation

◆ ailayer_leaky_relu_calc_result_tensor_params_q31_default()

void ailayer_leaky_relu_calc_result_tensor_params_q31_default ( ailayer_t self)

Calculate and set the quantization parameters for the result tensor of the Leaky ReLU Q31 default implementation.

Implementation of ailayer.calc_result_tensor_params.

The quantization parameters are pre-defined and the same as in the corresponding math function aimath_q31_default_leaky_relu().

Parameters
*selfThe layer structure

◆ ailayer_leaky_relu_calc_result_tensor_params_q7_default()

void ailayer_leaky_relu_calc_result_tensor_params_q7_default ( ailayer_t self)

Calculate and set the quantization parameters for the result tensor of the Leaky ReLU Q7 default implementation.

Implementation of ailayer.calc_result_tensor_params.

The quantization parameters are pre-defined and the same as in the corresponding math function aimath_q7_default_leaky_relu().

Parameters
*selfThe layer structure

◆ ailayer_leaky_relu_f32_default()

ailayer_t* ailayer_leaky_relu_f32_default ( ailayer_leaky_relu_f32_t layer,
ailayer_t input_layer 
)

Initializes and connect a Leaky ReLU layer with the F32 default implementation.

Example: Create the layer structure:
In C:

ailayer_leaky_relu_f32_t leaky_relu_layer = {
.alpha = 0.01f
};
Data-type specific Leaky ReLU layer struct for F32 .
Definition: ailayer_leaky_relu_default.h:51
aiscalar_f32_t alpha
Data type-specific parameter used to calculate Leaky ReLU function for input values < 0.
Definition: ailayer_leaky_relu_default.h:53

In C, C++ and on Arduino:

ailayer_leaky_relu_f32_t leaky_relu_layer = AILAYER_LEAKY_RELU_F32_A(0.01f);

Example: Initialize and connect the layer:

x = ailayer_leaky_relu_f32_default(&leaky_relu_layer, x);
ailayer_t * ailayer_leaky_relu_f32_default(ailayer_leaky_relu_f32_t *layer, ailayer_t *input_layer)
Initializes and connect a Leaky ReLU layer with the F32 default implementation.
Parameters
*layerthe layer structure to be initialized
*input_layerthe prior layer that provides the input to this Leaky ReLU layer
Returns
the initialized Leaky ReLU layer structure

◆ ailayer_leaky_relu_q31_default()

ailayer_t* ailayer_leaky_relu_q31_default ( ailayer_leaky_relu_q31_t layer,
ailayer_t input_layer 
)

Initializes and connect a Leaky ReLU layer with the Q31 default implementation.

The quantization parameters of the result tensor are automatically set to {shift = input_layer.result.shift, zero_point = input_layer.result.zero_point} because the output values are in the interval (alpha * min(input_layer.result), max(input_layer.result)].

Example: Create the layer structure:
In C:

ailayer_leaky_relu_q31_t leaky_relu_layer = {
.alpha = AISCALAR_Q31(0.01f, 25, 0)
};
Data-type specific Leaky ReLU layer struct for Q31 .
Definition: ailayer_leaky_relu_default.h:60
aiscalar_q31_t alpha
Data type-specific parameter used to calculate Leaky ReLU function for input values < 0.
Definition: ailayer_leaky_relu_default.h:62

In C, C++ and on Arduino:

ailayer_leaky_relu_q31_t leaky_relu_layer = AILAYER_LEAKY_RELU_Q31_M(AISCALAR_Q31(0.01f, 25, 0));

Example: Initialize and connect the layer:

x = ailayer_leaky_relu_q31_default(&leaky_relu_layer, x);
ailayer_t * ailayer_leaky_relu_q31_default(ailayer_leaky_relu_q31_t *layer, ailayer_t *input_layer)
Initializes and connect a Leaky ReLU layer with the Q31 default implementation.
Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.

◆ ailayer_leaky_relu_q7_default()

ailayer_t* ailayer_leaky_relu_q7_default ( ailayer_leaky_relu_q7_t layer,
ailayer_t input_layer 
)

Initializes and connect a Leaky ReLU layer with the Q7 default implementation.

The quantization parameters of the result tensor are automatically set to {shift = input_layer.result.shift, zero_point = input_layer.result.zero_point} because the output values are in the interval (alpha * min(input_layer.result), max(input_layer.result)].

Example: Create the layer structure of a pre-trained model (qparams must be set manually):
In C:

ailayer_leaky_relu_q7_t leaky_relu_layer = {
.alpha = AISCALAR_Q7(0.01f, 7, 0)
};
Data-type specific Leaky ReLU layer struct for Q7 .
Definition: ailayer_leaky_relu_default.h:69
aiscalar_q7_t alpha
Data type-specific parameter used to calculate Leaky ReLU function for input values < 0.
Definition: ailayer_leaky_relu_default.h:71

In C, C++ and on Arduino:

ailayer_leaky_relu_q7_t leaky_relu_layer = AILAYER_LEAKY_RELU_Q7_M(AISCALAR_Q7(0.01f, 7, 0));

Example: Initialize and connect the layer:

x = ailayer_leaky_relu_q7_default(&leaky_relu_layer, x);
ailayer_t * ailayer_leaky_relu_q7_default(ailayer_leaky_relu_q7_t *layer, ailayer_t *input_layer)
Initializes and connect a Leaky ReLU layer with the Q7 default implementation.
Parameters
*layerThe layer structure to initialize.
*input_layerThe prior layer.
Returns
The (successfully) initialized layer structure.