heterocl.tvm.intrin module¶
Expression Intrinsics and math functions in TVM.
-
call_intrin
(dtype, func_name, *args)[source]¶ Build expression by calling an intrinsic function.
Intrinsics can be overloaded with multiple data types via the intrinsic translation rule.
-
call_packed
(*args)[source]¶ Build expression by call an external packed function.
The argument to packed function can be Expr or Buffer. The argument is the corresponding POD type when Expr is presented.
When the argument is Buffer, the corresponding PackedFunc will recieve an TVMArrayHandle whose content is valid during the callback period. If the PackedFunc is a python callback, then the corresponding argument is NDArray.
- Parameters
args (list of Expr or Buffer.) – Positional arguments.
- Returns
call – The call expression.
- Return type
See also
tvm.extern()
Create tensor with extern function call.
-
call_pure_extern
(dtype, func_name, *args)[source]¶ Build expression by calling a pure extern function.
-
call_pure_intrin
(dtype, func_name, *args)[source]¶ Build expression by calling a pure intrinsic function.
Intrinsics can be overloaded with multiple data types via the intrinsic translation rule.
-
register_intrin_rule
(target, intrin, f=None, override=False)[source]¶ Register an intrinsic function generation rule.
Intrinsic generation rules are callback functions for code generator to get device specific calls. This function simply translates to.
register_func("tvm.intrin.rule.%s.%s" % (target, intrin), f, override)
TVM may already pre-register intrinsic rules in the backend. However, user can use this function to change the intrinsic translation behavior or add new intrinsic rules during runtime.
- Parameters
- Returns
fregister – Register function if f is not specified.
- Return type
function
Examples
The following code registers exp expansion rule for opencl.
register_intrin_rule("opencl", "exp", my_exp_rule, override=True)