AI Engine API User Guide (AIE) 2022.1
aie::linear_approx< T, MyLUT > Struct Template Reference

Detailed Description

template<typename T, ParallelLUT MyLUT>
struct aie::linear_approx< T, MyLUT >

Type to support a linear approximation via interpolation with slope/offset values stored in a lookup table.

The logical steps of the computation are:

  • index = floor(input / step) + bias
  • slope/offset pair read from LUT based on index
  • output = slope * (input % step_bits) + (offset << shift_offset)
Supported linear approximation types
InputOffsetSlopeAccumulator type
int8int8 int8 acc32
int16int16
int32
int16
int32
acc64
bfloat16floatbfloat16 accfloat
Template Parameters
TType of the input vector, containing values used to index the lookup table.
MyLUTDefinition 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...
 

Constructor & Destructor Documentation

◆ linear_approx()

template<typename T , ParallelLUT MyLUT>
aie::linear_approx< T, MyLUT >::linear_approx ( const MyLUT &  l,
unsigned  step_bits,
int  bias = 0,
int  shift_offset = 0 
)
inline

Constructor, configures aspects of how the approximation is performed.

Parameters
lLUT 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_bitsLower 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.
biasOptional offset added to the input values used to index, for example to center on 0 by adding half the number of LUT elements.
shift_offsetOptional scaling factor applied to the offset before adding it (to avoid loss of precision).

Member Function Documentation

◆ compute()

template<typename T , ParallelLUT MyLUT>
template<Vector Vec>
auto aie::linear_approx< T, MyLUT >::compute ( const Vec &  input)
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

Parameters
inputVector of input values that are used to index the look-up table.

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