You can initialize vector registers in the following ways:
- Elements undefined
- Elements as all zeros
- Using data from local memory
- Using part of the values set from another register
- A combination of the above
// contents undefined
aie::vector<int32,8> uv;
// all 0's
aie::vector<int32,8> nv = aie::zeros<int32,8>();
// all values are 100
aie::vector<int32,8> bv = aie::broadcast<int32,8>(100);
// concatenate vectors into larger vector
aie::vector<int32,16> cv=aie::concat(nv,bv);
int32* reals;
aie::vector<int32, 8> v = aie::load_v<8>(reals);
aie::vector<int32, 8> v2;
v2.load(reals);
// create a new 512-bit vector with lower 256-bit set with "iv"
aie::vector<int32,16> sv = iv.grow<16>(0);
In the previous example:
-
aie::zeros - Creates vector with all elements 0.
-
aie::broadcast - Sets all elements of vector to a value.
-
aie::concat - Concatenates multiple vectors or accumulators with same type and size into a larger vector or accumulator.
The vector and accumulator classes have the member function grow(). This creates a larger vector where only one
part is initialized with the subvector (iv in above
example). The other parts are undefined. Here the function parameter idx indicates the location of the subvector within the
output vector.
The static keyword applies to the vector data
type as well. When you apply, the default value is zero when not initialized, and
the value is kept between graph run iterations.