AIfES 2  2.0.0
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_taif32
 The F32 data-type indicator. More...
 

Detailed Description

Definition of the F32 (aif32) data-type.

Version
2.2.0

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 = {
.dim = 2,
.shape = example_shape,
.data = example_data
};
const aimath_dtype_t * aif32
The F32 data-type indicator.
A tensor in AIfES.
Definition: aifes_math.h:89
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;
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);
void print_aitensor(const aitensor_t *tensor)
Printing a tensor to console.

Example: Print a F32 scalar to the console

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

or by using

aimath_f32_print_aiscalar(&scalar, printf);
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

is prefered.

Parameters
*scalarThe 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
*tensorThe 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,