xf::dsp::aie::func_approx::getSqrt - 2024.2 English - XD160

Vitis Libraries

Document ID
XD160
Release Date
2024-11-29
Version
2024.2 English
#include "aie/func_approx_fns.hpp"
template <
    typename T_D,
    typename T_L
    >
void xf::dsp::aie::func_approx::getSqrt (
    T_L* lut_values,
    const int coarseBits,
    const int fineBits,
    const int domainMode,
    const int shift
    )

getSqrt is a utility function that creates a lookup table for approximating the square-root function of x. The recommended domainMode (TP_DOMAIN_MODE) for getSqrt is 2.

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.

Parameters:

T_D Describes the type of data that will be input to the func_approx .
T_L Describes the type of the values stored in the lookup table. This should be equal to T_D unless T_D is bfloat16, in which case T_L should be float.
lut_values A pointer to the area where the lookup table of slope and offset values will be created.
coarseBits Describes the number of bits in a sample of input data that will be used to address the provided lookup table. It determines the total number of locations in the lookup table.
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 locations. This is only applicable to lookup tables with an integer type offset value.