Function cinn::lang::CallExtern
Defined in File compute.cc
Function Documentation
-
Expr
cinn::lang
::
CallExtern
(const std::string &target, const std::vector<Expr> &args, const std::map<std::string, attr_t> &attrs = {}) Call an external function and get some tensors as result.
There are two kinds of extern functions distinguished by the return type.
Void, there are one or more mutable tensors in the argument list.
Tensor tuple = Compute({M}, []() { return CallExtern("mkl_gemm", {X, W}); });
To support returning multiple value one time, we include the tuple concept, it is a Tensor with CallOp marked with value_offset(from 0 to num_returns-1).
POD value, return an expression directly, and it can be inline expand in following computations.
Tensor tanh_out = Compute({M}, [](Var i) { return CallExtern("tanh", X(i)); });
Will generate something like
for (i) { gemm_mkl(X[i], gemm_out[i]) }
- Parameters
target
: The name of the function to call.args
: The readonly arguments(while there should be only one tensor as result).attrs
: The readonly attrs.