Overview - 2025.2 English

Vitis Libraries

Release Date
2026-02-09
Version
2025.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].
TP_USE_LUT_RELOAD

allows the user to select if runtime lookup table reloading should be used. When defining the parameter:

  • 0 = static lookup tables, defined in graph constructor

  • 1 = reloadable lookup tables, passed as argument to runtime update function via RTP ports

    Note: when used, there will be two async RTP ports ( rtpLut ). Both should be updated with the same lookup *values.

    Note: AIE-ML and AIE-MLv2 devices with TT_DATA of int16 or bfloat16 support parallel access of 4 for the LUTs, requiring duplication of every 128 bits (AIE-ML) or 256 bits (AIE-MLv2).

    Note: It is recommended to use the update_rtp graph method to update LUTs at runtime, which handles duplication automatically and both RTP ports.

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,
    unsigned int TP_USE_LUT_RELOAD = 0
    >
class func_approx_graph: public graph

// typedefs

typedef std::conditional <std::is_same <TT_DATA, bfloat16>::value, float, TT_DATA>::type TT_LUT
typedef port_conditional_array <input, (TP_USE_LUT_RELOAD==1), rtpPortsPerKernel> rtp_port_array

// fields

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