| AIfES 2 2.0.0

Typedefs | Functions | Variables
aimath_f32.h File Reference

Definition of the F32 (aif32) data-type. More...

Go to the source code of this file.

## Typedefs
typedef float | aiscalar_f32_t
| Scalar for F32 (aif32) data-type. More...

## Functions
void | aimath_f32_print_aitensor (const aitensor_t *tensor)
| Printing a F32 tensor to console. More...
void | aimath_f32_print_aiscalar (const void *scalar)
| Printing a F32 scalar to console. More...

## Variables
const aimath_dtype_t * | aif32
| The F32 data-type indicator. More...

## Detailed Description

Definition of the F32 (aif32) data-type.

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/.

The F32 (aif32) data-type stores data as 32 bit single precision floating point values. It does not require any additional parameter to define the values.

Example: Create a F32 tensor
The tensor

\[ \left( \begin{array}{rrr} 0 & 1 & 2 \\ 3 & 4 & 5 \end{array}\right) \]

can be created with In C:

float example_data[] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
uint16_t example_shape[] = {2, 3};
aitensor_t example_tensor = {
.dtype = aif32,
.dim = 2,
.shape = example_shape,
.data = example_data
};
aif32
const aimath_dtype_t * aif32
The F32 data-type indicator.
aitensor
A tensor in AIfES.
Definition: aifes_math.h:89
aitensor::dtype
const aimath_dtype_t * dtype
The datatype of the tensor, e.g.
Definition: aifes_math.h:90

In C, C++ and on Arduino:

float example_data[] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
uint16_t example_shape[] = {2, 3};
aitensor_t example_tensor = AITENSOR_2D_F32(example_shape, example_data);

Example: Create a F32 scalar
Either create it as a normal float value

float scalar = 42.0f;

or with the alias

aiscalar_f32_t scalar = 42.0f;
aiscalar_f32_t
float aiscalar_f32_t
Scalar for F32 (aif32) data-type.
Definition: aimath_f32.h:120

Example: Print a F32 tensor to the console

print_aitensor(&example_tensor);
print_aitensor
void print_aitensor(const aitensor_t *tensor)
Printing a tensor to console.

Example: Print a F32 scalar to the console

print_aiscalar(&scalar, aif32);
print_aiscalar
void print_aiscalar(const void *scalar, const aimath_dtype_t *dtype)
Printing a scalar to console.

## Typedef Documentation

## ◆ aiscalar_f32_t

typedef float aiscalar_f32_t

Scalar for F32 (aif32) data-type.

This is only an alias for a float value for consistency.
You can create a F32 scalar either as a normal float value

float scalar = 42.0f;

or with the alias

aiscalar_f32_t scalar = 42.0f;

You can print the scalar to the console with

print_aiscalar(&scalar, aif32);

or by using

aimath_f32_print_aiscalar(&scalar, printf);
aimath_f32_print_aiscalar
void aimath_f32_print_aiscalar(const void *scalar)
Printing a F32 scalar to console.

## Function Documentation

## ◆ aimath_f32_print_aiscalar()

void aimath_f32_print_aiscalar | ( | const void * | scalar | ) |

Printing a F32 scalar to console.

For users the function

print_aiscalar(&scalar, aif32);

is prefered.

Parameters

  *scalar | The scalar (type: float) to print.

## ◆ aimath_f32_print_aitensor()

void aimath_f32_print_aitensor | ( | const aitensor_t * | tensor | ) |

Printing a F32 tensor to console.

For users the function

print_aitensor(&tensor);

is prefered.

Parameters

  *tensor | The tensor to print.

## Variable Documentation

## ◆ aif32

const aimath_dtype_t* aif32
| extern

The F32 data-type indicator.

Use this variable to configure some element with the F32 data-type,