Primitive functions that contains TIR statements.
More...
#include <function.h>
|
| bool | SEqual (const PrimFuncNode *other, ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> equal) const |
| |
| int64_t | SHash (int64_t init_hash, ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> hash) const |
| |
| FuncType | func_type_annotation () const |
| | Return the derived function annotation of this function. More...
|
| |
| | TVM_FFI_DECLARE_OBJECT_INFO_FINAL ("tirx.PrimFunc", PrimFuncNode, BaseFuncNode) |
| |
| template<typename TObjectRef > |
| ffi::Optional< TObjectRef > | GetAttr (const std::string &attr_key, ffi::Optional< TObjectRef > default_value=std::nullopt) const |
| | Get a function attribute. More...
|
| |
| template<typename TObjectRef > |
| ffi::Optional< TObjectRef > | GetAttr (const std::string &attr_key, TObjectRef default_value) const |
| |
| bool | HasNonzeroAttr (const std::string &attr_key) const |
| | Check whether the function has an non-zero integer attr. More...
|
| |
| LinkageType | GetLinkageType () const |
| | Get the type of the linkage. More...
|
| |
| | TVM_FFI_DECLARE_OBJECT_INFO ("ir.BaseFunc", BaseFuncNode, ExprNode) |
| |
| | TVM_FFI_DECLARE_OBJECT_INFO ("ir.Expr", ExprNode, ffi::Object) |
| |
Primitive functions that contains TIR statements.
The PrimFunc provides low-level code representation does not automatically manage
- See also
- PrimFunc
◆ func_type_annotation()
| FuncType tvm::tirx::PrimFuncNode::func_type_annotation |
( |
| ) |
const |
Return the derived function annotation of this function.
- Returns
- The function type annotation.
- Note
- The function type annotation of PrimExpr is directly derived from the Vars without the need of type inference.
◆ RegisterReflection()
| static void tvm::tirx::PrimFuncNode::RegisterReflection |
( |
| ) |
|
|
inlinestatic |
◆ SEqual()
| bool tvm::tirx::PrimFuncNode::SEqual |
( |
const PrimFuncNode * |
other, |
|
|
ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> |
equal |
|
) |
| const |
|
inline |
◆ SHash()
| int64_t tvm::tirx::PrimFuncNode::SHash |
( |
int64_t |
init_hash, |
|
|
ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> |
hash |
|
) |
| const |
|
inline |
◆ TVM_FFI_DECLARE_OBJECT_INFO_FINAL()
◆ body
The body of the function.
◆ buffer_map
Maps some parameters to specific Buffer data structures.
buffer_map provides a way to express data structure's field and shape constraints. The provided information is used in the program analysis and the code generation.
- It defines the vars in the Buffer (m, n) in the cases below when they appears in the buffer_map for the first time.
- When a var appears multiple times, they translate into runtime assertion to check the field constraint.
# The corresponding fields of f are as follows
#
# - f.params = [a, b]
# - f.buffer_map = {a: A, b: B}
# - A = decl_buffer(shape=[m, n])
# - B = decl_buffer(shape=[m, n])
def f(a, b):
A = bind_buffer(a,
shape=[m, n])
B = bind_buffer(b,
shape=[m, n])
tirx::Stmt body
The body of the function.
Definition: function.h:102
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
Tensor shape(const Tensor &src, PrimType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:2010
buffer_map is a sugar to express:
- Parameter unpacking: e.g. I can load a.shape[0] to get value of m
- Constraint checking: a.shape[0] must equal b.shape[0] because they both corresponds to m.
While we could have express parameter unpacking and constraint using normal statements, making buffer_map as first class citizen of PrimFunc will make program analysis much easier.
Prior to buffer flattening, which is performed FlattenBuffer for TIR-based schedules, these buffer objects are used directly in the body of the function. After buffer flattening, these buffer objects remain unflattened for use in argument validation, but all usage in the body of the function is done through a flattened alias of the buffer.
◆ params
| ffi::Array<tirx::Var> tvm::tirx::PrimFuncNode::params |
◆ ret_type
The return type of the function.
The documentation for this class was generated from the following file: