Skip to main content

Module ir

Module ir 

Source
Expand description

The IR shared by every dialect. Expressions (Expr), statements (Stmt) and types (Type) are the three node hierarchies; functions are expressions, and an IRModule binds them to global names, the unit of compilation that the passes of transform rewrite.

Re-exports§

pub use attrs::*;
pub use base::*;
pub use expr::*;
pub use function::*;
pub use global_info::*;
pub use location::*;
pub use module::*;
pub use op::*;
pub use op_def::*;
pub use stmt::*;
pub use type::*;
pub use type_def::*;
pub use unique_name_supply::*;

Modules§

attrs
Attributes. Calls, functions and modules carry metadata as Attrs: a typed attribute object of an operator, or a DictAttrs map of named values.
base
Registry functions held by name. An EnvFunc keeps a registered global function with its name, so IR that refers to it serializes the name and resolves it again when loaded.
dtype
Data types. A [DLDataType] is the DLPack element type of a tensor or a primitive value; these functions build them as plain values, usable in constants, and PrimType is the IR type of one.
expr
Expressions. Every expression is an Expr that carries its type; PrimExpr and IntExpr are expressions known to have a primitive or scalar integer type, the operands of arithmetic (in prim).
function
Functions. Every function is a BaseFunc, an expression that carries the function’s attributes; a dialect defines the function itself, such as Function, and an IRModule binds it to a name.
global_info
Module-level information. A GlobalInfo is information an IRModule holds besides its functions, kept by name in global_infos.
location
Source locations. Every IR node carries a Location for diagnostics: an UnknownLoc, a SourceLoc span in a source, or a CallSiteLoc that pairs a location with its caller’s.
module
Modules. An IRModule is the unit of compilation, the input and output of passes: it maps each GlobalVar to a function (BaseFunc), and carries module attributes and module-level information.
op
Operators. An Op is a registry entry named once per process and called through a Call; OpDef registers one, and an OpAttrMap reads one attribute of every operator, such as its call effect.
op_def
Operator registration. An OpDef registers an Op with a signature of sig descriptors, from which its call validator is generated, and attribute values keyed by an AttrKey, such as the shared ones in op_attr.
prim
Primitive expressions. Each node, such as Add or Ramp, is a PrimExpr whose new only checks its operand types; the functions of op, which operators such as &x + 1 call, also match the operand types and fold constants.
stmt
Statements. Every statement is a Stmt; the body of a loop, conditional or region is a SeqStmt, so a single statement given as a body is wrapped in one, and a Bind binds a variable for the statements after it in the enclosing body.
transform
Pass infrastructure. A Pass transforms an IRModule under the current PassContext, whose instruments observe each pass it runs.
type
Types. Every expression carries a Type; a PrimType types the primitive scalars and vectors that arithmetic works on, and a dialect extends Type with its own kinds, as TensorType does.
type_def
Type registration. An IR type defined in Rust with rs_object calls register_type in a tvm_ffi::static_init_block!, so Python can construct it once its library loads.
unique_name_supply
Unique names. A UniqueNameSupply hands out names that do not collide with the ones it has given out or reserved, for building and rewriting IR.