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, int(*print)(const char *format,...))
 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.0alpha

AIfES is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details.

You should have received a copy of the GNU 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

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:98
const aimath_dtype_t * dtype
The datatype of the tensor, e.g.
Definition: aifes_math.h:99

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:101

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, int(*print)(const char *format,...))
Printing a F32 scalar to console.

Function Documentation

◆ aimath_f32_print_aiscalar()

void aimath_f32_print_aiscalar ( const void *  scalar,
int(*)(const char *format,...)  print 
)

Printing a F32 scalar to console.

For users the function

is prefered.

Parameters
*scalarThe scalar (type: float) to print.
*printThe print function to use

◆ 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,