AI Engine API User Guide (AIE-API) 2024.2
|
These functions allow users to explicitly unroll the body of a loop.
The simplest way to use them is to provide a lambda expression with the loop body. For example:
It is recommended that any functions or function-like objects used are marked with the always_inline
attribute. There are different ways you can specify this:
__aie_inline
__attribute__((always_inline))
[[gnu::always_inline]]
, [[clang::always_inline]]
.References:
Functions | |
template<typename T , T Start, T End, T Step = 1, typename Fn > | |
void | aie::unroll_for (Fn &&fn) |
Invokes a function object as many times as specified by a linear index sequence. | |
template<typename T , T StartY, T EndY, T StepY, T StartX, T EndX, T StepX, typename Fn > | |
void | aie::unroll_for_2d (Fn &&fn) |
Invokes a function object as many times as defined by a 2D index sequence. | |
template<unsigned Times, typename Fn > | |
void | aie::unroll_times (Fn &&fn) |
Invokes a function object a given number of times. | |
template<unsigned TimesY, unsigned TimesX, typename Fn > | |
void | aie::unroll_times_2d (Fn &&fn) |
Invokes a function object as many times as defined by a 2D index sequence. | |
void aie::unroll_for | ( | Fn && | fn | ) |
Invokes a function object as many times as specified by a linear index sequence.
T | Type of the sequence values passed to the function. |
Start | First value in the sequence. |
End | Upper limit of the sequence. |
Step | Distance between two consecutive values in the sequence. |
fn | A function object that takes a sequence value by argument. The signature of the function should be equivalent to one of the following:
The signature does not need to have |
void aie::unroll_for_2d | ( | Fn && | fn | ) |
Invokes a function object as many times as defined by a 2D index sequence.
T | Type of the sequence values passed to the function. |
StartY | First value in the sequence (y-axis). |
EndY | Upper limit of the sequence(y-axis). |
StepY | Distance between two consecutive values in the sequence (y-axis). |
StartX | First value in the sequence (x-axis). |
EndX | Upper limit of the sequence (x-axis). |
StepX | Distance between two consecutive values in the sequence (x-axis). |
fn | A function object that takes two values of type
The signature does not need to have |
void aie::unroll_times | ( | Fn && | fn | ) |
Invokes a function object a given number of times.
The function takes the current count by argument.
Times | Total number of function calls. |
fn | A function object that takes the current count by argument. The signature of the function should be equivalent to one of the following:
The signature does not need to have |
void aie::unroll_times_2d | ( | Fn && | fn | ) |
Invokes a function object as many times as defined by a 2D index sequence.
TimesY | Total number of function calls (y-axis). |
TimesX | Total number of function calls (x-axis). |
fn | A function object that takes two values by argument, representing the current count for each of the dimensions. The signature of the function should be equivalent to one of the following:
The signature does not need to have |