Relay References¶
The TVM codebase is large and can be very confusing to reference. Things are not always placed where'd you expect them to be. The two classes below aim to aid the developer or user in the navigation and referencing of TVM's codebase.
forge.relay.relay.Relay
¶
Bases: Enum
An enumeration of Relay objects.
Provides a flattened reference of Relay objects. This allows one to more easily navigate TVM's codebase of objects without in-depth knowledge of TVM's codebase structure.
Examples: .. code-block:: python
Relay.Var.help() # Print the docstring of the TVM Var object
Relay.Var.str # Get the string of the TVM object - 'Var'
Relay.Var.obj # Reference to the TVM Var object
Relay.Var(*args, **kwargs) # Invoke the constructor
str: str
property
¶
String of the enumerated TVM object
obj: typing.Any
property
¶
Reference to the enumerated TVM object
help() -> None
¶
Print the docstrings of the enumerated TVM object
__call__(*args, **kwargs) -> typing.Any
¶
Invocation of the enumerated TVM object's constructor
Use the member help()
method to get details on correct usage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
*Any
|
Positional arguments for the constructor |
()
|
**kwargs
|
**Any
|
Keyword arguments for the constructor |
{}
|
Returns:
Type | Description |
---|---|
Any
|
TVM object |
Examples: .. code-block:: python
var = Relay.Var("data", shape=(100,), dtype="float32")
mod = Relay.IRModule(var)
IRModule = tvm.ir.module.IRModule
class-attribute
instance-attribute
¶
Function = relay.function.Function
class-attribute
instance-attribute
¶
Call = relay.expr.Call
class-attribute
instance-attribute
¶
Var = relay.expr.Var
class-attribute
instance-attribute
¶
Constant = relay.expr.Constant
class-attribute
instance-attribute
¶
Tuple = relay.expr.Tuple
class-attribute
instance-attribute
¶
TupleGetItem = relay.expr.TupleGetItem
class-attribute
instance-attribute
¶
GlobalVar = relay.expr.GlobalVar
class-attribute
instance-attribute
¶
Op = tvm.ir.Op
class-attribute
instance-attribute
¶
Attrs = tvm.ir.attrs.Attrs
class-attribute
instance-attribute
¶
NDArray = tvm.runtime.ndarray.NDArray
class-attribute
instance-attribute
¶
ADT = tvm.runtime.container.ADT
class-attribute
instance-attribute
¶
Node = tvm.ir.base.Node
class-attribute
instance-attribute
¶
Clause = relay.adt.Clause
class-attribute
instance-attribute
¶
Match = relay.adt.Match
class-attribute
instance-attribute
¶
TypeData = relay.adt.TypeData
class-attribute
instance-attribute
¶
Constructor = relay.adt.Constructor
class-attribute
instance-attribute
¶
PatternConstructor = relay.adt.PatternConstructor
class-attribute
instance-attribute
¶
PatternVar = relay.adt.PatternVar
class-attribute
instance-attribute
¶
PatternWildcard = relay.adt.PatternWildcard
class-attribute
instance-attribute
¶
PatternTuple = relay.adt.PatternTuple
class-attribute
instance-attribute
¶
Array = tvm.ir.container.Array
class-attribute
instance-attribute
¶
Map = tvm.ir.container.Map
class-attribute
instance-attribute
¶
Span = tvm.ir.base.Span
class-attribute
instance-attribute
¶
SourceName = tvm.ir.base.SourceName
class-attribute
instance-attribute
¶
Let = relay.expr.Let
class-attribute
instance-attribute
¶
If = relay.expr.If
class-attribute
instance-attribute
¶
RefCreate = relay.expr.RefCreate
class-attribute
instance-attribute
¶
RefRead = relay.expr.RefRead
class-attribute
instance-attribute
¶
RefWrite = relay.expr.RefWrite
class-attribute
instance-attribute
¶
TupleWrapper = relay.expr.TupleWrapper
class-attribute
instance-attribute
¶
TypeVar = relay.ty.TypeVar
class-attribute
instance-attribute
¶
IncompleteType = relay.ty.IncompleteType
class-attribute
instance-attribute
¶
TensorType = relay.ty.TensorType
class-attribute
instance-attribute
¶
FuncType = relay.ty.FuncType
class-attribute
instance-attribute
¶
TupleType = relay.ty.TupleType
class-attribute
instance-attribute
¶
TypeRelation = relay.ty.TypeRelation
class-attribute
instance-attribute
¶
RefType = relay.ty.RefType
class-attribute
instance-attribute
¶
GlobalTypeVar = relay.ty.GlobalTypeVar
class-attribute
instance-attribute
¶
TypeCall = relay.ty.TypeCall
class-attribute
instance-attribute
¶
Any = tvm.tir.expr.Any
class-attribute
instance-attribute
¶
IntImm = tvm.tir.expr.IntImm
class-attribute
instance-attribute
¶
String = tvm.runtime.container.String
class-attribute
instance-attribute
¶
forge.relay.relay.RelayOp(op_name: str)
¶
Provide a quick reference to TVM's python API of Relay Operators
via the identifying op-name string. This is a very useful since
all the operators are encoded as strings in Forge. Additionally,
there is a minor quirk the the structure of the TVM operator
codebase such that QNN operators are not placed in the codebase
in a path that matches its string-form, e.g. 'qnn.conv2d' sits at
tvm.relay.qnn.op.conv2d
. This class resolves this quirk.
Lookup and reference the TVM operator function by operator's name string
Provided a valid operator name string, the returned instance is ready to be called as if it were the referenced TVM operator function. When a TVM operator function is called correctly, a Relay expression is formed.
Examples: .. code-block:: python
RelayOp("nn.conv2d") # Get the `tvm.relay.nn.conv2d` function
RelayOp("nn.conv2d")(*args, **kwargs) # Invoke operator and get a 'conv2d' expression
RelayOp("nn.conv2d").help() # Print the TVM operator function docstring
RelayOp.list_op_names() # Get a list of all op-name strings
__call__(*args, **kwargs) -> Relay.Node.obj
¶
Invoke the referenced TVM operator function
Use the instance help()
method to get details on correct usage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
*Any
|
Positional arguments for the TVM operator function |
()
|
**kwargs
|
**Any
|
Keyword arguments for the TVM operator function |
{}
|
Returns:
Type | Description |
---|---|
obj
|
TVM Relay expression |
help() -> None
¶
Print the docstrings of the TVM operator function