tvm
Loading...
Searching...
No Matches
Classes | Functions
tvm::codegen::intrin Namespace Reference

Classes

struct  Direct
 Preserve the intrinsic name for every primitive type. More...
 
struct  FloatSuffix
 Append f for scalar float32, preserve scalar float64, and reject other types. More...
 

Functions

template<typename T , bool dtype_from_arg = false>
PrimExpr DispatchPureExtern (const PrimExpr &e, const Target &target)
 Dispatch pure extern function.
 
TVM_TIRX_DLL PrimExpr DispatchFastErf (const PrimExpr &e, const Target &target)
 Lower a unary float16/float32 erf call to a rational approximation. The expansion clamps the input to [-4, 4] and evaluates numerator and denominator polynomials using the input element width; other types are rejected.
 
TVM_TIRX_DLL PrimExpr DispatchNumericallyStableTanh (const PrimExpr &e, const Target &target)
 Lower a unary floating-point tanh call using sign-dependent exponential formulas. The expansion avoids the large-positive-input overflow of the symmetric formula; accuracy follows the floating-point arithmetic and exponential lowering in use.
 

Function Documentation

◆ DispatchFastErf()

TVM_TIRX_DLL PrimExpr tvm::codegen::intrin::DispatchFastErf ( const PrimExpr &  e,
const Target &  target 
)

Lower a unary float16/float32 erf call to a rational approximation. The expansion clamps the input to [-4, 4] and evaluates numerator and denominator polynomials using the input element width; other types are rejected.

◆ DispatchNumericallyStableTanh()

TVM_TIRX_DLL PrimExpr tvm::codegen::intrin::DispatchNumericallyStableTanh ( const PrimExpr &  e,
const Target &  target 
)

Lower a unary floating-point tanh call using sign-dependent exponential formulas. The expansion avoids the large-positive-input overflow of the symmetric formula; accuracy follows the floating-point arithmetic and exponential lowering in use.

◆ DispatchPureExtern()

template<typename T , bool dtype_from_arg = false>
PrimExpr tvm::codegen::intrin::DispatchPureExtern ( const PrimExpr &  e,
const Target &  target 
)
inline

Dispatch pure extern function.

Parameters
eThe call expression.
targetThe explicit compilation target.
Template Parameters
TName mapper with std::string operator()(const PrimType&, std::string). The mapper receives the type and the intrinsic name without its prim. or tirx. prefix. An empty mapped name leaves the original call unchanged.

For example, an off-tree backend can register a C math mapping with OpDef("prim.exp").set_attr<tirx::FLowerIntrinsic>( "my_backend.FLowerIntrinsic", DispatchPureExtern<FloatSuffix>) after including tvm/tirx/op/attr.h.

Template Parameters
dtype_from_argUse the argument type of a unary call instead of its result type.