AI Engine-ML Intrinsics User Guide (v2024.2)
|
Pack/unpack operations convert between two representations of vector types.
Vector packing operations | |||
These intrinsics perform saturation based on the control register here: Control Register. Rounding is not done. No status flags are updated.
| |||
v32int8 | pack (v32int16 v) | ||
v32uint8 | pack (v32uint16 v) | ||
v64int4 | pack (v64int8 v) | ||
v64uint4 | pack (v64uint8 v) | ||
v32int8 | pack_conf (v32int16 v, crsat_t sat) | ||
v32uint8 | pack_conf (v32uint16 v, crsat_t sat) | ||
v64int4 | pack_conf (v64int8 v, crsat_t sat) | ||
v64uint4 | pack_conf (v64uint8 v, crsat_t sat) | ||
Vector unpacking operations | |||
| |||
v32int16 | unpack (v32int8 v) | ||
v32uint16 | unpack (v32uint8 v) | ||
v64int8 | unpack (v64int4 v) | ||
v64uint8 | unpack (v64uint4 v) | ||
Vector packing operations (dynamic sign) | |||||
These intrinsics perform saturation based on the control register here: Control Register. Rounding is not done. No status flags are updated. The v = {0b0000000011111111, ...}
assert pack(v, true)[0] == 0b01111111
assert pack(v, false)[0] == 0b11111111
# Reasoning:
# v is signed 255, truncating will result in -128 so the top bit is truncated to give INT_MAX for 8b (127) == 0b01111111
# v is unsigned so just truncate and saturate the value == 0b11111111
| |||||
v32int8 | pack (v32int16 v, int sign) | ||||
v32uint8 | pack (v32uint16 v, int sign) | ||||
v64int4 | pack (v64int8 v, int sign) | ||||
v64uint4 | pack (v64uint8 v, int sign) | ||||
v32int8 | pack_conf (v32int16 v, int sign, crsat_t sat) | ||||
v32uint8 | pack_conf (v32uint16 v, int sign, crsat_t sat) | ||||
v64int4 | pack_conf (v64int8 v, int sign, crsat_t sat) | ||||
v64uint4 | pack_conf (v64uint8 v, int sign, crsat_t sat) | ||||
Vector unpacking operations (dynamic sign) | |||||
These intrinsics perform saturation based on the control register here: Control Register. Rounding is not done. No status flags are updated. The v = {0b11111111, ...}
assert unpack(v, true)[0] == 0b1111111111111111
assert unpack(v, false)[0] == 0b0000000011111111
# Reasoning:
# true means v is signed so -1_8b should extend to -1_16b == 0b1111111111111111
# false means v is unsigned so 0b11111111 is 255_8b and should stay 255 in 16b == 0b0000000011111111
| |||||
v32int16 | unpack (v32int8 v, uint1_t sign) | ||||
v32uint16 | unpack (v32uint8 v, uint1_t sign) | ||||
v64int8 | unpack (v64int4 v, uint1_t sign) | ||||
v64uint8 | unpack (v64uint4 v, uint1_t sign) | ||||