xf::dsp::aie::func_approx::getInv - 2025.2 English

Vitis Libraries

Release Date
2025-12-17
Version
2025.2 English
#include "aie/func_approx_fns.hpp"
template <
    typename T_D,
    typename T_L
    >
void xf::dsp::aie::func_approx::getInv (
    T_L* lut_values,
    const int coarseBits,
    const int fineBits,
    const int domainMode,
    const int shift
    )

getInv creates a lookup table for approximating the inverse function 1/x.

This function generates a piecewise linear approximation for the reciprocal function using slope-offset pairs. The recommended domainMode for getInv is 2 (domain 1 ≤ x < 4).

If domainMode = 1, where the input domain is 1 <= x < 2, it is expected that the most significant bit of coarseBits has been set to zero and will be ignored by the function approximation kernel when addressing the lookup table.

This means that the lookup table will be half the size of other domainMode (TP_DOMAIN_MODE) with a similar coarseBits value.

For domainMode values equal to 0 or 2, there are 2 ^ (coarseBits) locations, and when domainMode is equal to 1, there are 2 ^ (coarseBits - 1) locations.

float lut[512]; // 256 slope-offset pairs
getInv<float, float>(lut, 8, 8, 2, 0); // 8-bit addressing, domain [1,4)

Parameters:

T_D Data type that will be input to the func_approx kernel (e.g., int16, int32, float, bfloat16).
T_L Lookup table storage type. Should equal T_D except when T_D is bfloat16, then T_L should be float.
lut_values A pointer to the memory where the lookup table of slope and offset values will be created.
coarseBits

Number of most significant bits used for table indexing. Determines table size:

  • domainMode 0,2: 2^coarseBits locations
  • domainMode 1: 2^(coarseBits-1) locations
fineBits Describes the number of bits in an input data sample used for fine interpolation. It determines the width of each location.
domainMode

The choice of TP_DOMAIN_MODE template parameter. This creates an approximation of f(x) where x is normalized over a specified domain.

This can be:

  • 0 (input domain is 0 <= x < 1)
  • 1 (input domain is 1 <= x < 2)
  • 2 (input domain is 1 <= x < 4).
shift The downward shift value that will be applied to each offset of a location. This is only applicable to lookup tables with an integer type offset value.