AIfES 2  2.0.0
aimath_f32_avr_pgm.h File Reference

Math functions for F32 data type using AVR pgmspace.h library for constant data storage. More...

Go to the source code of this file.

Functions

void aimath_f32_avr_pgm_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...
 

Detailed Description

Math functions for F32 data type using AVR pgmspace.h library for constant data storage.

Version
2.2.0

These functions modify the default implementation of the F32 math functions to work with parameters, stored in the program memory of AVR controllers.

The library avr/pgmspace.h is required.

Function Documentation

◆ aimath_f32_avr_pgm_linear()

void aimath_f32_avr_pgm_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 data of b and c must be defined constant in PROGMEM.

Same functionality as aimath_f32_default_linear().

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:

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};
const float b_data[3*2] PROGMEM = {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};
const float c_data[1*2] PROGMEM = {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_avr_pgm_linear(&a, &b, &c, &result);
void aimath_f32_avr_pgm_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.
A tensor in AIfES.
Definition: aifes_math.h:89
Parameters
*aF32 matrix a (2D tensor of shape [N x K])
*bF32 matrix b (2D tensor of shape [K x M]) (data const in PROGMEM)
*cF32 vector c (2D tensor of shape [1 x M]) (data const in PROGMEM)
*resultResulting F32 matrix (2D tensor of shape [N x M])