tvm_tirx.tirx.Function#
- class tvm_tirx.tirx.Function(params, body, ret_type=None, attrs=None, loc=UNKNOWN_LOC)#
Bases:
BaseFunc,ScriptableA TIRx function definition or declaration.
The function’s
tyis a FuncType derived from parameter types andret_type. The body is normalized to a SeqStmt. A declaration has an empty body and thedeclarationattribute set to True.- Parameters:
params (list[tvm_tirx.ir.Var]) – Input parameters, in calling order.
body (Stmt or Sequence[Stmt]) – The function body. An empty sequence is a valid body.
ret_type (tvm_tirx.ir.Type, optional) – The declared return type. Omitting it or supplying MissingType produces an empty TupleType, the type returned by the C++ VoidType() helper. Construction does not infer a return type from the body.
attrs (tvm_tirx.ir.DictAttrs, optional) – Function attributes, empty by default.
loc (Location, optional) – The source location of the function.
- property body#
- with_body(new_body, loc=UNKNOWN_LOC)#
Create a function with the same parameters, return type, and attributes but a new body.
- property params#
- property ret_type#
- Function.expr_ty()#
Return this expression’s primitive result type.
- Function.script(*, name=None, show_meta=False, int_dtype='int32', float_dtype='void', verbose_expr=False, indent_spaces=4, print_line_numbers=False, num_context_lines=-1, path_to_underline=None, path_to_annotate=None, obj_to_underline=None, obj_to_annotate=None, extra_config=None)#
Print TVM IR into TVMScript text format
- Parameters:
name (Optional[str] = None) – The name of the object
show_meta (bool = False) – Whether to print the meta data of the object
int_dtype (str = "int32") – The default data type of integer
float_dtype (str = "void") – The default data type of float
verbose_expr (bool = False) – Whether to print the detailed definition of each variable in the expression
indent_spaces (int = 4) – The number of spaces for indentation
print_line_numbers (bool = False) – Whether to print line numbers
num_context_lines (int = -1) – The number of lines of context to print before and after the line to underline.
path_to_underline (Optional[List[AccessPath]] = None) – Object path to be underlined
path_to_annotate (Optional[Dict[AccessPath, str]] = None) – Object path to be annotated
obj_to_underline (Optional[List[tvm_ffi.Object]] = None) – Object to be underlined
obj_to_annotate (Optional[Dict[tvm_ffi.Object, str]] = None) – Object to be annotated
extra_config (Optional[dict] = None) – Dialect-specific configuration passed through to PrinterConfig.extra_config, including
ir.prefixfor the IR namespace alias (default"I"). Keys are conventionally namespaced as “<dialect>.<knob>”, e.g.{"tirx.prefix": "T"}.
- Returns:
script (str) – The TVM Script of the given TVM IR
- Return type:
str
- Function.show(style=None, *, name=None, show_meta=False, int_dtype='int32', float_dtype='void', verbose_expr=False, indent_spaces=4, print_line_numbers=False, num_context_lines=-1, path_to_underline=None, path_to_annotate=None, obj_to_underline=None, obj_to_annotate=None, extra_config=None)#
Print highlighted TVMScript.
- Parameters:
style (str, optional) – Pygmentize printing style, auto-detected if None. See tvm_tirx.script.printer.highlight.cprint for more details.
name (Optional[str] = None) – The name of the object
show_meta (bool = False) – Whether to print the meta data of the object
int_dtype (str = "int32") – The default data type of integer
float_dtype (str = "void") – The default data type of float
verbose_expr (bool = False) – Whether to print the detailed definition of each variable in the expression
indent_spaces (int = 4) – The number of spaces for indentation
print_line_numbers (bool = False) – Whether to print line numbers
num_context_lines (int = -1) – The number of lines of context to print before and after the line to underline.
path_to_underline (Optional[List[AccessPath]] = None) – Object path to be underlined
path_to_annotate (Optional[Dict[AccessPath, str]] = None) – Object path to be annotated
obj_to_underline (Optional[List[tvm_ffi.Object]] = None) – Object to be underlined
obj_to_annotate (Optional[Dict[tvm_ffi.Object, str]] = None) – Object to be annotated
extra_config (Optional[dict] = None) – Dialect-specific configuration passed through to PrinterConfig.extra_config, including
ir.prefixfor the IR namespace alias (default"I").
- Return type:
None