19 #ifndef TVM_SCRIPT_PRINTER_IR_DOCSIFIER_H_ 20 #define TVM_SCRIPT_PRINTER_IR_DOCSIFIER_H_ 23 #include <tvm/runtime/logging.h> 79 v->Visit(
"vars", &vars);
80 v->Visit(
"frames", &frames);
81 v->Visit(
"dispatch_tokens", &dispatch_tokens);
82 v->Visit(
"ir_prefix", &ir_prefix);
85 static constexpr
const char*
_type_key =
"script.printer.IRDocsifier";
97 auto result = Downcast<TDoc>(AsDocImpl(obj));
98 result->source_paths.push_back(obj.
GetPath());
122 return WithCtx(
nullptr, [
this]() { this->dispatch_tokens.
pop_back(); });
137 frame->EnterWithScope();
139 return WithCtx(
nullptr, [
this, pushed_frame = frame]() {
141 ICHECK_EQ(last_frame, pushed_frame);
143 last_frame->ExitWithScope();
151 template <
typename FrameType>
153 for (
auto it = frames.
rbegin(); it != frames.
rend(); ++it) {
154 if (
const auto* f = (*it).as<
typename FrameType::ContainerType>()) {
155 return GetRef<FrameType>(f);
180 TVM_DLL
static FType& vtable();
212 static constexpr
const char*
_type_key =
"script.printer.RootNodeContainer";
230 #endif // TVM_SCRIPT_PRINTER_IR_DOCSIFIER_H_ WithCtx WithFrame(const Frame &frame)
Push a new frame the stack.
Definition: ir_docsifier.h:136
Traced wrapper for regular (non-container) TVM objects.
Definition: traced_object.h:39
Definition: ir_docsifier.h:216
#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:758
Definitions and helper macros for IR/AST nodes.
const T back() const
Definition: array.h:443
void VisitAttrs(tvm::AttrVisitor *v)
Definition: ir_docsifier.h:210
void VisitAttrs(tvm::AttrVisitor *v)
Definition: ir_docsifier.h:78
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
Reference type of IRDocsifierNode.
Definition: ir_docsifier.h:168
Reference type of DocNode.
Definition: doc.h:67
VarTable vars
The var table to use during the printing process.
Definition: ir_docsifier.h:60
Map< String, String > ir_prefix
This map connects IR dipatch token to the name of identifier.
Definition: ir_docsifier.h:76
base class of all object containers.
Definition: object.h:167
ObjectRef root_node
The root node to print.
Definition: ir_docsifier.h:208
TVM_DECLARE_FINAL_OBJECT_INFO(IRDocsifierNode, Object)
void push_back(const T &item)
push a new item to the back of the list
Definition: array.h:457
TDoc AsDoc(const TracedObject< ObjectRef > &obj) const
Transform the input object into TDoc.
Definition: ir_docsifier.h:96
Dynamic dispatch functor based on TracedObject.
Definition: traced_object_functor.h:82
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
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Reference type of FrameNode.
Definition: frame.h:76
Array< String > dispatch_tokens
The stack of dispatch tokens.
Definition: ir_docsifier.h:72
Reference to string objects.
Definition: string.h:97
reverse_iterator rbegin() const
Definition: array.h:393
const ObjectPath & GetPath() const
Get the path of the wrapped object.
Definition: traced_object.h:157
RAII wrapper function to enter and exit a context object similar to python's with syntax...
Definition: with.h:58
Base class of all object reference.
Definition: object.h:511
Array< Frame > frames
The stack of frames.
Definition: ir_docsifier.h:65
A wrapper object to provide injection point for printer of each IR.
Definition: ir_docsifier.h:205
IRDocsifier is the top-level interface in the IR->Doc process.
Definition: ir_docsifier.h:54
static constexpr const char * _type_key
Definition: ir_docsifier.h:85
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
Definition: map.h:1271
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
void pop_back()
Remove the last item of the list.
Definition: array.h:503
Reference type of ExprDocNode.
Definition: doc.h:133
constexpr runtime::NullOptType NullOpt
Definition: optional.h:160
reverse_iterator rend() const
Definition: array.h:399
Reference type of VarTableNode.
Definition: var_table.h:142
WithCtx WithDispatchToken(const String &token)
Push a new dispatch token into the stack.
Definition: ir_docsifier.h:120
Optional< FrameType > GetFrame() const
Get the top frame with type FrameType.
Definition: ir_docsifier.h:152
With< ContextManager > WithCtx
Definition: ir_docsifier.h:35
ExprDoc AsExprDoc(const TracedObject< ObjectRef > &obj)
Helper method to transform object into ExprDoc.
Definition: ir_docsifier.h:108
#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:728
RAII wrapper function to enter and exit a context object similar to python's with syntax...