tvm_tirx.ir#

Shared IR types, expressions, statements, source locations, and modules.

Namespaces#

Location#

SourceName(name)

An identifier for a source location.

Location()

Non-null source-location metadata attached to IR nodes.

SourceLoc(source_name, start_line, ...)

A source range with unchanged frontend coordinate units and endpoints.

UnknownLoc()

The canonical immutable location used when source information is unavailable.

CallSiteLoc(callee, caller)

A callee's source location together with its caller's location.

Type#

AnyType([loc])

The top type, which admits any value.

FuncType(arg_types, ret_type)

Function type.

MissingType()

Type information that has not been supplied or computed.

NoneType()

The concrete type whose only value is None.

OpaqueType()

Type marker for opaque values that must be removed from finished IR.

PtrType(element_type[, scope, loc])

A pointer to an element type in a specified memory scope.

PrimType(dtype)

A primitive scalar or vector data type, including the void sentinel.

StringType()

Semantic string type, independent of the function's calling convention.

TensorRegionType()

The type of a multi-dimensional tvm_tirx.ir.TensorRegion.

TupleType(fields[, loc])

The type of tuple values.

Type()

The base class of all types.

Expr#

Call(op, args[, attrs, ty_args, loc, ty])

Call a registered operator or another callable IR expression.

IntImm(ty, value[, loc])

Int constant.

FloatImm(ty, value[, loc])

Float constant.

Constant([loc, ty])

Base class of literal constants.

GenericConst(ty, value[, loc])

A literal payload with an explicit expression type.

DataTypeImm(value[, loc])

A data type literal whose expression type is AnyType.

StringImm(value[, loc])

A string literal with StringType.

Expr([loc, ty])

Base class of typed IR expressions.

GlobalVar(name_hint[, loc])

A global variable in the IR.

LambdaExpr(parameter_types, function, *[, ...])

A typed staging expression representing a lambda computation.

StagingExpr([loc, ty])

A traversable expression eliminated before executable IR.

OpaqueExpr([loc, ty])

Base class for opaque values that must be removed from finished IR.

TensorLoad(source, indices[, loc])

Load an element or vector from an indexed expression source.

TensorRegion(source, region, ty[, loc])

A region of an arbitrary tensor expression.

Tuple(fields[, loc])

Tuple expression that groups several fields together.

TupleGetItem(tuple_value, index[, loc])

Get the index-th item from a tuple.

Var([name, ty, loc, name_hint])

A canonical local variable in the IR.

BaseFunc(attrs[, loc, ty])

Base class for callable IR function definitions.

Op()

A registered primitive operator used as a Call callee.

OpAttrMap(attr_name, column)

The values of one operator attribute, keyed by operator.

Stmt#

Stmt(loc)

Base class of all the statements.

SeqStmt(seq[, loc])

Sequence of statements.

Bind(var, value[, loc])

Bind node.

Evaluate(value[, loc])

Evaluate an expression for its effects and discard its result.

Return(value[, loc])

Exit the enclosing function with a return value.

If(condition, then_case, else_case[, loc])

Execute one branch according to a boolean condition.

For(var, begin, end, step, kind, body[, ...])

Iterate from begin while below end, incrementing by step.

While(condition, body[, loc])

Repeat the body while the condition evaluates to true.

Break([loc])

Exit the innermost enclosing loop.

Continue([loc])

Skip to the next iteration of the innermost enclosing loop.

AssertStmt(condition, error_kind[, ...])

Check a condition and raise the specified error when it is false.

RegionStmt(op, args, body_params, attrs, body)

An operation with enclosing-scope operands and one lexical body.

TensorStore(dest, indices, value[, loc])

Store a primitive value into a tensor destination.

IRModule#

IRModule([functions, attrs, global_infos])

A collection of global functions and module-level metadata.

Supporting classes#

Attrs()

Base class for structured operator and function attributes.

DictAttrs(dict)

A string-keyed attribute map for functions, modules, and calls.

EnvFunc(name, func)

A registered global function referenced and serialized by name.

Node

Base class of all IR Nodes.

Range(begin[, end, loc])

A half-open interval stored as begin and extent.

GlobalInfo()

Base class for module-level information referenced by the IR.

Operator functions (tvm_tirx.ir.prim)#

abs(x[, loc])

Get absolute value of the input element-wise.

acos(x, *[, ty, loc])

Take acos of input x.

acosh(x, *[, ty, loc])

Take acos of input x.

all(*args[, loc])

Create a new expression of the intersection of all conditions in the

any(*args[, loc])

Create a new experssion of the union of all conditions in the arguments

asin(x, *[, ty, loc])

Take asin of input x.

asinh(x, *[, ty, loc])

Take asinh of input x.

assume([cond, ty, loc])

Provide a true statement that can be used for simplifications

atan(x, *[, ty, loc])

Take atan of input x.

atan2(x1, x2, *[, ty, loc])

Take arctan2(x1, x2).

atanh(x, *[, ty, loc])

Take atanh of input x.

bitwise_and(x, y[, loc])

Take bitwise and of two values

bitwise_not(x[, loc])

Take bitwise not of input value

bitwise_or(x, y[, loc])

Take bitwise or of two values

bitwise_xor(x, y[, loc])

Take bitwise xor of two values

ceil(x[, loc])

Take ceil of float input x.

ceildiv(lhs, rhs[, loc])

Generic ceildiv operator.

clz(x)

Count leading zero bits of an integer x.

copysign(x1, x2, *[, ty, loc])

Change the sign of x1 to that of x2, element-wise.

cos(x, *[, ty, loc])

Take cos of input x.

cosh(x, *[, ty, loc])

Take cosh of input x.

div(a, b[, loc])

Compute a / b as in C/C++ semantics.

erf(x, *[, ty, loc])

Take gauss error function of the input x.

exp(x, *[, ty, loc])

Take exponential of input x.

exp2(x, *[, ty, loc])

Calculate 2**x

exp10(x, *[, ty, loc])

Calculate 10**x

floor(x[, loc])

Take floor of float input x.

floordiv(a, b[, loc])

Compute the floordiv of two expressions.

floormod(a, b[, loc])

Compute the floormod of two expressions.

fma(x, y, z, *[, ty, loc])

Take fused multiply-add of input x, y, z.

fmod(x, y, *[, ty, loc])

Return the remainder of x divided by y with the same sign as x.

hypot(x1, x2, *[, ty, loc])

Equivalent to sqrt(x1**2 + x2**2), element-wise.

if_then_else(cond, t, f[, loc])

Conditional selection expression.

indexdiv(a, b[, loc])

Compute floor(a / b) where a and b are non-negative.

indexmod(a, b[, loc])

Compute the remainder of indexdiv.

isfinite(x[, loc])

Check if input value is finite.

isinf(x[, loc])

Check if input value is infinite.

isnan(x[, loc, ty])

Check if input value is Nan.

ldexp(x1, x2, *[, ty, loc])

Returns x1 * (2 ** x2).

likely(cond[, loc])

Mark condition as likely.

log(x, *[, ty, loc])

Take log of input x.

log1p(x, *[, ty, loc])

Take log(x + 1) with respect to input x.

log2(x, *[, ty, loc])

Take log2 of input x.

log10(x, *[, ty, loc])

Take log10 of input x.

max(a, b[, loc])

Elementwise maximum of two primitive expressions.

min(a, b[, loc])

Elementwise minimum of two primitive expressions.

nearbyint(x[, loc])

Round elements of the array to the nearest integer.

nextafter(x1, x2, *[, ty, loc])

Return the next floating-point value after x1 towards x2.

popcount(x, *[, ty, loc])

Count the number of set bits in input x.

pow(x, y[, loc])

x power y

power(x, y[, loc])

x power y

round(x[, loc])

Round elements of the array to the nearest integer.

rsqrt(x, *[, ty, loc])

Take reciprocal of square root of input x.

shift_left(x, y[, loc])

Return the result of x left shifted by y bits.

shift_right(x, y[, loc])

Return the result of x right shifted by y bits.

sigmoid(x, *[, ty, loc])

Quick function to get sigmoid

sin(x, *[, ty, loc])

Take sin of input x.

sinh(x, *[, ty, loc])

Take sinh of input x.

sqrt(x, *[, ty, loc])

Take square root of input x.

tan(x, *[, ty, loc])

Take tan of input x.

tanh(x, *[, ty, loc])

Take hyperbolic tanh of input x.

trunc(x[, loc])

Get truncated value of the input.

truncdiv(a, b[, loc])

Compute the truncdiv of two expressions.

truncmod(a, b[, loc])

Compute the truncmod of two expressions.

vscale(*[, ty, loc])

Get the target's vscale value.

IR helpers#

const(value[, ty, loc, dtype])

Construct a constant with an explicit or inferred primitive type.

format_tree(value, *[, fold, expand, hide, ...])

Display an object's fields as a text tree.

make_node(type_key, /, **kwargs)

Make a new IR node by its type key and fields

assert_structural_equal(lhs, rhs[, ...])

Assert lhs and rhs are structurally equal to each other.

load_json(json_str)

Load tvm object from json_str.

save_json(node)

Save tvm object as json string.

is_prim_expr(value)

Return whether an expression has a primitive result type.

is_prim_var(value)

Return whether a value is an ordinary variable with a primitive type.

reinfer_type(call)

Derive a Call's result type from its current inputs without changing the Call.

register_op_attr(op_name, attr_key[, value, ...])

Register an operator property of an operator by name.

stmt_seq(*args)

Make sequence of statements

Supporting functions#

register_script_printer(*, script, show, ...)

Attach shared printer behavior without replacing native IR wrappers.

register_dialect_script_method(name, method)

Register a dialect-owned private printing convenience method.

Tree Formatting Defaults#

tvm_tirx.ir.DEFAULT_FOLD#

Tuple of field selectors to inline with their parent by default.

tvm_tirx.ir.DEFAULT_EXPAND#

Tuple of field selectors to expand explicitly by default. This is empty because objects already expand unless a rule folds or hides them.

tvm_tirx.ir.DEFAULT_HIDE#

Tuple of field selectors to omit by default.

tvm_tirx.ir.DEFAULT_FOLD_FORMATTERS#

Standard folded representations, keyed by class. Callbacks take an object and return single-line text.