Overview - 2024.2 English - XD160

Vitis Libraries

Document ID
XD160
Release Date
2024-11-29
Version
2024.2 English

func_approx is a utility that provides an approximation of f(x) for a given input data, x.

These are the templates to configure the function:

Parameters:

TT_DATA

Describes the type of individual data samples input to the function.

This is a typename and must be one of the following:

  • int16, int32, and float for AIE
  • int16, int32, float, and bfloat16 for AIE-ML
TP_COARSE_BITS 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.
TP_FINE_BITS Describes the number of bits in an input data sample used for fine interpolation.
TP_DOMAIN_MODE

Specifies a mode for the input domain of the chosen function for approximation.

There are three modes available:

  • TP_DOMAIN_MODE = 0: Domain of input, x, is from 0 to 1
  • TP_DOMAIN_MODE = 1: Domain of input, x, is from 1 to 2. (The most significant TP_COARSE_BITS bit must be set to zero and will be ignored when addressing the lookup *table. Refer to the Function Approximation User Guide for more information)
  • TP_DOMAIN_MODE = 2: Domain of input, x, is from 1 to 4
TP_WINDOW_VSIZE

Describes the number of samples to be processed in each call to this function.

Configurations that are not supported by the lookup table API functions (all data types on AIE1, and int32 and float on AIE-ML) will require memory for two additional internal buffers of size TP_WINDOW_VSIZE.

TP_SHIFT Describes the number of bits to downshift the final output approximation.
TP_RND

Describes the selection of rounding to be applied during the shift down stage of processing.

Although TP_RND accepts unsigned integer values, descriptive macros are recommended:

  • rnd_floor = Truncate LSB, always round down (towards negative infinity).

  • rnd_ceil = Always round up (towards positive infinity).

  • rnd_sym_floor = Truncate LSB, always round towards 0.

  • rnd_sym_ceil = Always round up towards infinity.

  • rnd_pos_inf = Round halfway towards positive infinity.

  • rnd_neg_inf = Round halfway towards negative infinity.

  • rnd_sym_inf = Round halfway towards infinity (away from zero).

  • rnd_sym_zero = Round halfway towards zero (away from infinity).

  • rnd_conv_even = Round halfway towards the nearest even number.

  • rnd_conv_odd = Round halfway towards the nearest odd number.

    No rounding is performed on ceil or floor mode variants.

    Other modes round to the nearest integer. They differ only in how they round for values of 0.5.

    Note: Rounding modes rnd_sym_floor and rnd_sym_ceil are only supported on the AIE-ML device.

TP_SAT

Describes the selection of saturation to be applied during the shift down stage of processing.

TP_SAT accepts unsigned integer values, where:

  • 0: none = No saturation is performed, and the value is truncated on the MSB side.
  • 1: saturate = Default. Saturation rounds an n-bit signed value in the range [- (2^(n-1)) : +2^(n-1) - 1].
  • 3: symmetric = Controls symmetric saturation. Symmetric saturation rounds an n-bit signed value in the range [- (2^(n-1) - 1) : +2^(n-1) - 1].
template <
    typename TT_DATA,
    unsigned int TP_COARSE_BITS,
    unsigned int TP_FINE_BITS,
    unsigned int TP_DOMAIN_MODE,
    unsigned int TP_WINDOW_VSIZE,
    unsigned int TP_SHIFT,
    unsigned int TP_RND,
    unsigned int TP_SAT
    >
class func_approx_graph: public graph

// typedefs

typedef std::conditional <std::is_same <TT_DATA, bfloat16>::value, float, TT_DATA>::type TT_LUT

// fields

port_array <input, 1> in
port_array <output, 1> out
kernel m_kernel[1]
std::vector <TT_LUT> lut_ab
std::vector <TT_LUT> lut_cd