AI Engine-ML v2 Intrinsics User Guide  v2025.1
Loading...
Searching...
No Matches

Intrinsics for moving values from vector data-types to accumulator data-types. More...

Topics

 AIE interface
 
 Floating-point
 
 Size interface
 

Detailed Description

Intrinsics for moving values from vector data-types to accumulator data-types.

Moving data from vector data-types to accumulator data-types (e.g. for initialization) requires adjustment in precision because the accumulator data-types are wider in size. For fixed point arithmetic, an appropriate left shift operation would align the decimal point between the two representations. The shift amount is specified as a parameter ranging from 0 to 63. Specifically, left shift operations involving 32-bit accumulators (e.g., v32acc32) handle shift amounts ranging from 0 to 31, while they will return 0 for shift amounts larger than 32 due to a left shift overflow. On the other hand, left shift operations involving 64-bit accumulators (e.g., v16acc64) support shift amounts ranging from 0 to 63.

The upshift intrinsics performs the saturation computing and then the upshift :

input_datatype saturation ( input_datatype ival , int shift , bool & has_sat )
{
input_datatype oval
input_datatype max
input_datatype min
if ( get_sat() ) // Please see set_sat() and get_sat()
{
min = - 2^( output_precision - 1 )
max = 2^( output_precision - 1 ) - 1
if ( is_unsigned( output_datatype ) )
{
min = 0
max = 2 ^ output_precision - 1
}
else if ( get_symsat() ) // Please see set_sym_sat() and get_sym_sat()
min = - 2 ^ output_precision + 1
max = max >> shift
min = min >> shift
if ( ival > max )
{
oval = max
has_sat = True // See set_ups_sat()
}
else if ( ival < min )
{
oval = min
has_sat = True // See set_ups_sat()
}
else
{
oval = ival
}
}
else
oval = ival
return oval
}
v64int8 min(v64int8 a, v64int8 b)
Calculates the minimum between two input vectors.
Definition me_vadd.h:443
v64int8 max(v64int8 a, v64int8 b)
Calculates the maximum between two input vectors.
Definition me_vadd.h:508
unsigned int get_symsat()
Get symmetric saturation mode.
Definition me_set_mode.h:160
unsigned int get_sat()
Get saturation mode.
Definition me_set_mode.h:158
v64int8 shift(v64int8 a, v64int8 b, unsigned int shift)
Definition me_scl2vec.h:169

No rounding is needed as there is no loss in precision. Thus, after the saturation is computed, the shift is performed:

output_datatype lane_ups ( input_datatype ival , int shift, bool & sat)
{
input_datatype oval_aux
output_datatype oval
sat = False
oval_aux = saturation( ival, shift, sat )
oval = oval_aux << shift
return oval
}

The full ups call then applies the above algorithm to all lanes of a vector and sets the status saturation bit (if saturation is triggered):

vec_output_datatype ups ( vec_input_datatype ival , int shift, bool & sat)
{
vec_output_datatype out
bool sat = False
bool sat_aux = False
for i in lanes(ival)
{
r = lane_ups(i, shift, sat_aux)
sat |= sat_aux
out = upd_elem(out,i,r)
}
if sat
set_ups_sat()
return out
}
v128int4 upd_elem(v128int4 v, int idx, v2int4 b)
v16accfloat ups(v16bfloat16)
Note
Saturation status is not cleared automatically. If set, it will remain set until the user clears the status bit.
See also
'srs' intrinsics (Shift-Round-Saturate)