AI Engine API User Guide (AIE) 2022.2
aie::detail::vector< T, Elems > Class Template Reference

Detailed Description

template<typename T, unsigned Elems>
class aie::detail::vector< T, Elems >

Implementation of the vector data type

Template Parameters
TType of the elements contained in the vector.
ElemsNumber of elements in the vector.

#include <vector.hpp>

Public Types

using native_type = native_vector_type_t< T, Elems >
 
using value_type = T
 

Public Member Functions

 vector ()
  More...
 
 vector (const native_type &v)
  More...
 
template<typename... Values>
 vector (value_type v, Values &&... values)
  More...
 
 vector (vector_storage_t< T, Elems > v)
  More...
 
template<typename DstT >
auto cast_to () const
  More...
 
constexpr vector_elem_const_ref< value_type, Elems > elem_const_ref (unsigned idx) const
  More...
 
constexpr vector_elem_ref< value_type, Elems > elem_ref (unsigned idx)
  More...
 
constexpr vector_elem_const_ref< value_type, Elems > elem_ref (unsigned idx) const
  More...
 
template<unsigned ElemsOut>
vector< value_type, ElemsOut > extract (unsigned idx) const
  More...
 
value_type get (unsigned idx) const
  More...
 
template<unsigned ElemsOut>
constexpr vector< T, ElemsOut > grow (unsigned idx=0) const
  More...
 
template<unsigned ElemsOut>
vector< value_type, ElemsOut > grow_extract (unsigned idx) const
 
template<unsigned ElemsOut>
constexpr vector< T, ElemsOut > grow_replicate () const
  More...
 
template<unsigned ElemsIn>
vectorinsert (unsigned idx, const vector< T, ElemsIn > &v)
  More...
 
template<unsigned ElemsIn>
vectorinsert (unsigned idx, typename vector< T, ElemsIn >::native_type v)
  More...
 
template<aie_dm_resource Resource, typename T2 >
void load (const T2 *ptr)
  More...
 
template<aie_dm_resource Resource, typename T2 >
void load_unaligned (const T2 *ptr, unsigned aligned_elems)
  More...
 
 operator native_type () const
  More...
 
constexpr vector_elem_ref< value_type, Elems > operator[] (unsigned idx)
  More...
 
constexpr vector_elem_const_ref< value_type, Elems > operator[] (unsigned idx) const
  More...
 
template<typename T2 >
vector< T2, Elems > pack () const
  More...
 
template<typename T2 >
vector< T2, Elems > pack_sign (bool v_sign) const
  More...
 
vectorpush (value_type v)
  More...
 
void set (value_type v, unsigned idx)
  More...
 
template<unsigned ElemsOut>
auto split () const
  More...
 
template<aie_dm_resource Resource, typename T2 >
void store (T2 *ptr) const
  More...
 
template<aie_dm_resource Resource, typename T2 >
void store_unaligned (T2 *ptr, unsigned aligned_elems) const
  More...
 
auto to_native () const
 
vector< int16, Elems > unpack () const
  More...
 
vector< int16, Elems > unpack_sign (bool v_sign) const
  More...
 
template<typename... SubVectors>
vectorupd_all (SubVectors &&...subvectors)
  More...
 

Static Public Member Functions

static constexpr unsigned bits ()
  More...
 
static constexpr bool is_complex ()
  More...
 
static constexpr bool is_floating_point ()
  More...
 
static constexpr bool is_integral ()
  More...
 
static constexpr bool is_real ()
  More...
 
static constexpr bool is_signed ()
  More...
 
static constexpr unsigned size ()
  More...
 

Friends

template<typename T2 , unsigned Elems2>
class vector
  More...
 

Constructor & Destructor Documentation

◆ vector() [1/4]

template<typename T , unsigned Elems>
aie::detail::vector< T, Elems >::vector ( )
inline

Default constructor. The value of the elements is undefined.

◆ vector() [2/4]

template<typename T , unsigned Elems>
aie::detail::vector< T, Elems >::vector ( vector_storage_t< T, Elems >  v)
inline

Construct from internal native types.

Parameters
vData used to construct the vector from.

◆ vector() [3/4]

template<typename T , unsigned Elems>
aie::detail::vector< T, Elems >::vector ( const native_type v)
inline

Construct from internal types. This is a special case for 1024b internal vector types, which need to be broken into two 512b vectors

Parameters
vData used to construct the vector from

◆ vector() [4/4]

template<typename T , unsigned Elems>
template<typename... Values>
aie::detail::vector< T, Elems >::vector ( value_type  v,
Values &&...  values 
)
inlineexplicit

Construct from a list of values

Parameters
vFirst value in the list
valuesRest of values in the list

Member Function Documentation

◆ bits()

template<typename T , unsigned Elems>
static constexpr unsigned aie::detail::vector< T, Elems >::bits ( )
inlinestaticconstexpr

Returns the total size of the vector in bits.

◆ cast_to()

template<typename T , unsigned Elems>
template<typename DstT >
auto aie::detail::vector< T, Elems >::cast_to ( ) const
inline

Reinterprets the current vector as a vector of the given type. The number of elements is automatically computed by the function

Template Parameters
DstTType the vector will be cast to

◆ elem_const_ref()

template<typename T , unsigned Elems>
constexpr vector_elem_const_ref<value_type, Elems> aie::detail::vector< T, Elems >::elem_const_ref ( unsigned  idx) const
inlineconstexpr

Returns a constant reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ elem_ref() [1/2]

template<typename T , unsigned Elems>
constexpr vector_elem_ref<value_type, Elems> aie::detail::vector< T, Elems >::elem_ref ( unsigned  idx)
inlineconstexpr

Returns a reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ elem_ref() [2/2]

template<typename T , unsigned Elems>
constexpr vector_elem_const_ref<value_type, Elems> aie::detail::vector< T, Elems >::elem_ref ( unsigned  idx) const
inlineconstexpr

Returns a constant reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ extract()

template<typename T , unsigned Elems>
template<unsigned ElemsOut>
vector<value_type, ElemsOut> aie::detail::vector< T, Elems >::extract ( unsigned  idx) const
inline

Returns a subvector with the contents of a region of the vector.

Template Parameters
ElemsOutSize of the returned subvector.
Parameters
idxIndex of the subvector to be returned.

◆ get()

template<typename T , unsigned Elems>
value_type aie::detail::vector< T, Elems >::get ( unsigned  idx) const
inline

Returns the value of the element on the given index.

Parameters
idxIndex of the element.

◆ grow()

template<typename T , unsigned Elems>
template<unsigned ElemsOut>
constexpr vector<T, ElemsOut> aie::detail::vector< T, Elems >::grow ( unsigned  idx = 0) const
inlineconstexpr

Returns a copy of the current vector in a larger vector. The value of the new elements is undefined.

Template Parameters
ElemsOutSize of the output vector.
Parameters
idxLocation of the subvector within the output vector

◆ grow_replicate()

template<typename T , unsigned Elems>
template<unsigned ElemsOut>
constexpr vector<T, ElemsOut> aie::detail::vector< T, Elems >::grow_replicate ( ) const
inlineconstexpr

Returns a copy of the current vector in a larger vector. The contents of the vector are replicated as many times as required to fill the output vector

Template Parameters
ElemsOutSize of the output vector.

◆ insert() [1/2]

template<typename T , unsigned Elems>
template<unsigned ElemsIn>
vector& aie::detail::vector< T, Elems >::insert ( unsigned  idx,
const vector< T, ElemsIn > &  v 
)
inline

Updates the contents of a region of the vector using the values in the given subvector and returns a reference to the updated vector.

Parameters
idxIndex of the subvector to be replaced.
vSubvector to be written into the region.

◆ insert() [2/2]

template<typename T , unsigned Elems>
template<unsigned ElemsIn>
vector& aie::detail::vector< T, Elems >::insert ( unsigned  idx,
typename vector< T, ElemsIn >::native_type  v 
)
inline

Updates the contents of a region of the vector using the values in the given native subvector and returns a reference to the updated vector.

Parameters
idxIndex of the subvector to be replaced.
vNative subvector to be written into the region.

◆ is_complex()

template<typename T , unsigned Elems>
static constexpr bool aie::detail::vector< T, Elems >::is_complex ( )
inlinestaticconstexpr

Returns a bool that says whether the element type is a complex number.

◆ is_floating_point()

template<typename T , unsigned Elems>
static constexpr bool aie::detail::vector< T, Elems >::is_floating_point ( )
inlinestaticconstexpr

Returns a bool that says whether the element type is floating-point.

◆ is_integral()

template<typename T , unsigned Elems>
static constexpr bool aie::detail::vector< T, Elems >::is_integral ( )
inlinestaticconstexpr

Returns a bool that says whether the element type is an integer.

◆ is_real()

template<typename T , unsigned Elems>
static constexpr bool aie::detail::vector< T, Elems >::is_real ( )
inlinestaticconstexpr

Returns a bool that says whether the element type is a real number.

◆ is_signed()

template<typename T , unsigned Elems>
static constexpr bool aie::detail::vector< T, Elems >::is_signed ( )
inlinestaticconstexpr

Returns a bool that says whether the element type is signed.

◆ load()

template<typename T , unsigned Elems>
template<aie_dm_resource Resource, typename T2 >
void aie::detail::vector< T, Elems >::load ( const T2 *  ptr)
inline

Replaces the contents of the vector with the values pointed by the given memory address. Address is assumed to meet the alignment requirements for vector loads (>= 32 bytes).

Parameters
ptrPointer to the location of the values in memory.

◆ load_unaligned()

template<typename T , unsigned Elems>
template<aie_dm_resource Resource, typename T2 >
void aie::detail::vector< T, Elems >::load_unaligned ( const T2 *  ptr,
unsigned  aligned_elems 
)
inline

Replaces the contents of the vector with the values pointed by the given memory address. Address is assumed to be aligned to the given amount of elements.

Parameters
ptrPointer to the location of the values in memory.
aligned_elemsNumber of elements ptr is aligned to.

◆ operator native_type()

template<typename T , unsigned Elems>
aie::detail::vector< T, Elems >::operator native_type ( ) const
inline

Operator for conversion to the native type

◆ operator[]() [1/2]

template<typename T , unsigned Elems>
constexpr vector_elem_ref<value_type, Elems> aie::detail::vector< T, Elems >::operator[] ( unsigned  idx)
inlineconstexpr

Returns a reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ operator[]() [2/2]

template<typename T , unsigned Elems>
constexpr vector_elem_const_ref<value_type, Elems> aie::detail::vector< T, Elems >::operator[] ( unsigned  idx) const
inlineconstexpr

Returns a constant reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ pack()

template<typename T , unsigned Elems>
template<typename T2 >
vector<T2, Elems> aie::detail::vector< T, Elems >::pack ( ) const
inline

Converts the current vector of 16b elements into a vector of 8b elements.

◆ pack_sign()

template<typename T , unsigned Elems>
template<typename T2 >
vector<T2, Elems> aie::detail::vector< T, Elems >::pack_sign ( bool  v_sign) const
inline

Note: Not currently functional on this architecture Converts the current vector of 16b elements into a vector of 8b elements, with control of the sign of the return type.

Parameters
v_signReturned vector is signed or not, regardless of the underlying type.

◆ push()

template<typename T , unsigned Elems>
vector& aie::detail::vector< T, Elems >::push ( value_type  v)
inline

Shifts all elements in the vector up and writes the given value into the first position of the vector (the element in the last position of the vector is lost).

Parameters
vValue to be written into the first position of the vector

◆ set()

template<typename T , unsigned Elems>
void aie::detail::vector< T, Elems >::set ( value_type  v,
unsigned  idx 
)
inline

Updates the value of the element on the given index.

Parameters
vValue to write.
idxIndex of the element whose value is updated.

◆ size()

template<typename T , unsigned Elems>
static constexpr unsigned aie::detail::vector< T, Elems >::size ( )
inlinestaticconstexpr

Returns the number of elements in the vector.

◆ split()

template<typename T , unsigned Elems>
template<unsigned ElemsOut>
auto aie::detail::vector< T, Elems >::split ( ) const
inline

Returns the contents of the current vector stored in a std::tuple of subvectors.

Template Parameters
ElemsOutSize of each subvector.

◆ store()

template<typename T , unsigned Elems>
template<aie_dm_resource Resource, typename T2 >
void aie::detail::vector< T, Elems >::store ( T2 *  ptr) const
inline

Writes the contents of the vector into the given memory address. Address is assumed to meet the alignment requirements for vector stores (>= 32 bytes).

Parameters
ptrPointer to the location where the vector contents must be written in memory.

◆ store_unaligned()

template<typename T , unsigned Elems>
template<aie_dm_resource Resource, typename T2 >
void aie::detail::vector< T, Elems >::store_unaligned ( T2 *  ptr,
unsigned  aligned_elems 
) const
inline

Writes the contents of the vector into the given memory address. Address is assumed to be aligned to the given amount of elements.

Parameters
ptrPointer to the location where the vector contents must be written in memory.
aligned_elemsNumber of elements ptr is aligned to.

◆ unpack()

template<typename T , unsigned Elems>
vector<int16, Elems> aie::detail::vector< T, Elems >::unpack ( ) const
inline

Converts the current vector of 8b elements into a vector of 16b elements.

◆ unpack_sign()

template<typename T , unsigned Elems>
vector<int16, Elems> aie::detail::vector< T, Elems >::unpack_sign ( bool  v_sign) const
inline

Note: Not currently functional on this architecture Converts the current vector of 8b elements into a vector of 16b elements, with control of the sign of the return type.

Parameters
v_signReturned vector is signed or not, regardless of the underlying type.

◆ upd_all()

template<typename T , unsigned Elems>
template<typename... SubVectors>
vector& aie::detail::vector< T, Elems >::upd_all ( SubVectors &&...  subvectors)
inline

Updates the contents of the vector using the values in the given subvectors. Subvectors must be of the same type and size.

Parameters
subvectorsList of subvectors.

Friends And Related Function Documentation

◆ vector

template<typename T , unsigned Elems>
template<typename T2 , unsigned Elems2>
friend class vector
friend

Type for vector registers. The documentation of this class and its members can be found at detail::vector.

Template Parameters
TType of the elements contained in the vector. It must meet ElemBaseType.
ElemsNumber of elements in the vector.

The documentation for this class was generated from the following file: