tvm
Classes | Typedefs | Functions | Variables
tvm::script::printer Namespace Reference

Classes

class  AssertDoc
 Reference type of AssertDocNode. More...
 
class  AssertDocNode
 Doc that represents assert statement. More...
 
class  AssignDoc
 Reference type of AssignDocNode. More...
 
class  AssignDocNode
 Doc that represents assign statement. More...
 
class  AttrAccessDoc
 Reference type of AttrAccessDocNode. More...
 
class  AttrAccessDocNode
 Doc that represents attribute access on another expression. More...
 
class  CallDoc
 Reference type of CallDocNode. More...
 
class  CallDocNode
 Doc that represents function call. More...
 
class  ClassDoc
 Reference type of ClassDocNode. More...
 
class  ClassDocNode
 Doc that represents class definition. More...
 
class  DictDoc
 Reference type of DictDocNode. More...
 
class  DictDocNode
 Doc that represents dictionary literal. More...
 
class  Doc
 Reference type of DocNode. More...
 
class  DocNode
 The base class of all Doc. More...
 
class  ExprDoc
 Reference type of ExprDocNode. More...
 
class  ExprDocNode
 The base class of expression doc. More...
 
class  ExprStmtDoc
 Reference type of ExprStmtDocNode. More...
 
class  ExprStmtDocNode
 Doc that represents an expression as statement. More...
 
class  ForDoc
 Reference type of ForDocNode. More...
 
class  ForDocNode
 Doc that represents for statement. More...
 
class  Frame
 Reference type of FrameNode. More...
 
class  FrameNode
 
class  FunctionDoc
 Reference type of FunctionDocNode. More...
 
class  FunctionDocNode
 Doc that represents function definition. More...
 
class  IdDoc
 Reference type of IdDocNode. More...
 
class  IdDocNode
 Doc that represents identifier. More...
 
class  IfDoc
 Reference type of IfDocNode. More...
 
class  IfDocNode
 Doc that represent if-then-else statement. More...
 
class  IndexDoc
 Reference type of IndexDocNode. More...
 
class  IndexDocNode
 Doc that represents index access on another expression. More...
 
class  IRDocsifier
 Reference type of IRDocsifierNode. More...
 
class  IRDocsifierNode
 IRDocsifier is the top-level interface in the IR->Doc process. More...
 
class  LambdaDoc
 Reference type of LambdaDocNode. More...
 
class  LambdaDocNode
 Doc that represents anonymous function. More...
 
class  ListDoc
 Reference type of ListDocNode. More...
 
class  ListDocNode
 Doc that represents list literal. More...
 
class  LiteralDoc
 Reference type of LiteralDocNode. More...
 
class  LiteralDocNode
 Doc that represents literal value. More...
 
class  MetadataFrame
 Reference type of MetadataFrameNode. More...
 
class  MetadataFrameNode
 MetadataFrame contains information like contant parameter array. More...
 
class  OperationDoc
 Reference type of OperationDocNode. More...
 
class  OperationDocNode
 Doc that represents operation. More...
 
class  ReturnDoc
 Reference type of ReturnDocNode. More...
 
class  ReturnDocNode
 Doc that represents return statement. More...
 
class  RootNodeContainer
 
class  RootNodeContainerNode
 A wrapper object to provide injection point for printer of each IR. More...
 
class  ScopeDoc
 Reference type of ScopeDocNode. More...
 
class  ScopeDocNode
 Doc that represents special scopes. More...
 
class  SliceDoc
 Reference type of SliceDocNode. More...
 
class  SliceDocNode
 Doc that represents slice in Index expression. More...
 
class  StmtBlockDoc
 Reference type of StmtBlockDocNode. More...
 
class  StmtBlockDocNode
 The container doc that holds a list of StmtDoc. More...
 
class  StmtDoc
 Reference type of StmtDocNode. More...
 
class  StmtDocNode
 The base class of statement doc. More...
 
class  TracedObjectFunctor
 Dynamic dispatch functor based on TracedObject. More...
 
class  TupleDoc
 Reference type of TupleDocNode. More...
 
class  TupleDocNode
 Doc that represents tuple literal. More...
 
class  VarDefFrame
 Reference type of VarDefFrameNode. More...
 
class  VarDefFrameNode
 VarDefFrame contains information about the free variables that needs to be defined at the beginning of the printed snippet. More...
 
class  VarTable
 Reference type of VarTableNode. More...
 
class  VarTableNode
 Variable Table manages mapping from variable object to ExprDoc during the process of printing TVMScript. More...
 
class  WhileDoc
 Reference type of WhileDocNode. More...
 
class  WhileDocNode
 Doc that represents while statement. More...
 

Typedefs

using WithCtx = With< ContextManager >
 
using DispatchTable = std::unordered_map< std::string, std::vector< runtime::PackedFunc > >
 

Functions

String DocToPythonScript (Doc doc, int indent_spaces=4, bool print_line_numbers=false, int num_context_lines=-1, Optional< ObjectPath > path_to_underline=NullOpt)
 Convert Doc into Python script. More...
 
const runtime::PackedFuncGetDispatchFunction (const DispatchTable &dispatch_table, const String &token, uint32_t type_index)
 Get function from dispatch table. More...
 
void SetDispatchFunction (DispatchTable *dispatch_table, const String &token, uint32_t type_index, runtime::PackedFunc f)
 Set function in dispatch table. More...
 
void RemoveDispatchFunction (DispatchTable *dispatch_table, const String &token, uint32_t type_index)
 Remove function from dispatch table. More...
 
String Script (const ObjectRef &root_node, String ir_name, Map< String, String > ir_prefix, int indent_spaces=4, bool print_line_numbers=false, int num_context_lines=-1, Optional< ObjectPath > path_to_underline=NullOpt)
 Print IR graph as TVMScript code. More...
 

Variables

constexpr const char * kDefaultDispatchToken = ""
 

Typedef Documentation

◆ DispatchTable

using tvm::script::printer::DispatchTable = typedef std::unordered_map<std::string, std::vector<runtime::PackedFunc> >

◆ WithCtx

Function Documentation

◆ DocToPythonScript()

String tvm::script::printer::DocToPythonScript ( Doc  doc,
int  indent_spaces = 4,
bool  print_line_numbers = false,
int  num_context_lines = -1,
Optional< ObjectPath path_to_underline = NullOpt 
)

Convert Doc into Python script.

This function unpacks the DocPrinterOptions into function arguments to be FFI friendly.

Parameters
docDoc to be converted
indent_spacesNumber of spaces used for indentation
print_line_numbersWhether to print line numbers
num_context_linesNumber of context lines to print around the underlined text
path_to_underlineObject path to be underlined

◆ GetDispatchFunction()

const runtime::PackedFunc& tvm::script::printer::GetDispatchFunction ( const DispatchTable dispatch_table,
const String token,
uint32_t  type_index 
)

Get function from dispatch table.

Parameters
dispatch_tableThe dispatch table.
tokenThe dispatch token.
type_indexThe type index of the Object type to be dispatched.
Returns
The dispatch function.

◆ RemoveDispatchFunction()

void tvm::script::printer::RemoveDispatchFunction ( DispatchTable dispatch_table,
const String token,
uint32_t  type_index 
)

Remove function from dispatch table.

Parameters
dispatch_tableThe dispatch table.
tokenThe dispatch token.
type_indexThe TVM object type index for the dispatch function to be removed.

◆ Script()

String tvm::script::printer::Script ( const ObjectRef root_node,
String  ir_name,
Map< String, String ir_prefix,
int  indent_spaces = 4,
bool  print_line_numbers = false,
int  num_context_lines = -1,
Optional< ObjectPath path_to_underline = NullOpt 
)

Print IR graph as TVMScript code.

Parameters
root_nodeThe root node to print.
ir_nameThe dispatch token of the target IR, e.g., "tir", "relax".
ir_prefixThe symbol name for TVMScript IR namespaces. For example, {"tir": "T"}.
indent_spacesNumber of spaces used for indentation
print_line_numbersWhether to print line numbers
num_context_linesNumber of context lines to print around the underlined text
path_to_underlineObject path to be underlined
Returns
the TVMScript code as string.

◆ SetDispatchFunction()

void tvm::script::printer::SetDispatchFunction ( DispatchTable dispatch_table,
const String token,
uint32_t  type_index,
runtime::PackedFunc  f 
)

Set function in dispatch table.

Parameters
dispatch_tableThe dispatch table.
tokenThe dispatch token.
type_indexThe type index of the Object type to be dispatched.
fThe dispatch function.

Variable Documentation

◆ kDefaultDispatchToken

constexpr const char* tvm::script::printer::kDefaultDispatchToken = ""