AI Engine API User Guide (AIE) 2022.1
|
Type to support a linear approximation via interpolation with slope/offset values stored in a lookup table.
The logical steps of the computation are:
Input | Offset | Slope | Accumulator type |
---|---|---|---|
int8 | int8 | int8 | acc32 |
int16 | int16 int32 | int16 int32 | acc64 |
bfloat16 | float | bfloat16 | accfloat |
T | Type of the input vector, containing values used to index the lookup table. |
MyLUT | Definition of the LUT type, using the lut type. |
#include <aie.hpp>
Public Member Functions | |
linear_approx (const MyLUT &l, unsigned step_bits, int bias=0, int shift_offset=0) | |
More... | |
template<Vector Vec> | |
auto | compute (const Vec &input) |
More... | |
|
inline |
Constructor, configures aspects of how the approximation is performed.
l | LUT containing the stored slope/offset value pairs used for the linear approximation. Each value in the LUT has the slope in the LSB, the offset in the MSB. |
step_bits | Lower bits that won't be used from the input to index the LUT, these will be the remainder multiplied by the slope value at each point. |
bias | Optional offset added to the input values used to index, for example to center on 0 by adding half the number of LUT elements. |
shift_offset | Optional scaling factor applied to the offset before adding it (to avoid loss of precision). |
|
inline |
Performs a linear approximation for the input values with the configured lookup table. An accumulator of the same number of elements as the input is returned.
Input values are interpreted from MSB to LSB: headroom | LUT elements | step_bits
input | Vector of input values that are used to index the look-up table. |