|
AI Engine API User Guide (AIE-API) 2025.1
|
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> | |
| constexpr 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> | |
| constexpr 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> | |
| constexpr void | aie::unroll_times (Fn &&fn) |
| Invokes a function object a given number of times. | |
| template<unsigned TimesY, unsigned TimesX, typename Fn> | |
| constexpr void | aie::unroll_times_2d (Fn &&fn) |
| Invokes a function object as many times as defined by a 2D index sequence. | |
|
constexpr |
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: void fun(const Type &i);
void fun();
The signature does not need to have |
|
constexpr |
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 void fun(const Type &y, const Type &x);
void fun();
The signature does not need to have |
|
constexpr |
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: void fun(const Type &i);
void fun();
The signature does not need to have |
|
constexpr |
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: void fun(const Type &y, const Type &x);
void fun();
The signature does not need to have |