IRDocsifier is the top-level interface in the IR->Doc process.
More...
#include <ir_docsifier.h>
|
struct | VariableInfo |
| Information about a variable, including its optional name and its doc creator. More...
|
|
IRDocsifier is the top-level interface in the IR->Doc process.
It provides methods to convert IR node object to Doc, operate on Frame objects and change dispatch tokens.
◆ DocCreator
A function that creates the doc for a variable.
◆ AddGlobalInfo()
void tvm::script::printer::IRDocsifierNode::AddGlobalInfo |
( |
const String & |
name, |
|
|
const GlobalInfo & |
ginfo |
|
) |
| |
Add a GlobalInfo to the global_infos map.
- Parameters
-
name | The name of key of global_infos. |
ginfo | The GlobalInfo to be added. |
◆ AddMetadata()
ExprDoc tvm::script::printer::IRDocsifierNode::AddMetadata |
( |
const ObjectRef & |
obj | ) |
|
Add a TVM object to the metadata section.
◆ AsDoc()
template<class TDoc >
TDoc tvm::script::printer::IRDocsifierNode::AsDoc |
( |
const ObjectRef & |
obj, |
|
|
const ObjectPath & |
path |
|
) |
| const |
|
inline |
Transform the input object into TDoc.
- Parameters
-
obj | The object to be transformed. |
path | The path to this object. |
- Returns
- The Doc object.
◆ Define() [1/2]
Define variable by name.
- Parameters
-
obj | The variable object. |
frame | The frame that this variable is defined in. |
name_hint | The hint for variable name. |
- Returns
- The id doc for this variable.
This function will rename the variable to avoid name conflict with other variables in the table.
◆ Define() [2/2]
void tvm::script::printer::IRDocsifierNode::Define |
( |
const ObjectRef & |
obj, |
|
|
const Frame & |
frame, |
|
|
DocCreator |
doc_factory |
|
) |
| |
Define variable by doc factory.
- Parameters
-
obj | The variable object. |
frame | The frame that this variable is defined in. |
doc_factory | The function to return an ExprDoc object for this variable. |
This function is a special form of Define
. Variable is mapped to ExprDoc rather than IdDoc. It's useful when a variable is implicitly defined without a name, like the buf->data in TIR, which should be mapped to AttrDoc(IdDoc("<buffer_name>"), "data")
.
This function takes a DocFactory instead of Doc. It's because GetVarDoc needs to return a new Doc object every time it's called, as the returned doc will have different source_path
. Currently there isn't a good way to deep copy a TVMObject so VarTable needs to call a factory function to get a freshly-constructed Doc object every time GetVarDoc is called.
◆ GetVarDoc()
Get the doc for variable.
- Parameters
-
- Returns
- The doc for variable, if it exists in the table. Otherwise it returns NullOpt.
◆ IsVarDefined()
bool tvm::script::printer::IRDocsifierNode::IsVarDefined |
( |
const ObjectRef & |
obj | ) |
const |
Check if a variable exists in the table.
- Parameters
-
- Returns
- a boolean for whether variable exists.
◆ RemoveVar()
void tvm::script::printer::IRDocsifierNode::RemoveVar |
( |
const ObjectRef & |
obj | ) |
|
Remove the variable defined.
◆ SetCommonPrefix()
Set the common prefix information of variable usage.
- Parameters
-
root | The root of the AST. |
is_var | A function that returns true if the given object is considered a variable. |
◆ TVM_DECLARE_FINAL_OBJECT_INFO()
◆ VisitAttrs()
◆ _type_key
constexpr const char* tvm::script::printer::IRDocsifierNode::_type_key = "script.printer.IRDocsifier" |
|
staticconstexpr |
◆ cfg
PrinterConfig tvm::script::printer::IRDocsifierNode::cfg {nullptr} |
The configuration of the printer.
◆ common_prefix
std::unordered_map<const Object*, std::vector<const Object*> > tvm::script::printer::IRDocsifierNode::common_prefix |
Common prefixes of variable usages.
◆ defined_names
std::unordered_set<String> tvm::script::printer::IRDocsifierNode::defined_names |
The variable names used already.
◆ dispatch_tokens
Array<String> tvm::script::printer::IRDocsifierNode::dispatch_tokens |
The stack of dispatch tokens.
The dispatch token on the top decides which dispatch function to use when converting IR node object to Doc.
◆ frames
Array<Frame> tvm::script::printer::IRDocsifierNode::frames |
◆ global_infos
◆ ir_usage
std::unordered_set<std::string> tvm::script::printer::IRDocsifierNode::ir_usage |
The IR usages for headers printing.
◆ metadata
◆ obj2info
Mapping from a var to its info.
The documentation for this class was generated from the following file: