23 #ifndef TVM_NODE_REPR_PRINTER_H_
24 #define TVM_NODE_REPR_PRINTER_H_
26 #include <tvm/ffi/reflection/access_path.h>
46 TVM_DLL
void Print(
const ObjectRef& node);
48 TVM_DLL
void Print(
const ffi::Any& node);
60 TVM_DLL
void Dump(
const runtime::ObjectRef& node);
66 TVM_DLL
void Dump(
const runtime::Object* node);
74 inline std::ostream&
operator<<(std::ostream& os,
const ObjectRef& n) {
80 inline std::ostream&
operator<<(std::ostream& os,
const Any& n) {
85 template <
typename... V>
86 inline std::ostream&
operator<<(std::ostream& os,
const Variant<V...>& n) {
91 namespace reflection {
93 inline std::ostream&
operator<<(std::ostream& os,
const AccessStep& step) {
94 namespace refl = ffi::reflection;
96 case refl::AccessKind::kAttr: {
97 os <<
'.' << step->key.cast<String>();
100 case refl::AccessKind::kArrayItem: {
101 os <<
"[" << step->key.cast<int64_t>() <<
"]";
104 case refl::AccessKind::kMapItem: {
105 os <<
"[" << step->key <<
"]";
108 case refl::AccessKind::kAttrMissing: {
109 os <<
".<missing attr " << step->key.cast<String>() <<
"`>";
112 case refl::AccessKind::kArrayItemMissing: {
113 os <<
"[<missing item at " << step->key.cast<int64_t>() <<
">]";
116 case refl::AccessKind::kMapItemMissing: {
117 os <<
"[<missing item at " << step->key <<
">]";
121 LOG(FATAL) <<
"Unknown access step kind: " <<
static_cast<int>(step->kind);
128 Array<AccessStep> steps = path->ToSteps();
130 for (
const auto& step : steps) {
A dynamically dispatched functor on the type of the first argument.
Definition: functor.h:65
A printer class to print the AST/IR nodes.
Definition: repr_printer.h:35
void Print(const ObjectRef &node)
The node to be printed.
std::ostream & stream
The output stream.
Definition: repr_printer.h:38
ReprPrinter(std::ostream &stream)
Definition: repr_printer.h:42
void Print(const ffi::Any &node)
The node to be printed.
void PrintIndent()
Print indent to the stream.
int indent
The indentation level.
Definition: repr_printer.h:40
Defines the Functor data structures.
std::ostream & operator<<(std::ostream &os, const AccessStep &step)
Definition: repr_printer.h:93
std::ostream & operator<<(std::ostream &os, const ObjectRef &n)
Definition: repr_printer.h:74
ffi::reflection::AccessPath AccessPath
Definition: doc.h:35
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
void Dump(const runtime::ObjectRef &node)
Dump the node to stderr, used for debug purposes.