The base node types for the Relay language.


Register a Relay node type.

Parameters:type_key (str or cls) – The type key of the node.

Register a Relay attribute node.

Parameters:type_key (str or cls) – The type key of the node.
class tvm.relay.base.RelayNode

Base class of all Relay nodes.

astext(show_meta_data=True, annotate=None)

Get the text format of the expression.

  • show_meta_data (bool) – Whether to include meta data section in the text if there is meta data.
  • annotate (Optional[relay.Expr->str]) – Optional annotate function to provide additional information in the comment block.


The meta data section is necessary to fully parse the text format. However, it can contain dumps that are big (e.g constant weights), so it can be helpful to skip printing the meta data section.

Returns:text – The text format of the expression.
Return type:str
class tvm.relay.base.Span(source, lineno, col_offset)

Specifies a location in a source program.

class tvm.relay.base.SourceName(name)

A identifier for a source location

class tvm.relay.base.Id

Unique identifier(name) used in Var. Guaranteed to be stable across all passes.