tvm.script.parser

tvm.script.parser

The parser subpackage of TVMScript.

Per-dialect parser submodules (tvm.script.parser.tirx, etc.) are resolved lazily via tvm.script._DIALECT_REGISTRY. When a dialect is accessed (e.g. tvm.script.parser.tirx), this subpackage’s __getattr__ looks up the dialect in _DIALECT_REGISTRY and imports <dialect_module_path>.parser (e.g. tvm.tirx.script.parser), caching the result so subsequent accesses skip __getattr__.

The IR layer is foundational and is NOT registered as a dialect — its parser lives as a real submodule tvm.script.parser.ir, with ir_module re-exported at this level for convenience.

See tvm.script for a full description of the dialect resolution mechanism, including the _DialectRedirectFinder that handles deep statement-form imports.

tvm.script.parser.parse(program: AST | Any | str, extra_vars: dict[str, Any] | None = None, check_well_formed: bool = True) Any

Register a method for a operand type, AST operator node and operand index.

Parameters:
  • program (Union[doc.AST, Any, str]) – The TVMScript code to parse.

  • extra_vars (Dict[str, Any]) – The extra variable table for parsing.

  • check_well_formed (bool) – Whether to check well-formedness after parsing.

Returns:

func – The parsed TVMScript program.

Return type:

Any

tvm.script.parser.ir_module(mod: type | None = None, check_well_formed: bool = True) IRModule

The parsing method for ir module, by using @ir_module as decorator.

Parameters:
  • mod (Type) – The class to be parsed as ir module.

  • check_well_formed (bool) – Whether to check well-formedness during parsing.

Returns:

ir_module – The parsed ir module.

Return type:

IRModule

tvm.script.parser.ir

The ir module parser

tvm.script.parser.relax

Initial impl of relax parser for sugars

tvm.script.parser.tirx

The tirx parser