19 #ifndef TVM_SCRIPT_PRINTER_VAR_TABLE_H_ 20 #define TVM_SCRIPT_PRINTER_VAR_TABLE_H_ 28 #include <unordered_map> 29 #include <unordered_set> 112 template <
typename TObjectRef>
125 static constexpr
const char*
_type_key =
"script.printer.VarTable";
131 struct VariableInfo {
135 std::unordered_map<ObjectRef, VariableInfo, ObjectPtrHash, ObjectPtrEqual> obj2info;
136 std::unordered_set<String> defined_names;
155 #endif // TVM_SCRIPT_PRINTER_VAR_TABLE_H_ void VisitAttrs(AttrVisitor *)
Definition: var_table.h:46
Traced wrapper for regular (non-container) TVM objects.
Definition: traced_object.h:39
#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:758
Reference type of IdDocNode.
Definition: doc.h:367
Definitions and helper macros for IR/AST nodes.
IdDoc Define(const ObjectRef &obj, const String &name_hint, const ObjectPath &object_path, const Frame &frame)
Define variable by name.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
const RefT & Get() const
Access the wrapped object.
Definition: traced_object.h:115
base class of all object containers.
Definition: object.h:167
TVM_DECLARE_FINAL_OBJECT_INFO(VarTableNode, Object)
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Reference type of FrameNode.
Definition: frame.h:76
Reference to string objects.
Definition: string.h:97
const ObjectPath & GetPath() const
Get the path of the wrapped object.
Definition: traced_object.h:157
Base class of all object reference.
Definition: object.h:511
Variable Table manages mapping from variable object to ExprDoc during the process of printing TVMScri...
Definition: var_table.h:44
Optional< ExprDoc > GetVarDoc(const ObjectRef &obj, const ObjectPath &object_path) const
Get the doc for variable.
void DefineByDoc(const ObjectRef &obj, DocFactory doc_factory, const Frame &frame)
Define variable by doc factory.
static constexpr const char * _type_key
Definition: var_table.h:125
std::function< ExprDoc()> DocFactory
Definition: var_table.h:77
Definition: object_path.h:122
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
IdDoc Define(const ObjectRef &obj, const TracedObject< String > &name_hint, const Frame &frame)
Define variable by name.
Definition: var_table.h:73
Reference type of VarTableNode.
Definition: var_table.h:142
bool IsVarDefined(const ObjectRef &obj) const
Check if a variable exists in the table.
Optional< ExprDoc > GetVarDoc(const TracedObject< TObjectRef > obj) const
Get the doc for variable.
Definition: var_table.h:113