heterocl.tvm.expr module

Expression AST Node in TVM.

User do not need to deal with expression AST node directly. But they can be helpful for developer to do quick proptyping. While not displayed in the document and python file. Each expression node have subfields that can be visited from python side.

For example, you can use addexp.a to get the left operand of an Add node.

x = tvm.var("n")
y = x + 2
assert(isinstance(y, tvm.expr.Add))
assert(y.a == x)
class Add(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class And(handle)[source]

Bases: heterocl.tvm.expr.LogicalExpr

class BinaryOpExpr(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Broadcast(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Call(handle)[source]

Bases: heterocl.tvm.expr.Expr

Extern = 0
ExternCPlusPlus = 1
Halide = 3
Intrinsic = 4
PureExtern = 2
PureIntrinsic = 5
class Cast(handle)[source]

Bases: heterocl.tvm.expr.Expr

class CmpExpr(handle)[source]

Bases: heterocl.tvm.expr.Expr

class ConstExpr(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Div(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class EQ(handle)[source]

Bases: heterocl.tvm.expr.CmpExpr

class EqualOp(a, b)[source]

Bases: heterocl.tvm._ffi.node_generic.NodeGeneric, heterocl.tvm.expr.ExprOp

Deferred equal operator.

This is used to support sugar that a == b can either mean NodeBase.same_as or NodeBase.equal.

Parameters
  • a (Expr) – Left operand.

  • b (Expr) – Right operand.

asnode()[source]

Convert node.

same_as

Return self==value.

class Expr(handle)[source]

Bases: heterocl.tvm.expr.ExprOp, heterocl.tvm._ffi.node.NodeBase

Base class of all tvm Expressions

class ExprOp[source]

Bases: object

astype(dtype)[source]

Cast the expression to other type.

Parameters

dtype (str) – The type of new expression

Returns

expr – Expression with new type

Return type

Expr

equal(other)[source]

Build an equal check expression with other expr.

Parameters

other (Expr) – The other expression

Returns

ret – The equality expression.

Return type

Expr

class FloatImm(handle)[source]

Bases: heterocl.tvm.expr.ConstExpr

class GE(handle)[source]

Bases: heterocl.tvm.expr.CmpExpr

class GT(handle)[source]

Bases: heterocl.tvm.expr.CmpExpr

class GetBit(handle)[source]

Bases: heterocl.tvm.expr.Expr

class GetSlice(handle)[source]

Bases: heterocl.tvm.expr.Expr

class IntImm(handle)[source]

Bases: heterocl.tvm.expr.ConstExpr

class KernelExpr(handle)[source]

Bases: heterocl.tvm.expr.Expr

class LE(handle)[source]

Bases: heterocl.tvm.expr.CmpExpr

class LT(handle)[source]

Bases: heterocl.tvm.expr.CmpExpr

class Let(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Load(handle)[source]

Bases: heterocl.tvm.expr.Expr

class LogicalExpr(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Max(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class Min(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class Mod(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class Mul(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class NE(handle)[source]

Bases: heterocl.tvm.expr.CmpExpr

class Not(handle)[source]

Bases: heterocl.tvm.expr.LogicalExpr

class NotEqualOp(a, b)[source]

Bases: heterocl.tvm._ffi.node_generic.NodeGeneric, heterocl.tvm.expr.ExprOp

Deferred NE operator.

This is used to support sugar that a != b can either mean not NodeBase.same_as or make.NE.

Parameters
  • a (Expr) – Left operand.

  • b (Expr) – Right operand.

asnode()[source]

Convert node.

same_as

Return self==value.

class Or(handle)[source]

Bases: heterocl.tvm.expr.LogicalExpr

class Quantize(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Ramp(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Reduce(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Select(handle)[source]

Bases: heterocl.tvm.expr.Expr

class SetBit(handle)[source]

Bases: heterocl.tvm.expr.Expr

class SetSlice(handle)[source]

Bases: heterocl.tvm.expr.Expr

class Shuffle(handle)[source]

Bases: heterocl.tvm.expr.Expr

class StreamExpr(handle)[source]

Bases: heterocl.tvm.expr.Expr

DoubleBuffer = 1
FIFO = 0
class StringImm(handle)[source]

Bases: heterocl.tvm.expr.ConstExpr

class Sub(handle)[source]

Bases: heterocl.tvm.expr.BinaryOpExpr

class UIntImm(handle)[source]

Bases: heterocl.tvm.expr.ConstExpr

class Var(handle)[source]

Bases: heterocl.tvm.expr.Expr

Symbolic variable.