| AIfES 2 2.0.0

Typedefs | Functions
ailayer_softmax_default.h File Reference

Default implementation of the Softmax layer . More...

Go to the source code of this file.

## Typedefs
typedef struct ailayer_softmax | ailayer_softmax_f32_t
typedef struct ailayer_softmax | ailayer_softmax_q31_t
typedef struct ailayer_softmax | ailayer_softmax_q7_t

## Functions
ailayer_t * | ailayer_softmax_f32_default (ailayer_softmax_f32_t *layer, ailayer_t *input_layer)
| Initializes and connect an Softmax layer with the F32 default implementation. More...
ailayer_t * | ailayer_softmax_q31_default (ailayer_softmax_q31_t *layer, ailayer_t *input_layer)
| Initializes and connects an Softmax layer with the Q31 default implementation. More...
ailayer_t * | ailayer_softmax_q7_default (ailayer_softmax_q7_t *layer, ailayer_t *input_layer)
| Initializes and connects an Softmax layer with the Q7 default implementation. More...
void | ailayer_softmax_calc_result_tensor_params_q31_default (ailayer_t *self)
| Calculate and set the quantization parameters for the result tensor of the softmax Q31 default implementation. More...
void | ailayer_softmax_calc_result_tensor_params_q7_default (ailayer_t *self)
| Calculate and set the quantization parameters for the result tensor of the softmax Q7 default implementation. More...

## Detailed Description

Default implementation of the Softmax layer .

Version
  2.2.0

Copyright
  Copyright (C) 2020-2023 Fraunhofer Institute for Microelectronic Circuits and Systems. All rights reserved.
  AIfES is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
  You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Hardware independent implementations of the Softmax layer in F32 data-type. For more information about the Softmax layer refer to ailayer_softmax.h.

## Function Documentation

## ◆ ailayer_softmax_calc_result_tensor_params_q31_default()

void ailayer_softmax_calc_result_tensor_params_q31_default | ( | ailayer_t * | self | ) |

Calculate and set the quantization parameters for the result tensor of the softmax 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_softmax().

Parameters

  *self | The layer structure

## ◆ ailayer_softmax_calc_result_tensor_params_q7_default()

void ailayer_softmax_calc_result_tensor_params_q7_default | ( | ailayer_t * | self | ) |

Calculate and set the quantization parameters for the result tensor of the softmax 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_softmax().

Parameters

  *self | The layer structure

## ◆ ailayer_softmax_f32_default()

ailayer_t* ailayer_softmax_f32_default | ( | ailayer_softmax_f32_t * | layer,
|  | ailayer_t * | input_layer
| ) |  |

Initializes and connect an Softmax layer with the F32 default implementation.

Example: Create the layer structure:

ailayer_softmax_f32_t softmax_layer;
ailayer_softmax
General Softmax layer struct.
Definition: ailayer_softmax.h:51

or

ailayer_softmax_f32_t softmax_layer = AILAYER_SOFTMAX_F32_A();

Example: Initialize and connect the layer:

x = ailayer_softmax_f32_default(&softmax_layer, x);
ailayer_softmax_f32_default
ailayer_t * ailayer_softmax_f32_default(ailayer_softmax_f32_t *layer, ailayer_t *input_layer)
Initializes and connect an Softmax layer with the F32 default implementation.

Parameters

  *layer | The layer structure to initialize.
  *input_layer | The prior layer.

Returns
  The (successfully) initialized layer structure.

## ◆ ailayer_softmax_q31_default()

ailayer_t* ailayer_softmax_q31_default | ( | ailayer_softmax_q31_t * | layer,
|  | ailayer_t * | input_layer
| ) |  |

Initializes and connects an Softmax layer with the Q31 default implementation.

The quantization parameters of the result tensor are automatically set to {shift = 32, zero_point = -2^31} because the output values are in the interval (0, 1).

Example: Create the layer structure:

ailayer_softmax_q31_t softmax_layer;

or

ailayer_softmax_q31_t softmax_layer = AILAYER_SOFTMAX_Q31_M();

Example: Initialize and connect the layer:

x = ailayer_softmax_q31_default(&softmax_layer, x);
ailayer_softmax_q31_default
ailayer_t * ailayer_softmax_q31_default(ailayer_softmax_q31_t *layer, ailayer_t *input_layer)
Initializes and connects an Softmax layer with the Q31 default implementation.

Parameters

  *layer | The layer structure to initialize.
  *input_layer | The prior layer.

Returns
  The (successfully) initialized layer structure.

## ◆ ailayer_softmax_q7_default()

ailayer_t* ailayer_softmax_q7_default | ( | ailayer_softmax_q7_t * | layer,
|  | ailayer_t * | input_layer
| ) |  |

Initializes and connects an Softmax layer with the Q7 default implementation.

The quantization parameters of the result tensor are automatically set to {shift = 8, zero_point = -2^7} because the output values are in the interval (0, 1).

Example: Create the layer structure:

ailayer_softmax_q7_t softmax_layer;

or

ailayer_softmax_q7_t softmax_layer = AILAYER_SOFTMAX_Q7_M();

Example: Initialize and connect the layer:

x = ailayer_softmax_q7_default(&softmax_layer, x);
ailayer_softmax_q7_default
ailayer_t * ailayer_softmax_q7_default(ailayer_softmax_q7_t *layer, ailayer_t *input_layer)
Initializes and connects an Softmax layer with the Q7 default implementation.

Parameters

  *layer | The layer structure to initialize.
  *input_layer | The prior layer.

Returns
  The (successfully) initialized layer structure.