24#ifndef TVM_CODEGEN_INTRIN_RULE_H_
25#define TVM_CODEGEN_INTRIN_RULE_H_
27#include <tvm/ffi/container/array.h>
28#include <tvm/ffi/dtype.h>
44 if (ty->dtype == DLDataType{kDLFloat, 32, 1}) {
46 }
else if (ty->dtype == DLDataType{kDLFloat, 64, 1}) {
73template <
typename T,
bool dtype_from_arg = false>
76 TVM_FFI_ICHECK(call !=
nullptr);
79 TVM_FFI_ICHECK(op !=
nullptr);
80 std::string name = op->
name;
81 TVM_FFI_ICHECK(name.substr(0, 5) ==
"prim.") <<
"Unexpected intrinsic name: " << name;
83 TVM_FFI_ICHECK_EQ(call->
args.size(), 1U);
87 name = T()(type, name.substr(5));
90 ffi::Array<Expr> new_args = {
StringImm(name)};
91 for (
const PrimExpr& arg : call->
args.as_or_throw<ffi::Array<PrimExpr>>()) {
92 new_args.push_back(arg);
Canonical primitive operators and their registration.
#define TVM_TIRX_DLL
Definition base.h:55
Call corresponds to callable invocation.
Definition expr.h:788
Expr op
The operator/function being invoked.
Definition expr.h:799
ffi::Array< Expr > args
The arguments of the call.
Definition expr.h:802
Managed reference to CallObj.
Definition expr.h:825
Type ty
The deduced or annotated type of the expression.
Definition expr.h:80
Metadata for a canonical primitive operator invoked through Call.
Definition op.h:77
ffi::String name
Canonical operator name.
Definition op.h:84
Typed reference/view over any Expr whose ExprObj::ty is PrimType.
Definition expr.h:187
Managed reference to a string literal.
Definition expr.h:278
Managed reference class to TargetObj.
Definition target.h:155
ExpectedType ty() const
Definition expr.h:164
PrimExpr DispatchPureExtern(const PrimExpr &e, const Target &target)
Dispatch pure extern function.
Definition intrin_rule.h:74
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...
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 avoid...
TVM_TIRX_DLL const Op & call_pure_extern_op()
Call a pure external C function with types supplied by the caller.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Preserve the intrinsic name for every primitive type.
Definition intrin_rule.h:55
std::string operator()(const PrimType &ty, std::string name) const
Definition intrin_rule.h:56
Append f for scalar float32, preserve scalar float64, and reject other types.
Definition intrin_rule.h:42
std::string operator()(const PrimType &ty, std::string name) const
Definition intrin_rule.h:43
Compilation target object.