AI Engine API User Guide (AIE) 2023.2
Loading...
Searching...
No Matches
Reshaping

AIE API provides operations to change the location of the elements within a vector and to combine the elements from two or more vectors. More...

Overview

AIE API provides operations to change the location of the elements within a vector and to combine the elements from two or more vectors.

Functions

template<Vector Vec>
auto aie::filter_even (const Vec &v, unsigned step=1) -> vector< typename Vec::value_type, Vec::size()/2 >
 Returns a vector of half the size whose contents follow the following pattern.
 
template<Vector Vec>
auto aie::filter_odd (const Vec &v, unsigned step=1) -> vector< typename Vec::value_type, Vec::size()/2 >
 Returns a vector of half the size whose contents follow the following pattern.
 
template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2>)
auto aie::interleave_unzip (const Vec1 &v1, const Vec2 &v2, unsigned step) -> std::pair< aie_dm_resource_remove_t< Vec1 >, aie_dm_resource_remove_t< Vec1 > >
 Picks elements sequentially from the input vectors and writes them alternatively into the output vectors.
 
template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2>)
auto aie::interleave_zip (const Vec1 &v1, const Vec2 &v2, unsigned step) -> std::pair< aie_dm_resource_remove_t< Vec1 >, aie_dm_resource_remove_t< Vec1 > >
 Picks elements alternatively from the input vectors and writes them sequentially into the output vectors.
 
template<Vector Vec>
auto aie::reverse (const Vec &v) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but in reverse order.
 
template<Elem E1, Elem E2, Mask M>
requires (is_valid_elem_op_v<E1, E2>)
vector< operand_base_type_t< E1 >, M::size()> aie::select (const E1 &a, const E2 &b, const M &m)
 Combines the values of the input vector and value into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.
 
template<Vector Vec, Elem E, Mask M>
requires (is_valid_elem_op_v<E, typename Vec::value_type> && Vec::size() == M::size())
auto aie::select (const Vec &v, E a, const M &m) -> aie_dm_resource_remove_t< Vec >
 Combines the values of the input vector and value into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.
 
template<Vector Vec1, Vector Vec2, Mask M>
requires (is_same_vector_v<Vec1, Vec2> && Vec1::size() == M::size())
auto aie::select (const Vec1 &v1, const Vec2 &v2, const M &m) -> aie_dm_resource_remove_t< Vec1 >
 Combines the values of the two input vectors into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.
 
template<Elem E, Vector Vec, Mask M>
requires (is_valid_elem_op_v<E, typename Vec::value_type> && Vec::size() == M::size())
auto aie::select (E a, const Vec &v, const M &m) -> aie_dm_resource_remove_t< Vec >
 Combines the values of the input value and vector into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.
 
template<Vector Vec>
auto aie::shuffle_down (const Vec &v, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted down by n.
 
template<Vector Vec>
auto aie::shuffle_down_fill (const Vec &v, const Vec &fill, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted down by n.
 
template<Vector Vec>
auto aie::shuffle_down_replicate (const Vec &v, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted down by n.
 
template<Vector Vec>
auto aie::shuffle_down_rotate (const Vec &v, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted down by n (elements wrap around):
 
template<Vector Vec>
auto aie::shuffle_up (const Vec &v, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted up by n.
 
template<Vector Vec>
auto aie::shuffle_up_fill (const Vec &v, const Vec &fill, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted up by n.
 
template<Vector Vec>
auto aie::shuffle_up_replicate (const Vec &v, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted up by n.
 
template<Vector Vec>
auto aie::shuffle_up_rotate (const Vec &v, unsigned n) -> aie_dm_resource_remove_t< Vec >
 Returns a vector whose contents are the same as the input vector, but shifted up by n (elements wrap around):
 
template<Vector Vec>
auto aie::transpose (const Vec &v, unsigned Row, unsigned Col) -> aie_dm_resource_remove_t< Vec >
 The input vector is interpreted as a row-major matrix of the dimensions specified by Row and Col, the function returns a vector ordered as the transpose of the specified matrix.
 

Function Documentation

◆ filter_even()

template<Vector Vec>
auto aie::filter_even ( const Vec &  v,
unsigned  step = 1 
) -> vector<typename Vec::value_type, Vec::size() / 2>

Returns a vector of half the size whose contents follow the following pattern.

out = { a[0:step], a[2*step:3*step], ... }
#
Parameters
vInput vector. Must meet Vector.
stepNumber of contiguous elements taken from the input vector. Must be a power of two.

◆ filter_odd()

template<Vector Vec>
auto aie::filter_odd ( const Vec &  v,
unsigned  step = 1 
) -> vector<typename Vec::value_type, Vec::size() / 2>

Returns a vector of half the size whose contents follow the following pattern.

out = { a[step:2*step], a[3*step:4*step], ... }
#
Parameters
vInput vector. Must meet Vector.
stepNumber of contiguous elements taken from the input vector. Must be a power of two.

◆ interleave_unzip()

template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2>)
auto aie::interleave_unzip ( const Vec1 &  v1,
const Vec2 &  v2,
unsigned  step 
) -> std::pair<aie_dm_resource_remove_t<Vec1>, aie_dm_resource_remove_t<Vec1>>

Picks elements sequentially from the input vectors and writes them alternatively into the output vectors.

out = { a[0:step], a[2*step:3*step], ..., b[0:step], b[2*step:3*step], ..., a[step:2*step], a[3*step:4*step], ..., b[step:2*step], b[3*step:4*step], ... }
#
Parameters
v1First input vector. Must meet Vector.
v2Second input vector. Must meet Vector.
stepNumber of contiguous elements taken from each input vector. Must be a power of two.

◆ interleave_zip()

template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2>)
auto aie::interleave_zip ( const Vec1 &  v1,
const Vec2 &  v2,
unsigned  step 
) -> std::pair<aie_dm_resource_remove_t<Vec1>, aie_dm_resource_remove_t<Vec1>>

Picks elements alternatively from the input vectors and writes them sequentially into the output vectors.

out = { a[0:step], b[0:step], a[step:2*step], b[step:2*step], ... }
Parameters
v1First input vector. Must meet Vector.
v2Second input vector. Must meet Vector.
stepNumber of contiguous elements taken from each input vector. Must be a power of two.

◆ reverse()

template<Vector Vec>
auto aie::reverse ( const Vec &  v) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but in reverse order.

for (unsigned i = 0; i < Elems; ++i)
out[i] = in[Elems - i - 1];
Parameters
vInput vector. The type must meet Vector.

◆ select() [1/4]

template<Elem E1, Elem E2, Mask M>
requires (is_valid_elem_op_v<E1, E2>)
vector< operand_base_type_t< E1 >, M::size()> aie::select ( const E1 &  a,
const E2 &  b,
const M &  m 
)

Combines the values of the input vector and value into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = m[i] == 0? a : b;
Parameters
aInput value. The type must meet Elem.
bInput value. The type must meet Elem.
mMask that specifies the source input for each output element. The type must meet Mask.

◆ select() [2/4]

template<Vector Vec, Elem E, Mask M>
requires (is_valid_elem_op_v<E, typename Vec::value_type> && Vec::size() == M::size())
auto aie::select ( const Vec &  v,
a,
const M &  m 
) -> aie_dm_resource_remove_t<Vec>

Combines the values of the input vector and value into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = m[i] == 0? v[i] : a;
Parameters
vInput vector. The type must meet Vector.
aInput value. The type must meet Elem.
mMask that specifies the source input for each output element. The type must meet Mask.

◆ select() [3/4]

template<Vector Vec1, Vector Vec2, Mask M>
requires (is_same_vector_v<Vec1, Vec2> && Vec1::size() == M::size())
auto aie::select ( const Vec1 &  v1,
const Vec2 &  v2,
const M &  m 
) -> aie_dm_resource_remove_t<Vec1>

Combines the values of the two input vectors into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = m[i] == 0? v1[i] : v2[i];
Parameters
v1First input vector. The type must meet Vector.
v2Second input vector. The type must meet Vector.
mMask that specifies the source input for each output element. The type must meet Mask.

◆ select() [4/4]

template<Elem E, Vector Vec, Mask M>
requires (is_valid_elem_op_v<E, typename Vec::value_type> && Vec::size() == M::size())
auto aie::select ( a,
const Vec &  v,
const M &  m 
) -> aie_dm_resource_remove_t<Vec>

Combines the values of the input value and vector into a vector of the same size by using a mask that specifies which is the source input for each element of the output vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = m[i] == 0? a : v[i];
Parameters
aInput value. The type must meet Elem.
vInput vector. The type must meet Vector.
mMask that specifies the source input for each output element. The type must meet Mask.

◆ shuffle_down()

template<Vector Vec>
auto aie::shuffle_down ( const Vec &  v,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted down by n.

Elements do not wrap around and new elements are undefined.

for (unsigned i = 0; i < Elems - n; ++i)
out[i] = in[i + n]
Parameters
vInput vector. The type must meet Vector.
nDistance for the elements to be shifted.

◆ shuffle_down_fill()

template<Vector Vec>
auto aie::shuffle_down_fill ( const Vec &  v,
const Vec &  fill,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted down by n.

Elements do not wrap around and new elements are filled from a second vector.

for (unsigned i = 0; i < Elems - n; ++i)
out[i] = in[i + n]
for (unsigned i = 0; i < n; ++i)
out[i + Elems - n] = fill[i]
Parameters
vInput vector. The type must meet Vector.
fillSecond input vector used to fill the elements in the upper part of the output vector.
nDistance for the elements to be shifted.

◆ shuffle_down_replicate()

template<Vector Vec>
auto aie::shuffle_down_replicate ( const Vec &  v,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted down by n.

Elements do not wrap around and new elements are copies of the last element of the input vector.

for (unsigned i = 0; i < Elems - n; ++i)
out[i] = in[i + n]
for (unsigned i = Elems - n; i < Elems; ++i)
out[i] = in[Elems - 1];
Parameters
vInput vector. The type must meet Vector.
nDistance for the elements to be shifted.

◆ shuffle_down_rotate()

template<Vector Vec>
auto aie::shuffle_down_rotate ( const Vec &  v,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted down by n (elements wrap around):

for (unsigned i = 0; i < Elems; ++i)
out[i] = in[(i + n) % Elems]
Parameters
vInput vector. The type must meet Vector.
nDistance for the elements to be shifted.

◆ shuffle_up()

template<Vector Vec>
auto aie::shuffle_up ( const Vec &  v,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted up by n.

Elements do not wrap around and new elements are undefined.

for (unsigned i = 0; i < Elems - n; ++i)
out[i + n] = in[i]
Parameters
vInput vector. The type must meet Vector.
nDistance for the elements to be shifted.

◆ shuffle_up_fill()

template<Vector Vec>
auto aie::shuffle_up_fill ( const Vec &  v,
const Vec &  fill,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted up by n.

Elements do not wrap around and new elements are filled from a second vector.

for (unsigned i = 0; i < Elems - n; ++i)
out[i + n] = in[i]
for (unsigned i = 0; i < n; ++i)
out[i] = fill[i + Elems - n];
Parameters
vInput vector. The type must meet Vector.
fillSecond input vector used to fill the elements in the lower part of the output vector.
nDistance for the elements to be shifted.

◆ shuffle_up_replicate()

template<Vector Vec>
auto aie::shuffle_up_replicate ( const Vec &  v,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted up by n.

Elements do not wrap around and new elements are copies of the first element of the input vector.

for (unsigned i = 0; i < Elems - n; ++i)
out[i + n] = in[i]
for (unsigned i = 0; i < n; ++i)
out[i] = in[0];
Parameters
vInput vector. The type must meet Vector.
nDistance for the elements to be shifted.

◆ shuffle_up_rotate()

template<Vector Vec>
auto aie::shuffle_up_rotate ( const Vec &  v,
unsigned  n 
) -> aie_dm_resource_remove_t<Vec>

Returns a vector whose contents are the same as the input vector, but shifted up by n (elements wrap around):

for (unsigned i = 0; i < Elems; ++i)
out[i] = in[(i - n) % Elems]
Parameters
vInput vector. The type must meet Vector.
nDistance for the elements to be shifted.

◆ transpose()

template<Vector Vec>
auto aie::transpose ( const Vec &  v,
unsigned  Row,
unsigned  Col 
) -> aie_dm_resource_remove_t<Vec>

The input vector is interpreted as a row-major matrix of the dimensions specified by Row and Col, the function returns a vector ordered as the transpose of the specified matrix.

For Row equal to 1, the input vector is returned.

Parameters
vInput vector. The type must meet Vector, with number of elements equal to Row * Col.
RowNumber of rows of the input matrix shape.
ColNumber of cols of the input matrix shape.