AIfES 2  2.0.0
aimath_u8.h File Reference

Definition of the U8 (aiu8) data-type. More...

Go to the source code of this file.

Typedefs

typedef uint8_t aiscalar_u8_t
 

Functions

void aimath_u8_print_aitensor (const aitensor_t *tensor)
 Printing a U8 tensor to console. More...
 
void aimath_u8_print_aiscalar (const void *scalar)
 Printing a U8 scalar to console. More...
 

Variables

const aimath_dtype_taiu8
 The U8 data-type indicator. More...
 

Detailed Description

Definition of the U8 (aiu8) data-type.

Version
2.2.0

The U8 (aiu8) data-type stores data as 8 bit unsigned integer values. It does not require any additional parameter to define the values. This data-type is used for example for classification labels.

Example: Create a U8 tensor
The tensor

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

can be created with In C:

uint8_t example_data[] = {0, 1, 2,
3, 4, 5};
uint16_t example_shape[] = {2, 3};
aitensor_t example_tensor = {
.dtype = aiu8,
.dim = 2,
.shape = example_shape,
.data = example_data
};
const aimath_dtype_t * aiu8
The U8 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:

uint8_t example_data[] = {0, 1, 2,
3, 4, 5};
uint16_t example_shape[] = {2, 3};
aitensor_t example_tensor = AITENSOR_2D_U8(example_shape, example_data);

Example: Create a U8 scalar
Either create it as a normal uint8_t value

uint8_t scalar = 42;

or with the alias

aiscalar_u8_t scalar = 42;

Example: Print a U8 tensor to the console

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

Example: Print a U8 scalar to the console

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

Function Documentation

◆ aimath_u8_print_aiscalar()

void aimath_u8_print_aiscalar ( const void *  scalar)

Printing a U8 scalar to console.

For users the function

print_aiscalar(&scalar, aiu8);

is prefered.

Parameters
*scalarThe scalar (type: uint8_t) to print.

◆ aimath_u8_print_aitensor()

void aimath_u8_print_aitensor ( const aitensor_t tensor)

Printing a U8 tensor to console.

For users the function

print_aitensor(&tensor);

is prefered.

Parameters
*tensorThe tensor to print.

Variable Documentation

◆ aiu8

const aimath_dtype_t* aiu8
extern

The U8 data-type indicator.

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