AI Engine-ML Intrinsics User Guide  (v2023.2)

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

Overview

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 (in the range 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
}

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
}
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)

Modules

 AIE interface
 
 Floating-point
 
 Size interface
 
get_sat
unsigned int get_sat()
Control for rounding mode (for Shift-Round-Saturate). See Rounding modes for possible values.
Definition: me_set_mode.h:138
max
v64uint8 max(v64uint8 a, v64uint8 b)
Calculates the maximum between two input vectors.
Definition: me_vadd.h:462
get_symsat
unsigned int get_symsat()
Control for rounding mode (for Shift-Round-Saturate). See Rounding modes for possible values.
Definition: me_set_mode.h:139
min
v64uint8 min(v64uint8 a, v64uint8 b)
Calculates the minimum between two input vectors.
Definition: me_vadd.h:397
ups
v16accfloat ups(v16bfloat16)
upd_elem
v64int8 upd_elem(v64int8 v, int idx, char b)
shift
v64int8 shift(v64int8 a, v64int8 b, int shift)
Concatenates a and b, interprets them as a vector of 128 bytes and returns a::b[shift*elem_size:shift...
Definition: me_scl2vec.h:161