AIfES 2  2.0.0
aimath_f32_default.h File Reference

Math functions for F32 data type, default implementation. More...

Go to the source code of this file.

Functions

void aimath_f32_default_linear (const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result)
 Performs a matrix multiplication of F32 matrices a and b and adds a vector c to each row. More...
 
void aimath_f32_default_mat_mul (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Performs a matrix multiplication of F32 matrices a and b. More...
 
void aimath_f32_default_multiply (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Performs an element wise multiplication of F32 tensors a and b (Hadamard product) More...
 
void aimath_f32_default_divide (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Performs an element wise division of F32 tensors a and b (Hadamard division) More...
 
void aimath_f32_default_scalar_mul (const void *scalar, const aitensor_t *a, aitensor_t *result)
 Performs a scalar multiplication (scaling) of F32 tensor a and a scalar. More...
 
void aimath_f32_default_scalar_add (const void *scalar, const aitensor_t *a, aitensor_t *result)
 Performs an element wise addition of a scalar to a F32 tensor. More...
 
void aimath_f32_default_tensor_add (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Performs an element wise addition of F32 tensors a and b. More...
 
void aimath_f32_default_tensor_sub (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Performs a element wise subtraction of F32 tensors a and b. More...
 
void aimath_f32_default_tensor_sub_sparse8 (const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
 Performs a subtraction between a F32 matrix a and a U8 sparse matrix b. More...
 
void aimath_f32_default_copy_tensor (const aitensor_t *from, aitensor_t *to)
 Performs an element wise copy of F32 tensors. More...
 
void aimath_f32_default_transpose_vector (aitensor_t *vector)
 Transposes a F32 vector. More...
 
void aimath_f32_default_norm_squared (const aitensor_t *x, void *result)
 Calculates the squared sum of all elements in a F32 tensor. More...
 
void aimath_f32_default_sum (const aitensor_t *x, void *result)
 Calculates the sum of all elements in a F32 tensor. More...
 
void aimath_f32_default_min (const aitensor_t *x, void *result)
 Identifies the minimum value in a F32 tensor. More...
 
void aimath_f32_default_max (const aitensor_t *x, void *result)
 Identifies the maximum value in a F32 tensor. More...
 
void aimath_f32_default_sigmoid (const aitensor_t *x, aitensor_t *result)
 Calculates the sigmoid of each element in a F32 tensor. More...
 
void aimath_f32_default_d_sigmoid (const aitensor_t *sigmoid_x, aitensor_t *result)
 Calculates the derivative sigmoid of each element in a F32 tensor. More...
 
void aimath_f32_default_tanh (const aitensor_t *x, aitensor_t *result)
 Calculates the tanh of each element in a F32 tensor. More...
 
void aimath_f32_default_d_tanh (const aitensor_t *tanh_x, aitensor_t *result)
 Calculates the tanh derivative of each element in a F32 tensor. More...
 
void aimath_f32_default_relu (const aitensor_t *x, aitensor_t *result)
 Calculates the rectifier (ReLU) value of each element in a F32 tensor. More...
 
void aimath_f32_default_d_relu (const aitensor_t *x, aitensor_t *result)
 Calculates the rectifier (ReLU) derivative of each element in a F32 tensor. More...
 
void aimath_f32_default_leaky_relu (const aitensor_t *x, const void *alpha, aitensor_t *result)
 Calculates the leaky rectifier (leaky ReLU) value of each element in a F32 tensor. More...
 
void aimath_f32_default_d_leaky_relu (const aitensor_t *x, const void *alpha, aitensor_t *result)
 Calculates the leaky rectifier (leaky ReLU) derivative of each element in a F32 tensor. More...
 
void aimath_f32_default_elu (const aitensor_t *x, const void *alpha, aitensor_t *result)
 Calculates the exponential rectifier (ELU) value of each element in a F32 tensor. More...
 
void aimath_f32_default_d_elu (const aitensor_t *x, const void *alpha, aitensor_t *result)
 Calculates the exponential rectifier (ELU) derivative of each element in a F32 tensor. More...
 
void aimath_f32_default_softmax (const aitensor_t *x, aitensor_t *result)
 Calculates the softmax value of each row of a F32 matrix. More...
 
void aimath_f32_default_softsign (const aitensor_t *x, aitensor_t *result)
 Calculates the softsign value of each element in a F32 tensor. More...
 
void aimath_f32_default_d_softsign (const aitensor_t *x, aitensor_t *result)
 Calculates the softsign derivative of each element in a F32 tensor. More...
 
void aimath_f32_default_binary_crossentropy (const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
 Calculates the binary cross entropy between the F32 predicted and the target data. More...
 
void aimath_f32_default_categorical_crossentropy (const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
 Calculates the categorical cross entropy between the F32 predicted and the target data. More...
 
void aimath_f32_default_categorical_crossentropy_sparse8 (const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
 Calculates the categorical Cross-Entropy between the F32 predicted data and the U8 target data in sparse representation. More...
 
void aimath_f32_default_sqrt (const aitensor_t *x, aitensor_t *result)
 Calculates the element wise square root of a F32 tensor. More...
 
void aimath_f32_default_zero_tensor (aitensor_t *tensor)
 Fills a F32 tensor with zeros. More...
 
void aimath_f32_default_init_zeros (aitensor_t *tensor)
 Fills a F32 tensor with zeros. More...
 
void aimath_f32_default_tensor_init_uniform (aitensor_t *tensor, float from, float to)
 Fills a F32 tensor with random numbers created from a uniform distribution within given range. More...
 
void aimath_f32_default_init_glorot_uniform (aitensor_t *tensor)
 Fills a F32 tensor with random numbers uniformly within given range, according to Glorot et al. More...
 
void aimath_f32_default_init_he_uniform (aitensor_t *tensor)
 Fills a F32 tensor with uniformly drawn random numbers within given range, according to He et al. More...
 
float aimath_f32_default_expf_fast (const float x)
 Fast approximation of the exponential function. More...
 

Detailed Description

Math functions for F32 data type, default implementation.

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

These functions can be used when no hardware specific implementation is available.

Function Documentation

◆ aimath_f32_default_binary_crossentropy()

void aimath_f32_default_binary_crossentropy ( const aitensor_t predicted_data,
const aitensor_t target_data,
void *  result 
)

Calculates the binary cross entropy between the F32 predicted and the target data.

\[ result = - \sum_i (target_i \cdot \log(predicted_i) + (1 - target_i) \cdot \log(1 - predicted_i)) \]

Example:

uint16_t p_shape[2] = {2, 3};
float p_data[2*3] = {0.8f, 0.1f, 0.7f,
0.2f, 0.3f, 0.0f};
aitensor_t p = AITENSOR_2D_F32(p_shape, p_data);
uint16_t t_shape[2] = {2, 3};
float t_data[2*3] = {1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f};
aitensor_t t = AITENSOR_2D_F32(t_shape, t_data);
float result;
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.
void aimath_f32_default_binary_crossentropy(const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
Calculates the binary cross entropy between the F32 predicted and the target data.
A tensor in AIfES.
Definition: aifes_math.h:98
Parameters
*predicted_dataF32 matrix with the predicted or calculated values (2D tensor)
*target_dataF32 matrix with the target data / true values / labels (2D tensor with binary values 0 or 1)
*resultResulting F32 matrix (2D tensor)

◆ aimath_f32_default_categorical_crossentropy()

void aimath_f32_default_categorical_crossentropy ( const aitensor_t predicted_data,
const aitensor_t target_data,
void *  result 
)

Calculates the categorical cross entropy between the F32 predicted and the target data.

\[ result = - \sum_i target_i \cdot \log(predicted_i) \]

Example:

uint16_t p_shape[2] = {2, 3};
float p_data[2*3] = {0.2f, 0.1f, 0.7f,
0.9f, 0.1f, 0.0f};
aitensor_t p = AITENSOR_2D_F32(p_shape, p_data);
uint16_t t_shape[2] = {2, 3};
float t_data[2*3] = {0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f};
aitensor_t t = AITENSOR_2D_F32(t_shape, t_data);
float result;
void aimath_f32_default_categorical_crossentropy(const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
Calculates the categorical cross entropy between the F32 predicted and the target data.
Parameters
*predicted_dataF32 matrix with the predicted or calculated values (2D tensor)
*target_dataF32 matrix with the target data / true values / labels (2D tensor, rows one-hot encoded)
*resultResulting F32 matrix (2D tensor)

◆ aimath_f32_default_categorical_crossentropy_sparse8()

void aimath_f32_default_categorical_crossentropy_sparse8 ( const aitensor_t predicted_data,
const aitensor_t target_data,
void *  result 
)

Calculates the categorical Cross-Entropy between the F32 predicted data and the U8 target data in sparse representation.

This function can calculate the crossentropy between a row wise one-hot encoded matrix in sparse representation (just the integer index of the 1 is stored) and a normal F32 matrix a.

For example the matrix

\[ \left( \begin{array}{ccc} 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{array}\right) \]

in sparse representation is

\[ \left( \begin{array}{ccc} 3 \\ 0 \\ 2 \end{array}\right) \]

The result is then calculated from the one-hot encoded target matrix:

\[ result = - \sum_i target_{one-hot,i} \cdot \log(predicted_i) \]

Example:

uint16_t p_shape[2] = {2, 3};
float p_data[2*3] = {0.2f, 0.1f, 0.7f,
0.9f, 0.1f, 0.0f};
aitensor_t p = AITENSOR_2D_F32(p_shape, p_data);
uint16_t t_shape[2] = {2, 1};
uint8_t t_data[2*1] = {2,
0};
aitensor_t t = AITENSOR_2D_U8(t_shape, t_data);
float result;
void aimath_f32_default_categorical_crossentropy_sparse8(const aitensor_t *predicted_data, const aitensor_t *target_data, void *result)
Calculates the categorical Cross-Entropy between the F32 predicted data and the U8 target data in s...
Parameters
*predicted_dataF32 matrix with the predicted or calculated values (2D tensor of shape [N x M])
*target_dataU8 matrix with the target data / true values / labels (2D tensor of shape [N x 1] with true class indices)
*resultResulting F32 matrix (2D tensor of shape [N x M])

◆ aimath_f32_default_copy_tensor()

void aimath_f32_default_copy_tensor ( const aitensor_t from,
aitensor_t to 
)

Performs an element wise copy of F32 tensors.

\[ to \leftarrow from \]

Dimension and shape of from and to tensors have to be the same.

Example:

uint16_t from_shape[2] = {2, 3};
float from_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t from = AITENSOR_2D_F32(from_shape, from_data);
uint16_t to_shape[2] = {2, 3};
float to_data[2*3];
aitensor_t to = AITENSOR_2D_F32(to_shape, to_data);
void print_aitensor(const aitensor_t *tensor)
Printing a tensor to console.
void aimath_f32_default_copy_tensor(const aitensor_t *from, aitensor_t *to)
Performs an element wise copy of F32 tensors.
Parameters
*fromF32 tensor to copy from (N-D tensor)
*toF32 tensor to copy to (N-D tensor)

◆ aimath_f32_default_d_elu()

void aimath_f32_default_d_elu ( const aitensor_t x,
const void *  alpha,
aitensor_t result 
)

Calculates the exponential rectifier (ELU) derivative of each element in a F32 tensor.

\[ result_{i} = \begin{cases} \alpha \cdot e^{x_i} & \text{if } x_i < 0\\ 1 & \text{if } x_i \geq 0 \end{cases} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float alpha = 1.0f;
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_d_elu(&x, &alpha, &result);
print_aitensor(&result);
void aimath_f32_default_d_elu(const aitensor_t *x, const void *alpha, aitensor_t *result)
Calculates the exponential rectifier (ELU) derivative of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the ELU derivative from (N-D tensor)
*alphaScalar \( \alpha \) (type aiscalar_f32_t / float)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_d_leaky_relu()

void aimath_f32_default_d_leaky_relu ( const aitensor_t x,
const void *  alpha,
aitensor_t result 
)

Calculates the leaky rectifier (leaky ReLU) derivative of each element in a F32 tensor.

\[ result_{i} = \begin{cases} \alpha & \text{if } x_i < 0\\ 1 & \text{if } x_i \geq 0 \end{cases} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float alpha = 0.01f;
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_d_leaky_relu(&x, &alpha, &result);
print_aitensor(&result);
void aimath_f32_default_d_leaky_relu(const aitensor_t *x, const void *alpha, aitensor_t *result)
Calculates the leaky rectifier (leaky ReLU) derivative of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the leaky ReLU derivative from (N-D tensor)
*alphaScalar \( \alpha \) (type aiscalar_f32_t / float) for the leakage
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_d_relu()

void aimath_f32_default_d_relu ( const aitensor_t x,
aitensor_t result 
)

Calculates the rectifier (ReLU) derivative of each element in a F32 tensor.

\[ result_{ij} = \begin{cases} 0 & \text{if } x_i < 0\\ 1 & \text{if } x_i \geq 0 \end{cases} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_d_relu(const aitensor_t *x, aitensor_t *result)
Calculates the rectifier (ReLU) derivative of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the ReLU derivative from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_d_sigmoid()

void aimath_f32_default_d_sigmoid ( const aitensor_t sigmoid_x,
aitensor_t result 
)

Calculates the derivative sigmoid of each element in a F32 tensor.

\[ result_{i} = \sigma'(x_{i}) = \sigma(x_{i}) \cdot (1 - \sigma(x_{i})) \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_d_sigmoid(&result, &result);
print_aitensor(&result);
void aimath_f32_default_d_sigmoid(const aitensor_t *sigmoid_x, aitensor_t *result)
Calculates the derivative sigmoid of each element in a F32 tensor.
void aimath_f32_default_sigmoid(const aitensor_t *x, aitensor_t *result)
Calculates the sigmoid of each element in a F32 tensor.
Parameters
*sigmoid_xF32 tensor with the sigmoid values \( \sigma(x_{i}) \) (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_d_softsign()

void aimath_f32_default_d_softsign ( const aitensor_t x,
aitensor_t result 
)

Calculates the softsign derivative of each element in a F32 tensor.

\[ result_{i} = \frac {x_i} {(1 + |x_i|)^2} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_d_softsign(const aitensor_t *x, aitensor_t *result)
Calculates the softsign derivative of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the softsign derivative from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_d_tanh()

void aimath_f32_default_d_tanh ( const aitensor_t tanh_x,
aitensor_t result 
)

Calculates the tanh derivative of each element in a F32 tensor.

\[ result_{i} = tanh'(x_{i}) = 1 - tanh(x_{i})^2 \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_d_tanh(&result, &result);
print_aitensor(&result);
void aimath_f32_default_d_tanh(const aitensor_t *tanh_x, aitensor_t *result)
Calculates the tanh derivative of each element in a F32 tensor.
void aimath_f32_default_tanh(const aitensor_t *x, aitensor_t *result)
Calculates the tanh of each element in a F32 tensor.
Parameters
*tanh_xF32 tensor with the tanh values \( \tanh(x_{i}) \) (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_divide()

void aimath_f32_default_divide ( const aitensor_t a,
const aitensor_t b,
aitensor_t result 
)

Performs an element wise division of F32 tensors a and b (Hadamard division)

\[ result = a \oslash b \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {2, 3};
float b_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t b = AITENSOR_2D_F32(b_shape, b_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_divide(&a, &b, &result);
print_aitensor(&result);
void aimath_f32_default_divide(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Performs an element wise division of F32 tensors a and b (Hadamard division)
Parameters
*aF32 tensor a (N-D tensor)
*bF32 tensor b (N-D tensor)
*resultResulting F32 tensor of the element wise division (N-D tensor)

◆ aimath_f32_default_elu()

void aimath_f32_default_elu ( const aitensor_t x,
const void *  alpha,
aitensor_t result 
)

Calculates the exponential rectifier (ELU) value of each element in a F32 tensor.

\[ result_{i} = \begin{cases} \alpha \cdot (e^{x_i} - 1) & \text{if } x_i < 0 \\ x_i & \text{if } x_i \geq 0 \end{cases} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float alpha = 1.0f;
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_elu(&x, &alpha, &result);
print_aitensor(&result);
void aimath_f32_default_elu(const aitensor_t *x, const void *alpha, aitensor_t *result)
Calculates the exponential rectifier (ELU) value of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the ELU from (N-D tensor)
*alphaScalar \( \alpha \) (type aiscalar_f32_t / float)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_expf_fast()

float aimath_f32_default_expf_fast ( const float  x)

Fast approximation of the exponential function.

See also
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.9.4508&rep=rep1&type=pdf
Parameters
xInput of the exponential function

◆ aimath_f32_default_init_glorot_uniform()

void aimath_f32_default_init_glorot_uniform ( aitensor_t tensor)

Fills a F32 tensor with random numbers uniformly within given range, according to Glorot et al.

\[ fan_{avg} = \frac{fan_{in} + fan_{out}}{2} \]

\[ r = \sqrt{\frac{3}{fan_{avg}}} \]

\[ tensor_i \in \mathcal{U(-r, r)} \]

Example:

uint16_t tensor_shape[2] = {2, 3};
float tensor_data[2*3];
aitensor_t tensor = AITENSOR_2D_F32(tensor_shape, tensor_data);
print_aitensor(&tensor);
void aimath_f32_default_init_glorot_uniform(aitensor_t *tensor)
Fills a F32 tensor with random numbers uniformly within given range, according to Glorot et al.
See also
Glorot et al., 2010 ( http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf )
Parameters
*tensorF32 tensor to initialize with random numbers (N-D tensor)

◆ aimath_f32_default_init_he_uniform()

void aimath_f32_default_init_he_uniform ( aitensor_t tensor)

Fills a F32 tensor with uniformly drawn random numbers within given range, according to He et al.

\[ fan_{avg} = \frac{fan_{in}}{2} \]

\[ r = \sqrt{\frac{3}{fan_{avg}}} \]

\[ tensor_i \in \mathcal{U(-r, r)} \]

Example:

uint16_t tensor_shape[2] = {2, 3};
float tensor_data[2*3];
aitensor_t tensor = AITENSOR_2D_F32(tensor_shape, tensor_data);
print_aitensor(&tensor);
void aimath_f32_default_init_he_uniform(aitensor_t *tensor)
Fills a F32 tensor with uniformly drawn random numbers within given range, according to He et al.
See also
He et al., 2015 ( https://www.cv-foundation.org/openaccess/content_iccv_2015/html/He_Delving_Deep_into_ICCV_2015_paper.html )
Parameters
*tensorF32 tensor to initialize with random numbers (N-D tensor)

◆ aimath_f32_default_init_zeros()

void aimath_f32_default_init_zeros ( aitensor_t tensor)

Fills a F32 tensor with zeros.

\[ tensor_{i} = 0 \]

Example:

uint16_t tensor_shape[2] = {2, 3};
float tensor_data[2*3];
aitensor_t tensor = AITENSOR_2D_F32(tensor_shape, tensor_data);
print_aitensor(&tensor);
void aimath_f32_default_init_zeros(aitensor_t *tensor)
Fills a F32 tensor with zeros.

In the F32 implementation of this function, there is no difference between aimath_f32_default_zero_tensor() and aimath_f32_default_init_zeros().

Parameters
*tensorF32 tensor to set to zero (N-D tensor)

◆ aimath_f32_default_leaky_relu()

void aimath_f32_default_leaky_relu ( const aitensor_t x,
const void *  alpha,
aitensor_t result 
)

Calculates the leaky rectifier (leaky ReLU) value of each element in a F32 tensor.

\[ result_{i} = \begin{cases} \alpha \cdot x_i & \text{if } x_i < 0 \\ x_i & \text{if } x_i \geq 0 \end{cases} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float alpha = 0.01f;
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_leaky_relu(&x, &alpha, &result);
print_aitensor(&result);
void aimath_f32_default_leaky_relu(const aitensor_t *x, const void *alpha, aitensor_t *result)
Calculates the leaky rectifier (leaky ReLU) value of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the leaky ReLU from (N-D tensor)
*alphaScalar \( \alpha \) (type aiscalar_f32_t / float) for the leakage
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_linear()

void aimath_f32_default_linear ( const aitensor_t a,
const aitensor_t b,
const aitensor_t c,
aitensor_t result 
)

Performs a matrix multiplication of F32 matrices a and b and adds a vector c to each row.

The addition of the horizontal vector c is performed via broadcast, i.e. element wise in each column Mathematically this broadcast is equal to multiplying c with an vertical vector (with the same number of elements as c) and adding the result to a * b

\[ result = a \cdot b + \left( \begin{array}{c} 1 \\ 1 \\ \vdots \\ 1 \\ \end{array}\right) \cdot c \]

Example:

\[ a = \left( \begin{array}{rrr} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array}\right) \]

\[ b = \left( \begin{array}{rr} 1 & 0 \\ 0 & 1 \\ 0 & 0 \end{array}\right) \]

\[ c = \left( \begin{array}{rr} 2 & 5 \end{array}\right) \]

\[ result = a \cdot b + \left( \begin{array}{r} 1 \\ 1 \\ 1 \\ \end{array}\right) \cdot c \]

\[ = \left( \begin{array}{rr} 1 & 2 \\ 4 & 5 \\ 7 & 8 \end{array}\right) + \left( \begin{array}{rr} 2 & 5 \\ 2 & 5 \\ 2 & 5 \end{array}\right) \]

\[ = \left( \begin{array}{rr} 3 & 7 \\ 6 & 10 \\ 9 & 13 \end{array}\right) \]

Example:

uint16_t a_shape[2] = {3, 3};
float a_data[3*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f,
7.0f, 8.0f, 9.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {3, 2};
float b_data[3*2] = {1.0f, 0.0f,
0.0f, 1.0f,
0.0f, 0.0f};
aitensor_t b = AITENSOR_2D_F32(b_shape, b_data);
uint16_t c_shape[2] = {1, 2};
float c_data[1*2] = {2.0f, 5.0f};
aitensor_t c = AITENSOR_2D_F32(c_shape, c_data);
uint16_t result_shape[2] = {3, 2};
float result_data[3*2];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_linear(&a, &b, &c, &result);
print_aitensor(&result);
void aimath_f32_default_linear(const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result)
Performs a matrix multiplication of F32 matrices a and b and adds a vector c to each row.
Parameters
*aQ31 matrix a (2D tensor of shape [N x K])
*bQ31 matrix b (2D tensor of shape [K x M])
*cQ31 vector c (2D tensor of shape [1 x M])
*resultResulting Q31 matrix (2D tensor of shape [N x M])

◆ aimath_f32_default_mat_mul()

void aimath_f32_default_mat_mul ( const aitensor_t a,
const aitensor_t b,
aitensor_t result 
)

Performs a matrix multiplication of F32 matrices a and b.

\[ result = a \cdot b \]

Example:

uint16_t a_shape[2] = {3, 3};
float a_data[3*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f,
7.0f, 8.0f, 9.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {3, 2};
float b_data[3*2] = {1.0f, 0.0f,
0.0f, 1.0f,
0.0f, 0.0f};
aitensor_t b = AITENSOR_2D_F32(b_shape, b_data);
uint16_t result_shape[2] = {3, 2};
float result_data[3*2];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_mat_mul(&a, &b, &result);
print_aitensor(&result);
void aimath_f32_default_mat_mul(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Performs a matrix multiplication of F32 matrices a and b.
Parameters
*aF32 matrix a (2D tensor of shape [N x K])
*bF32 matrix b (2D tensor of shape [K x M])
*resultResulting F32 matrix of the multiplication (2D tensor of shape [N x M])

◆ aimath_f32_default_max()

void aimath_f32_default_max ( const aitensor_t x,
void *  result 
)

Identifies the maximum value in a F32 tensor.

\[ result = max(x) \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float result;
void aimath_f32_default_max(const aitensor_t *x, void *result)
Identifies the maximum value in a F32 tensor.
Parameters
*xF32 tensor x to get the maximum value of (N-D tensor)
*resultScalar result (type aiscalar_f32_t / float)

◆ aimath_f32_default_min()

void aimath_f32_default_min ( const aitensor_t x,
void *  result 
)

Identifies the minimum value in a F32 tensor.

\[ result = min(x) \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float result;
void aimath_f32_default_min(const aitensor_t *x, void *result)
Identifies the minimum value in a F32 tensor.
Parameters
*xF32 tensor x to get the minimum value of (N-D tensor)
*resultScalar result (type aiscalar_f32_t / float)

◆ aimath_f32_default_multiply()

void aimath_f32_default_multiply ( const aitensor_t a,
const aitensor_t b,
aitensor_t result 
)

Performs an element wise multiplication of F32 tensors a and b (Hadamard product)

\[ result = a \circ b \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {2, 3};
float b_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t b = AITENSOR_2D_F32(b_shape, b_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_multiply(&a, &b, &result);
print_aitensor(&result);
void aimath_f32_default_multiply(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Performs an element wise multiplication of F32 tensors a and b (Hadamard product)
Parameters
*aF32 tensor a (N-D tensor)
*bF32 tensor b (N-D tensor)
*resultResulting F32 tensor of the element wise multiplication (N-D tensor)

◆ aimath_f32_default_norm_squared()

void aimath_f32_default_norm_squared ( const aitensor_t x,
void *  result 
)

Calculates the squared sum of all elements in a F32 tensor.

\[ result = \sum_i x_{i}^2 \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float result;
void aimath_f32_default_norm_squared(const aitensor_t *x, void *result)
Calculates the squared sum of all elements in a F32 tensor.
Parameters
*xF32 tensor x (N-D tensor)
*resultScalar result (type aiscalar_f32_t / float)

◆ aimath_f32_default_relu()

void aimath_f32_default_relu ( const aitensor_t x,
aitensor_t result 
)

Calculates the rectifier (ReLU) value of each element in a F32 tensor.

\[ result_{i} = max(0, x_{i}) \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_relu(const aitensor_t *x, aitensor_t *result)
Calculates the rectifier (ReLU) value of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the ReLU from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_scalar_add()

void aimath_f32_default_scalar_add ( const void *  scalar,
const aitensor_t a,
aitensor_t result 
)

Performs an element wise addition of a scalar to a F32 tensor.

\[ result = a + \left( \begin{array}{ccc} 1 & \ldots & 1 \\ \vdots & \ddots & \vdots \\ 1 & \ldots & 1 \end{array}\right) \cdot scalar \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
float scalar = 0.1f;
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_scalar_add(&scalar, &a, &result);
print_aitensor(&result);
void aimath_f32_default_scalar_add(const void *scalar, const aitensor_t *a, aitensor_t *result)
Performs an element wise addition of a scalar to a F32 tensor.
Parameters
*scalarScalar (type aiscalar_f32_t / float)
*aF32 tensor a (N-D tensor)
*resultResulting F32 tensor of the element wise scalar addition (N-D tensor)

◆ aimath_f32_default_scalar_mul()

void aimath_f32_default_scalar_mul ( const void *  scalar,
const aitensor_t a,
aitensor_t result 
)

Performs a scalar multiplication (scaling) of F32 tensor a and a scalar.

\[ result = scalar \cdot a \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
float scalar = 0.1f;
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
aimath_f32_default_scalar_mul(&scalar, &a, &result);
print_aitensor(&result);
void aimath_f32_default_scalar_mul(const void *scalar, const aitensor_t *a, aitensor_t *result)
Performs a scalar multiplication (scaling) of F32 tensor a and a scalar.
Parameters
*scalarScalar (type aiscalar_f32_t / float)
*aF32 tensor a (N-D tensor)
*resultResulting F32 tensor of the scalar multiplication (N-D tensor)

◆ aimath_f32_default_sigmoid()

void aimath_f32_default_sigmoid ( const aitensor_t x,
aitensor_t result 
)

Calculates the sigmoid of each element in a F32 tensor.

\[ result_{i} = \sigma(x_{i}) = \frac{1}{1 + e^{-x_{i}}} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
Parameters
*xF32 tensor to calculate the sigmoid from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_softmax()

void aimath_f32_default_softmax ( const aitensor_t x,
aitensor_t result 
)

Calculates the softmax value of each row of a F32 matrix.

\[ result_{i} = \frac{e^{x_i}}{\sum_{j=1}^{K} e^{x_j}} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_softmax(const aitensor_t *x, aitensor_t *result)
Calculates the softmax value of each row of a F32 matrix.
Parameters
*xF32 matrix to calculate the softmax from (2D tensor)
*resultResulting F32 matrix (2D tensor)

◆ aimath_f32_default_softsign()

void aimath_f32_default_softsign ( const aitensor_t x,
aitensor_t result 
)

Calculates the softsign value of each element in a F32 tensor.

\[ result_{i} = \frac {x_i} {1 + |x_i|} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_softsign(const aitensor_t *x, aitensor_t *result)
Calculates the softsign value of each element in a F32 tensor.
Parameters
*xF32 tensor to calculate the softsign from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_sqrt()

void aimath_f32_default_sqrt ( const aitensor_t x,
aitensor_t result 
)

Calculates the element wise square root of a F32 tensor.

\[ result_{i} = \sqrt{x_{i}} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_sqrt(const aitensor_t *x, aitensor_t *result)
Calculates the element wise square root of a F32 tensor.
Parameters
*xF32 tensor to calculate the square root from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_sum()

void aimath_f32_default_sum ( const aitensor_t x,
void *  result 
)

Calculates the sum of all elements in a F32 tensor.

\[ result = \sum_i x_{i} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = {0.0f, 1.0f, 2.0f,
3.0f, 4.0f, 5.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
float result;
void aimath_f32_default_sum(const aitensor_t *x, void *result)
Calculates the sum of all elements in a F32 tensor.
Parameters
*xF32 tensor x (N-D tensor)
*resultScalar result (type aiscalar_f32_t / float)

◆ aimath_f32_default_tanh()

void aimath_f32_default_tanh ( const aitensor_t x,
aitensor_t result 
)

Calculates the tanh of each element in a F32 tensor.

\[ result_{i} = \tanh(x_{i}) = \frac{e^{x_i} - e^{-x_i}}{e^{x_i} + e^{-x_i}} \]

Example:

uint16_t x_shape[2] = {2, 3};
float x_data[2*3] = { 1.0f, -2.0f, 3.0f,
-4.0f, 5.0f, -6.0f};
aitensor_t x = AITENSOR_2D_F32(x_shape, x_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
Parameters
*xF32 tensor to calculate the tanh from (N-D tensor)
*resultResulting F32 tensor (N-D tensor)

◆ aimath_f32_default_tensor_add()

void aimath_f32_default_tensor_add ( const aitensor_t a,
const aitensor_t b,
aitensor_t result 
)

Performs an element wise addition of F32 tensors a and b.

\[ result = a + b \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {2, 3};
float b_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t b = AITENSOR_2D_F32(b_shape, b_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_tensor_add(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Performs an element wise addition of F32 tensors a and b.
Parameters
*aF32 tensor a (N-D tensor)
*bF32 tensor b (N-D tensor)
*resultResulting F32 tensor of the element wise addition (N-D tensor)

◆ aimath_f32_default_tensor_init_uniform()

void aimath_f32_default_tensor_init_uniform ( aitensor_t tensor,
float  from,
float  to 
)

Fills a F32 tensor with random numbers created from a uniform distribution within given range.

\[ tensor_i \in \mathcal{U(from, to)} \]

Example:

uint16_t tensor_shape[2] = {2, 3};
float tensor_data[2*3];
aitensor_t tensor = AITENSOR_2D_F32(tensor_shape, tensor_data);
print_aitensor(&tensor);
void aimath_f32_default_tensor_init_uniform(aitensor_t *tensor, float from, float to)
Fills a F32 tensor with random numbers created from a uniform distribution within given range.
Parameters
*tensorF32 tensor to initialize with random numbers (N-D tensor)
fromMinimum value of the uniform distribution
toMaximum value of the uniform distribution

◆ aimath_f32_default_tensor_sub()

void aimath_f32_default_tensor_sub ( const aitensor_t a,
const aitensor_t b,
aitensor_t result 
)

Performs a element wise subtraction of F32 tensors a and b.

\[ result = a - b \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {2, 3};
float b_data[2*3] = {1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f};
aitensor_t b = AITENSOR_2D_F32(b_shape, b_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_tensor_sub(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Performs a element wise subtraction of F32 tensors a and b.
Parameters
*aF32 tensor a (N-D tensor)
*bF32 tensor b (N-D tensor)
*resultResulting F32 tensor of the element wise subtraction (N-D tensor)

◆ aimath_f32_default_tensor_sub_sparse8()

void aimath_f32_default_tensor_sub_sparse8 ( const aitensor_t a,
const aitensor_t b,
aitensor_t result 
)

Performs a subtraction between a F32 matrix a and a U8 sparse matrix b.

This function can subtract a row wise one-hot encoded matrix in sparse representation (just the integer index of the 1 is stored) from a normal F32 matrix a.

For example the matrix

\[ \left( \begin{array}{ccc} 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{array}\right) \]

in sparse representation is

\[ \left( \begin{array}{ccc} 3 \\ 0 \\ 2 \end{array}\right) \]

The result is then calculated as

\[ result_{ij} = \begin{cases} a_{ij} - 1 & \text{if } j = b_i\\ a_{ij} & \text{if } j \neq b_i \end{cases} \]

Example:

uint16_t a_shape[2] = {2, 3};
float a_data[2*3] = {0.2f, 0.1f, 0.7f,
0.9f, 0.1f, 0.0f};
aitensor_t a = AITENSOR_2D_F32(a_shape, a_data);
uint16_t b_shape[2] = {2, 1};
uint8_t b_data[2*1] = {2,
0};
aitensor_t b = AITENSOR_2D_U8(b_shape, b_data);
uint16_t result_shape[2] = {2, 3};
float result_data[2*3];
aitensor_t result = AITENSOR_2D_F32(result_shape, result_data);
print_aitensor(&result);
void aimath_f32_default_tensor_sub_sparse8(const aitensor_t *a, const aitensor_t *b, aitensor_t *result)
Performs a subtraction between a F32 matrix a and a U8 sparse matrix b.
Parameters
*aF32 matrix a (2D tensor of shape [N x M])
*bU8 sparse matrix b (2D tensor of shape [N x 1])
*resultResulting F32 tensor of the subtraction (2D tensor of shape [N x M])

◆ aimath_f32_default_transpose_vector()

void aimath_f32_default_transpose_vector ( aitensor_t vector)

Transposes a F32 vector.

The given tensor must be a vector (2D tensor of shape [1 x N] or [N x 1]).

\[ vector \leftarrow vector^T \]

Example:

uint16_t vector_shape[2] = {1, 3};
float vector_data[1*3] = {1.0f, 2.0f, 3.0f};
aitensor_t vector = AITENSOR_2D_F32(vector_shape, vector_data);
print_aitensor(&vector);
void aimath_f32_default_transpose_vector(aitensor_t *vector)
Transposes a F32 vector.
Parameters
*vectorF32 vector (2D tensor of shape [1 x N] or [N x 1])

◆ aimath_f32_default_zero_tensor()

void aimath_f32_default_zero_tensor ( aitensor_t tensor)

Fills a F32 tensor with zeros.

\[ tensor_{i} = 0 \]

Example:

uint16_t tensor_shape[2] = {2, 3};
float tensor_data[2*3];
aitensor_t tensor = AITENSOR_2D_F32(tensor_shape, tensor_data);
print_aitensor(&tensor);
void aimath_f32_default_zero_tensor(aitensor_t *tensor)
Fills a F32 tensor with zeros.

In the F32 implementation of this function, there is no difference between aimath_f32_default_zero_tensor() and aimath_f32_default_init_zeros().

Parameters
*tensorF32 tensor to set to zero (N-D tensor)