|
AI Engine API User Guide (AIE-API) 2024.2
|
Vector Initialization
The contents of a vector are undefined when default constructed.
- Warning
- Operations with undefined input vectors may not produce an error during compilation, but may not work as expected.
The simplest way of initializing a vector is from another vector of the same type and size.
Or as the result of an operation.
A vector can also be read from memory using the aie::load_v operation or iterators. See Memory for more details.
Sections of a vector can be modified independently. It can be done in a per-element basis.
Or by writing subvectors.
Vectors can also be concatenated into a larger vector.
Accumulator Initialization
Accumulators support all the aforementioned vector operations but the individual element update.
The contents of an accumulator are undefined when default constructed.
- Warning
- Reading an undefined input accumulator may not produce an error during compilation, but the operation may not behave as intended.
We can initialize an accumulator from the result of an operation. Some operations such as aie::mul, are able to deduce the optimal accumulator type from their input arguments. When this is the case, it is not trivial for the developer to know what type each of the template parameters will be used in every situation, but we can let the compiler deduce them instead:
If we need to retrieve any of the template parameters later on, it is possible to access them by means of class member typedefs:
Initialization by Stream Read
Both vectors and accumulators can also be read from ADF abstractions such as windows and streams. See Interoperability with Adaptive Data Flow (ADF) Graph Abstractions for more details.
Mask Initialization
Masks are usually initialized as a result of a comparison using vectors:
In addition, it is possible to initialize a mask using a constant value. For example:
- Tip:
- You can use the standard C/C++ macros for fixed-sized integers instead of the integer suffix. In the definition of
m1it would look likeUINT64_C(0xaaaabbbbccccdddd).