AIfES 2  2.0.0
aimath_basic.h File Reference

Basic data-type independent math operations. More...

Go to the source code of this file.

Functions

void print_aitensor (const aitensor_t *tensor)
 Printing a tensor to console. More...
 
void print_aiscalar (const void *scalar, const aimath_dtype_t *dtype)
 Printing a scalar to console. More...
 
void aimath_transpose_vector (aitensor_t *vector)
 Transposes a vector. More...
 
uint32_t aimath_tensor_elements (const aitensor_t *tensor)
 Calculates the number of elements in a tensor. More...
 
uint32_t aimath_sizeof_dtype (const aimath_dtype_t *dtype)
 Returns the size of one value in the given data type in bytes. More...
 
uint32_t aimath_sizeof_tensor_data (const aitensor_t *tensor)
 Returns size of the data array of the tensor in bytes. More...
 
uint32_t aimath_sizeof_tensor_params (const aitensor_t *tensor)
 Returns size of the aitensor.tensor_params for the data type of the tensor. More...
 
uint32_t aimath_sizeof_tensor (const aitensor_t *tensor)
 Returns size of tensor in bytes. More...
 

Detailed Description

Basic data-type independent math operations.

Version
2.2.0

Function Documentation

◆ aimath_sizeof_dtype()

uint32_t aimath_sizeof_dtype ( const aimath_dtype_t dtype)

Returns the size of one value in the given data type in bytes.

Parameters
*dtypeThe data type to get the size of
Returns
Size of one value in the given data type in bytes

◆ aimath_sizeof_tensor()

uint32_t aimath_sizeof_tensor ( const aitensor_t tensor)

Returns size of tensor in bytes.

The size is calculated by:

uint32_t aimath_sizeof_tensor_data(const aitensor_t *tensor)
Returns size of the data array of the tensor in bytes.
uint32_t aimath_sizeof_tensor_params(const aitensor_t *tensor)
Returns size of the aitensor.tensor_params for the data type of the tensor.
A tensor in AIfES.
Definition: aifes_math.h:89
Parameters
*tensorThe tensor to get the size of
Returns
Size of tensor in bytes

◆ aimath_sizeof_tensor_data()

uint32_t aimath_sizeof_tensor_data ( const aitensor_t tensor)

Returns size of the data array of the tensor in bytes.

The size is calculated by:

uint32_t aimath_sizeof_dtype(const aimath_dtype_t *dtype)
Returns the size of one value in the given data type in bytes.
uint32_t aimath_tensor_elements(const aitensor_t *tensor)
Calculates the number of elements in a tensor.
Parameters
*tensorThe tensor to get the data size of
Returns
Size of tensor data in bytes

◆ aimath_sizeof_tensor_params()

uint32_t aimath_sizeof_tensor_params ( const aitensor_t tensor)

Returns size of the aitensor.tensor_params for the data type of the tensor.

Parameters
*tensorThe tensor to get the parameters size of
Returns
Size of tensor parameters in bytes

◆ aimath_tensor_elements()

uint32_t aimath_tensor_elements ( const aitensor_t tensor)

Calculates the number of elements in a tensor.

Parameters
*tensorThe tensor to count the elements of
Returns
Number of elements in tensor

◆ aimath_transpose_vector()

void aimath_transpose_vector ( aitensor_t vector)

Transposes a vector.

\[ vector \leftarrow vector^T \]

Make sure that the given tensor is a vector (with shape [1 x N] or [N x 1])

Parameters
*vectorThe vector to transpose (2D tensor of shape [1 x N] or [N x 1])

◆ print_aiscalar()

void print_aiscalar ( const void *  scalar,
const aimath_dtype_t dtype 
)

Printing a scalar to console.

Calls the corresponding print function of the used aimath_dtype.

Example:

aiscalar_f32_t scalar = 42.0f;
void print_aiscalar(const void *scalar, const aimath_dtype_t *dtype)
Printing a scalar to console.
const aimath_dtype_t * aif32
The F32 data-type indicator.
float aiscalar_f32_t
Scalar for F32 (aif32) data-type.
Definition: aimath_f32.h:120
Parameters
*scalarThe scalar to print.
*dtypeThe data type of the scalar

◆ print_aitensor()

void print_aitensor ( const aitensor_t tensor)

Printing a tensor to console.

Calls the corresponding print function of the used aimath_dtype.

Example:

uint16_t tensor_shape[2] = {2, 3};
float tensor_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t tensor = AITENSOR_2D_F32(tensor_shape, tensor_data);
print_aitensor(&tensor);
void print_aitensor(const aitensor_t *tensor)
Printing a tensor to console.
Parameters
*tensorThe tensor to print.