diff --git a/include/tvm/node/functor.h b/include/tvm/node/functor.h index d925fbde46717..e11fda892c305 100644 --- a/include/tvm/node/functor.h +++ b/include/tvm/node/functor.h @@ -139,11 +139,11 @@ class NodeFunctor { * \brief Useful macro to set NodeFunctor dispatch in a global static field. * * \code - * // Use NodeFunctor to implement NodePrinter similar to Visitor Pattern. + * // Use NodeFunctor to implement ReprPrinter similar to Visitor Pattern. * // vtable allows easy patch of new Node types, without changing - * // interface of NodePrinter. + * // interface of ReprPrinter. * - * class NodePrinter { + * class ReprPrinter { * public: * std::ostream& stream; * // the dispatch function. @@ -152,18 +152,18 @@ class NodeFunctor { * f(e, this); * } * - * using FType = NodeFunctor; + * using FType = NodeFunctor; * // function to return global function table * static FType& vtable(); * }; * * // in cpp/cc file - * NodePrinter::FType& NodePrinter::vtable() { // NOLINT(*) + * ReprPrinter::FType& ReprPrinter::vtable() { // NOLINT(*) * static FType inst; return inst; * } * - * TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) - * .set_dispatch([](const ObjectRef& ref, NodePrinter* p) { + * TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) + * .set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { * auto* n = static_cast(ref.get()); * p->print(n->a); * p->stream << '+' diff --git a/include/tvm/node/node.h b/include/tvm/node/node.h index 10c577a890bea..3ea3d763df74f 100644 --- a/include/tvm/node/node.h +++ b/include/tvm/node/node.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/tvm/node/printer.h b/include/tvm/node/repr_printer.h similarity index 85% rename from include/tvm/node/printer.h rename to include/tvm/node/repr_printer.h index a4c6a696633cc..41789a34d342c 100644 --- a/include/tvm/node/printer.h +++ b/include/tvm/node/repr_printer.h @@ -17,25 +17,25 @@ * under the License. */ /*! - * \file tvm/node/printer.h + * \file tvm/node/repr_printer.h * \brief Printer class to print repr string of each AST/IR nodes. */ -#ifndef TVM_NODE_PRINTER_H_ -#define TVM_NODE_PRINTER_H_ +#ifndef TVM_NODE_REPR_PRINTER_H_ +#define TVM_NODE_REPR_PRINTER_H_ #include #include namespace tvm { /*! \brief A printer class to print the AST/IR nodes. */ -class NodePrinter { +class ReprPrinter { public: /*! \brief The output stream */ std::ostream& stream; /*! \brief The indentation level. */ int indent{0}; - explicit NodePrinter(std::ostream& stream) // NOLINT(*) + explicit ReprPrinter(std::ostream& stream) // NOLINT(*) : stream(stream) {} /*! \brief The node to be printed. */ @@ -43,7 +43,7 @@ class NodePrinter { /*! \brief Print indent to the stream */ TVM_DLL void PrintIndent(); // Allow registration to be printer. - using FType = NodeFunctor; + using FType = NodeFunctor; TVM_DLL static FType& vtable(); }; @@ -60,9 +60,9 @@ namespace runtime { // default print function for all objects // provide in the runtime namespace as this is where objectref originally comes from. inline std::ostream& operator<<(std::ostream& os, const ObjectRef& n) { // NOLINT(*) - NodePrinter(os).Print(n); + ReprPrinter(os).Print(n); return os; } } // namespace runtime } // namespace tvm -#endif // TVM_NODE_PRINTER_H_ +#endif // TVM_NODE_REPR_PRINTER_H_ diff --git a/src/arith/const_int_bound.cc b/src/arith/const_int_bound.cc index a75e86a32660f..7fb90a5e87c14 100644 --- a/src/arith/const_int_bound.cc +++ b/src/arith/const_int_bound.cc @@ -51,8 +51,8 @@ inline void PrintBoundValue(std::ostream& os, int64_t val) { } } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "ConstIntBound["; PrintBoundValue(p->stream, op->min_value); diff --git a/src/arith/int_set.cc b/src/arith/int_set.cc index 27cdffee02b13..728cca1b5705e 100644 --- a/src/arith/int_set.cc +++ b/src/arith/int_set.cc @@ -813,8 +813,8 @@ IntSet EvalSet(Range r, TVM_REGISTER_NODE_TYPE(IntervalSetNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "IntervalSet" << "[" << op->min_value << ", " diff --git a/src/arith/modular_set.cc b/src/arith/modular_set.cc index 8b5309272efe1..c3031ca0edfc1 100644 --- a/src/arith/modular_set.cc +++ b/src/arith/modular_set.cc @@ -44,8 +44,8 @@ ModularSet::ModularSet(int64_t coeff, int64_t base) { data_ = std::move(node); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "ModularSet(" << "coeff=" << op->coeff << ", base=" diff --git a/src/ir/adt.cc b/src/ir/adt.cc index 2914779ae7ad0..f94284090e264 100644 --- a/src/ir/adt.cc +++ b/src/ir/adt.cc @@ -45,8 +45,8 @@ TVM_REGISTER_GLOBAL("relay._make.Constructor") return Constructor(name_hint, inputs, belong_to); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "ConstructorNode(" << node->name_hint << ", " << node->inputs << ", " << node->belong_to << ")"; @@ -71,8 +71,8 @@ TVM_REGISTER_GLOBAL("relay._make.TypeData") return TypeData(header, type_vars, constructors); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TypeDataNode(" << node->header << ", " << node->type_vars << ", " << node->constructors << ")"; diff --git a/src/ir/attrs.cc b/src/ir/attrs.cc index 8c6e191ce2873..c5d7446d29555 100644 --- a/src/ir/attrs.cc +++ b/src/ir/attrs.cc @@ -59,8 +59,8 @@ Attrs DictAttrsNode::make(Map dict) { return Attrs(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << op->dict; }); diff --git a/src/ir/env_func.cc b/src/ir/env_func.cc index b041d73949fdf..b125c03188537 100644 --- a/src/ir/env_func.cc +++ b/src/ir/env_func.cc @@ -31,8 +31,8 @@ using runtime::PackedFunc; using runtime::TVMArgs; using runtime::TVMRetValue; -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "EnvFunc(" << op->name << ")"; }); diff --git a/src/ir/expr.cc b/src/ir/expr.cc index f81eb33ba0df1..f194a386e359b 100644 --- a/src/ir/expr.cc +++ b/src/ir/expr.cc @@ -78,8 +78,8 @@ TVM_REGISTER_GLOBAL("make.IntImm") TVM_REGISTER_NODE_TYPE(IntImmNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); if (op->dtype == DataType::Int(32)) { p->stream << op->value; @@ -104,8 +104,8 @@ TVM_REGISTER_GLOBAL("make.FloatImm") TVM_REGISTER_NODE_TYPE(FloatImmNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); auto& stream = p->stream; switch (op->dtype.bits()) { @@ -134,8 +134,8 @@ Range Range::make_by_min_extent(PrimExpr min, PrimExpr extent) { return Range(make_object(min, extent)); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "range(min=" << op->min << ", ext=" << op->extent << ')'; }); @@ -159,15 +159,15 @@ TVM_REGISTER_GLOBAL("relay._make.GlobalVar") return GlobalVar(name); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "GlobalVar(" << node->name_hint << ")"; }); // Container printer -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '['; for (size_t i = 0 ; i < op->data.size(); ++i) { @@ -179,8 +179,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ']'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '{'; for (auto it = op->data.begin(); it != op->data.end(); ++it) { @@ -194,8 +194,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << '}'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '{'; for (auto it = op->data.begin(); it != op->data.end(); ++it) { diff --git a/src/ir/module.cc b/src/ir/module.cc index 01a8baaedb821..7f3796ed07f5d 100644 --- a/src/ir/module.cc +++ b/src/ir/module.cc @@ -434,8 +434,8 @@ TVM_REGISTER_GLOBAL("relay._module.Module_ImportFromStd") mod->ImportFromStd(path); });; -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "IRModuleNode( " << node->functions << ")"; }); diff --git a/src/ir/op.cc b/src/ir/op.cc index 2bdb04d729ac0..558b69891ae64 100644 --- a/src/ir/op.cc +++ b/src/ir/op.cc @@ -227,8 +227,8 @@ TVM_REGISTER_NODE_TYPE(OpNode) return static_cast(n)->name; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "Op(" << node->name << ")"; }); diff --git a/src/ir/span.cc b/src/ir/span.cc index 2519321eba382..2ea7095c89ac8 100644 --- a/src/ir/span.cc +++ b/src/ir/span.cc @@ -48,8 +48,8 @@ SourceName SourceName::Get(const std::string& name) { TVM_REGISTER_GLOBAL("relay._make.SourceName") .set_body_typed(SourceName::Get); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "SourceName(" << node->name << ", " << node << ")"; }); @@ -73,8 +73,8 @@ TVM_REGISTER_NODE_TYPE(SpanNode); TVM_REGISTER_GLOBAL("relay._make.Span") .set_body_typed(SpanNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "Span(" << node->source << ", " << node->lineno << ", " << node->col_offset << ")"; diff --git a/src/ir/tensor_type.cc b/src/ir/tensor_type.cc index 0a9ed4eed327c..5e7c51c72d9b5 100644 --- a/src/ir/tensor_type.cc +++ b/src/ir/tensor_type.cc @@ -27,7 +27,7 @@ namespace tvm { -using tvm::NodePrinter; +using tvm::ReprPrinter; using namespace tvm::runtime; TensorType::TensorType(Array shape, DataType dtype) { @@ -60,8 +60,8 @@ TVM_REGISTER_GLOBAL("relay._make.TensorType") return TensorType(shape, dtype); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TensorType(" << node->shape << ", " << node->dtype << ")"; }); diff --git a/src/ir/transform.cc b/src/ir/transform.cc index 5d0f5d8458330..1da010c5979d6 100644 --- a/src/ir/transform.cc +++ b/src/ir/transform.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include // TODO(tqchen): Update to use String container after it is merged. @@ -38,7 +38,7 @@ namespace transform { using tvm::runtime::TVMArgs; using tvm::runtime::TVMRetValue; -using tvm::NodePrinter; +using tvm::ReprPrinter; struct PassContextThreadLocalEntry { /*! \brief The default pass context. */ @@ -341,8 +341,8 @@ TVM_REGISTER_GLOBAL("relay._transform.Info") *ret = pass->Info(); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, tvm::NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, tvm::ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "The meta data of the pass: "; p->stream << "pass name: " << node->name; @@ -371,8 +371,8 @@ TVM_REGISTER_GLOBAL("relay._transform.RunPass") *ret = pass(mod); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); const PassInfo info = node->Info(); p->stream << "Run Module pass: " << info->name @@ -391,8 +391,8 @@ TVM_REGISTER_GLOBAL("relay._transform.Sequential") *ret = Sequential(passes, pass_info); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); const PassInfo info = node->Info(); p->stream << "Run Sequential pass: " << info->name @@ -421,8 +421,8 @@ TVM_REGISTER_GLOBAL("relay._transform.PassContext") *ret = pctx; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "Pass context information: " << "\n"; p->stream << "\topt_level: " << node->opt_level << "\n"; diff --git a/src/ir/type.cc b/src/ir/type.cc index 233274a79e020..02ddfc9371fd0 100644 --- a/src/ir/type.cc +++ b/src/ir/type.cc @@ -38,8 +38,8 @@ TVM_REGISTER_GLOBAL("relay._make.PrimType") return PrimType(dtype); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << node->dtype; }); @@ -59,8 +59,8 @@ TVM_REGISTER_GLOBAL("relay._make.TypeVar") return TypeVar(name, static_cast(kind)); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TypeVar(" << node->name_hint << ", " << node->kind << ")"; @@ -81,8 +81,8 @@ TVM_REGISTER_GLOBAL("relay._make.GlobalTypeVar") return GlobalTypeVar(name, static_cast(kind)); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "GlobalTypeVar(" << node->name_hint << ", " << node->kind << ")"; @@ -110,8 +110,8 @@ TVM_REGISTER_GLOBAL("relay._make.FuncType") return FuncType(arg_types, ret_type, type_params, type_constraints); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "FuncType(" << node->type_params << ", " << node->arg_types << ", " << node->ret_type << ", " @@ -136,8 +136,8 @@ TVM_REGISTER_GLOBAL("relay._make.TupleType") return TupleType(fields); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TupleTypeNode(" << node->fields << ")"; }); @@ -156,8 +156,8 @@ TVM_REGISTER_GLOBAL("relay._make.IncompleteType") return IncompleteType(static_cast(kind)); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "IncompleteTypeNode(" << node->kind << ", " << node << ")"; }); @@ -176,8 +176,8 @@ TVM_REGISTER_GLOBAL("relay._make.RefType") TVM_REGISTER_NODE_TYPE(RelayRefTypeNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "RelayRefTypeNode(" << node->value << ")"; }); diff --git a/src/ir/type_relation.cc b/src/ir/type_relation.cc index 361525c550441..1d80f95b10c95 100644 --- a/src/ir/type_relation.cc +++ b/src/ir/type_relation.cc @@ -40,8 +40,8 @@ TVM_REGISTER_GLOBAL("relay._make.TypeCall") return TypeCall(func, type); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TypeCallNode(" << node->func << ", " << node->args << ")"; @@ -69,8 +69,8 @@ TVM_REGISTER_GLOBAL("relay._make.TypeRelation") return TypeRelation(func, args, num_inputs, attrs); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TypeRelationNode(" << node->func->name diff --git a/src/node/printer.cc b/src/node/repr_printer.cc similarity index 87% rename from src/node/printer.cc rename to src/node/repr_printer.cc index e0176d245d801..ef91d2f5965e4 100644 --- a/src/node/printer.cc +++ b/src/node/repr_printer.cc @@ -19,13 +19,13 @@ /*! * Printer utilities - * \file node/printer.cc + * \file node/repr_printer.cc */ -#include +#include namespace tvm { -void NodePrinter::Print(const ObjectRef& node) { +void ReprPrinter::Print(const ObjectRef& node) { static const FType& f = vtable(); if (!node.defined()) { stream << "(nullptr)"; @@ -39,13 +39,13 @@ void NodePrinter::Print(const ObjectRef& node) { } } -void NodePrinter::PrintIndent() { +void ReprPrinter::PrintIndent() { for (int i = 0; i < indent; ++i) { stream << ' '; } } -NodePrinter::FType& NodePrinter::vtable() { +ReprPrinter::FType& ReprPrinter::vtable() { static FType inst; return inst; } diff --git a/src/relay/backend/interpreter.cc b/src/relay/backend/interpreter.cc index 224ff778ff342..0e95a69d466b0 100644 --- a/src/relay/backend/interpreter.cc +++ b/src/relay/backend/interpreter.cc @@ -47,8 +47,8 @@ InterpreterClosure::InterpreterClosure(tvm::Map env, data_ = std::move(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "InterpreterClosureNode(" << node->func << ", " << node->env << ")"; }); @@ -68,8 +68,8 @@ RecClosure::RecClosure(InterpreterClosure clos, Var bind) { data_ = std::move(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "RecClosureObj(" << node->clos << ")"; }); @@ -87,8 +87,8 @@ TVM_REGISTER_GLOBAL("relay._make.RefValue") TVM_REGISTER_NODE_TYPE(RefValueObj); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "RefValueObj(" << node->value << ")"; }); @@ -111,8 +111,8 @@ TVM_REGISTER_GLOBAL("relay._make.ConstructorValue") TVM_REGISTER_NODE_TYPE(ConstructorValueObj); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "ConstructorValueObj(" << node->tag << "," << node->fields << ")"; diff --git a/src/relay/ir/adt.cc b/src/relay/ir/adt.cc index bf9c9189e9266..485a0a283a31d 100644 --- a/src/relay/ir/adt.cc +++ b/src/relay/ir/adt.cc @@ -37,8 +37,8 @@ TVM_REGISTER_NODE_TYPE(PatternWildcardNode); TVM_REGISTER_GLOBAL("relay._make.PatternWildcard") .set_body_typed(PatternWildcardNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { p->stream << "PatternWildcardNode()"; }); @@ -53,8 +53,8 @@ TVM_REGISTER_NODE_TYPE(PatternVarNode); TVM_REGISTER_GLOBAL("relay._make.PatternVar") .set_body_typed(PatternVarNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "PatternVarNode(" << node->var << ")"; }); @@ -72,8 +72,8 @@ TVM_REGISTER_NODE_TYPE(PatternConstructorNode); TVM_REGISTER_GLOBAL("relay._make.PatternConstructor") .set_body_typed(PatternConstructorNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "PatternConstructorNode(" << node->constructor << ", " << node->patterns << ")"; @@ -90,8 +90,8 @@ TVM_REGISTER_NODE_TYPE(PatternTupleNode); TVM_REGISTER_GLOBAL("relay._make.PatternTuple") .set_body_typed(PatternTupleNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "PatternTupleNode(" << node->patterns << ")"; }); @@ -108,8 +108,8 @@ TVM_REGISTER_NODE_TYPE(ClauseNode); TVM_REGISTER_GLOBAL("relay._make.Clause") .set_body_typed(ClauseNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "ClauseNode(" << node->lhs << ", " << node->rhs << ")"; @@ -128,8 +128,8 @@ TVM_REGISTER_NODE_TYPE(MatchNode); TVM_REGISTER_GLOBAL("relay._make.Match") .set_body_typed(MatchNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "MatchNode(" << node->data << ", " << node->clauses << ", " << node->complete << ")"; diff --git a/src/relay/ir/expr.cc b/src/relay/ir/expr.cc index 8151db416b748..27b933d7162c2 100644 --- a/src/relay/ir/expr.cc +++ b/src/relay/ir/expr.cc @@ -27,7 +27,7 @@ namespace tvm { namespace relay { -using tvm::NodePrinter; +using tvm::ReprPrinter; using namespace tvm::runtime; Constant ConstantNode::make(runtime::NDArray data) { @@ -41,8 +41,8 @@ TVM_REGISTER_NODE_TYPE(ConstantNode); TVM_REGISTER_GLOBAL("relay._make.Constant") .set_body_typed(ConstantNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); const PackedFunc* fprint = Registry::Get("relay._constant_repr"); CHECK(fprint) << "unable to find printing function for constants"; @@ -74,8 +74,8 @@ TVM_REGISTER_NODE_TYPE(TupleNode); TVM_REGISTER_GLOBAL("relay._make.Tuple") .set_body_typed(TupleNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "Tuple(" << node->fields << ")"; }); @@ -99,8 +99,8 @@ TVM_REGISTER_NODE_TYPE(VarNode); TVM_REGISTER_GLOBAL("relay._make.Var") .set_body_typed(static_cast(VarNode::make)); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "Var(" << node->name_hint(); if (node->type_annotation.defined()) { @@ -209,8 +209,8 @@ TVM_REGISTER_NODE_TYPE(FunctionNode); TVM_REGISTER_GLOBAL("relay._make.Function") .set_body_typed(FunctionNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "FunctionNode(" << node->params << ", " << node->ret_type << ", " << node->body << ", " << node->type_params << ", " @@ -232,8 +232,8 @@ TVM_REGISTER_NODE_TYPE(CallNode); TVM_REGISTER_GLOBAL("relay._make.Call") .set_body_typed(CallNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "CallNode(" << node->op << ", " << node->args << ", " << node->attrs << ", " << node->type_args << ")"; @@ -252,8 +252,8 @@ TVM_REGISTER_NODE_TYPE(LetNode); TVM_REGISTER_GLOBAL("relay._make.Let") .set_body_typed(LetNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "LetNode(" << node->var << ", " << node->value << ", " << node->body << ")"; @@ -272,8 +272,8 @@ TVM_REGISTER_NODE_TYPE(IfNode); TVM_REGISTER_GLOBAL("relay._make.If") .set_body_typed(IfNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "IfNode(" << node->cond << ", " << node->true_branch << ", " << node->false_branch << ")"; @@ -291,8 +291,8 @@ TVM_REGISTER_NODE_TYPE(TupleGetItemNode); TVM_REGISTER_GLOBAL("relay._make.TupleGetItem") .set_body_typed(TupleGetItemNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "TupleGetItemNode(" << node->tuple << ", " << node->index << ")"; }); @@ -308,8 +308,8 @@ TVM_REGISTER_NODE_TYPE(RefCreateNode); TVM_REGISTER_GLOBAL("relay._make.RefCreate") .set_body_typed(RefCreateNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "RefCreateNode(" << node->value << ")"; }); @@ -325,8 +325,8 @@ TVM_REGISTER_NODE_TYPE(RefReadNode); TVM_REGISTER_GLOBAL("relay._make.RefRead") .set_body_typed(RefReadNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "RefReadNode(" << node->ref << ")"; }); @@ -343,8 +343,8 @@ TVM_REGISTER_NODE_TYPE(RefWriteNode); TVM_REGISTER_GLOBAL("relay._make.RefWrite") .set_body_typed(RefWriteNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); p->stream << "RefWriteNode(" << node->ref << ", " << node->value << ")"; }); diff --git a/src/relay/ir/transform.cc b/src/relay/ir/transform.cc index 1f2e8ed52f8d8..ac0f36cf2205f 100644 --- a/src/relay/ir/transform.cc +++ b/src/relay/ir/transform.cc @@ -23,7 +23,7 @@ */ #include #include -#include +#include #include @@ -157,8 +157,8 @@ TVM_REGISTER_NODE_TYPE(FunctionPassNode); TVM_REGISTER_GLOBAL("relay._transform.MakeFunctionPass") .set_body_typed(FunctionPassNode::make); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* node = static_cast(ref.get()); const PassInfo info = node->Info(); p->stream << "Run Function pass: " << info->name diff --git a/src/relay/pass/quantize/quantize.cc b/src/relay/pass/quantize/quantize.cc index 2441f6e65d88b..b3a8733c45e1a 100644 --- a/src/relay/pass/quantize/quantize.cc +++ b/src/relay/pass/quantize/quantize.cc @@ -116,8 +116,8 @@ QConfig& QConfig::Current() { TVM_REGISTER_NODE_TYPE(QConfigNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& ref, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& ref, ReprPrinter* p) { auto* op = static_cast(ref.get()); p->stream << "qconfig("; p->stream << "nbit_input=" << op->nbit_input << ", "; diff --git a/src/target/generic_func.cc b/src/target/generic_func.cc index 884bf762c9403..817d48f0cdbf9 100644 --- a/src/target/generic_func.cc +++ b/src/target/generic_func.cc @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/target/target.cc b/src/target/target.cc index a75e146586f53..245425a639214 100644 --- a/src/target/target.cc +++ b/src/target/target.cc @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -39,8 +39,8 @@ using runtime::PackedFunc; TVM_REGISTER_NODE_TYPE(TargetNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << op->str(); }); @@ -381,8 +381,8 @@ tvm::BuildConfig BuildConfig::Current() { TVM_REGISTER_NODE_TYPE(BuildConfigNode); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "build_config("; p->stream << "data_alignment=" << op->data_alignment << ", "; diff --git a/src/target/target_info.cc b/src/target/target_info.cc index 6c332e77b9bad..73fe011cc9364 100644 --- a/src/target/target_info.cc +++ b/src/target/target_info.cc @@ -21,13 +21,13 @@ * \file target/target_info.cc */ #include -#include +#include #include namespace tvm { -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "mem-info(" << "unit_bits=" << op->unit_bits << ", " diff --git a/src/tir/ir/buffer.cc b/src/tir/ir/buffer.cc index c2fc581a3904c..ff67e8d9cbc26 100644 --- a/src/tir/ir/buffer.cc +++ b/src/tir/ir/buffer.cc @@ -453,8 +453,8 @@ Buffer BufferNode::make(Var data, return Buffer(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "buffer(" << op->name << ", " << op << ")"; }); diff --git a/src/tir/ir/data_layout.cc b/src/tir/ir/data_layout.cc index 59fa2af41631a..8a5125bca193f 100644 --- a/src/tir/ir/data_layout.cc +++ b/src/tir/ir/data_layout.cc @@ -198,8 +198,8 @@ int32_t Layout::FactorOf(const LayoutAxis& axis) const { return -1; } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* l = static_cast(node.get()); p->stream << "Layout(" << l->name << ")"; }); @@ -365,8 +365,8 @@ BijectiveLayout BijectiveLayoutNode::make(const Layout& src_layout, return BijectiveLayout(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* b = static_cast(node.get()); p->stream << "BijectiveLayout(" << b->src_layout.name() << "->" << b->dst_layout.name() << ")"; diff --git a/src/tir/ir/expr.cc b/src/tir/ir/expr.cc index 0cdbfdc71c97b..d06c33f79dcc6 100644 --- a/src/tir/ir/expr.cc +++ b/src/tir/ir/expr.cc @@ -57,8 +57,8 @@ IterVar IterVarNode::make(Range dom, return IterVar(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "iter_var("; if (op->var->name_hint.length() != 0) { @@ -339,8 +339,8 @@ PrimExpr AnyNode::make() { return PrimExpr(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); auto& stream = p->stream; stream << '"'; @@ -375,24 +375,24 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) stream << '"'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << op->dtype << '('; p->Print(op->value); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); // omit the type // stream << op->name << "." << op->type; p->stream << op->name_hint; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "{" << op->name_hint << "|" << op->name_hint << ">=0}"; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -400,7 +400,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -408,7 +408,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -416,7 +416,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -424,7 +424,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -432,7 +432,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "min("; p->Print(op->a); @@ -440,7 +440,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ")"; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "max("; p->Print(op->a); @@ -448,7 +448,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ")"; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -456,7 +456,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -464,7 +464,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -472,7 +472,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -480,7 +480,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -488,7 +488,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->b); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -497,20 +497,20 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ')'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "floordiv(" << op->a << ", " << op->b << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "floormod(" << op->a << ", " << op->b << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -519,8 +519,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ')'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '('; p->Print(op->a); @@ -529,15 +529,15 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ')'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << '!'; p->Print(op->a); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "select("; p->Print(op->condition); @@ -548,8 +548,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << op->buffer_var << "["; p->Print(op->index); @@ -560,8 +560,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) } }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "ramp("; p->Print(op->base); @@ -570,16 +570,16 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ", " << op->lanes << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "x" << op->lanes << "("; p->Print(op->value); p->stream << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << op->name << "("; for (size_t i = 0; i < op->args.size(); ++i) { @@ -591,8 +591,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "(let " << op->var << " = "; p->Print(op->value); @@ -601,13 +601,13 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { p->stream << "?"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "reduce(combiner=" << op->combiner; @@ -618,8 +618,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << ")"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "comm_reducer(result=" << op->result << ", lhs=" << op->lhs diff --git a/src/tir/ir/lowered_func.cc b/src/tir/ir/lowered_func.cc index a2755343fc43e..c1331fbd4c1f5 100644 --- a/src/tir/ir/lowered_func.cc +++ b/src/tir/ir/lowered_func.cc @@ -24,8 +24,8 @@ namespace tvm { namespace tir { -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "LoweredFunc(" << op->name << ", " << op << ")"; }); diff --git a/src/tir/ir/stmt.cc b/src/tir/ir/stmt.cc index 6d39d99f69395..0cd2aba319ee1 100644 --- a/src/tir/ir/stmt.cc +++ b/src/tir/ir/stmt.cc @@ -248,8 +248,8 @@ Stmt EvaluateNode::make(PrimExpr value) { // Printers -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "let " << op->var << " = "; @@ -258,8 +258,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->body); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "// attr ["; @@ -271,8 +271,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->body); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "assert("; @@ -283,8 +283,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->body); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); if (op->is_producer) { p->PrintIndent(); @@ -317,8 +317,8 @@ std::ostream &operator<<(std::ostream& out, ForType type) { // NOLINT(*) return out; } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << op->for_type << " (" << op->loop_var << ", "; @@ -335,8 +335,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << "}\n"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << op->buffer_var << "["; @@ -350,8 +350,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << '\n'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << op->func->func_name() << "("; @@ -368,8 +368,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << '\n'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "allocate " << op->buffer_var << "[" << op->dtype; @@ -386,16 +386,16 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->body); }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "free " << op->buffer_var; p->stream << '\n'; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "realize " << op->func->func_name() << "("; @@ -425,8 +425,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << "}\n"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->stream << "prefetch " << op->func->func_name() << "("; @@ -444,16 +444,16 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) } }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); for (Stmt stmt : op->seq) { p->Print(stmt); } }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); while (true) { @@ -483,8 +483,8 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << "}\n"; }); -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->PrintIndent(); p->Print(op->value); @@ -492,7 +492,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) }); template -void PrintList(const Array &exprs, NodePrinter* p) { +void PrintList(const Array &exprs, ReprPrinter* p) { for (size_t i = 0; i < exprs.size(); ++i) { p->Print(exprs[i]); if (i < exprs.size() - 1) { @@ -501,8 +501,8 @@ void PrintList(const Array &exprs, NodePrinter* p) { } } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "shuffle("; PrintList(op->vectors, p); diff --git a/src/top/operation/compute_op.cc b/src/top/operation/compute_op.cc index f325ae85002c2..598a0f74405d8 100644 --- a/src/top/operation/compute_op.cc +++ b/src/top/operation/compute_op.cc @@ -39,8 +39,8 @@ namespace tvm { namespace top { using namespace tir; -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "compute(" << op->name << ", " << op << ")"; }); diff --git a/src/top/operation/extern_op.cc b/src/top/operation/extern_op.cc index 276b5ebf6bc70..8bc812e52a23f 100644 --- a/src/top/operation/extern_op.cc +++ b/src/top/operation/extern_op.cc @@ -31,8 +31,8 @@ namespace tvm { namespace top { using namespace tir; // ExternOpNode -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "extern(" << op->name << ", " << op << ")"; }); diff --git a/src/top/operation/hybrid_op.cc b/src/top/operation/hybrid_op.cc index f4e3850650a3c..4c1ab7073c891 100644 --- a/src/top/operation/hybrid_op.cc +++ b/src/top/operation/hybrid_op.cc @@ -37,8 +37,8 @@ namespace tvm { namespace top { using namespace tir; // HybridOpNode -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "hybrid(" << op->name << ", " << op << ")"; }); diff --git a/src/top/operation/placeholder_op.cc b/src/top/operation/placeholder_op.cc index 284752b3661c5..13311a8941238 100644 --- a/src/top/operation/placeholder_op.cc +++ b/src/top/operation/placeholder_op.cc @@ -27,8 +27,8 @@ namespace tvm { namespace top { // PlaceholderOpNode -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "placeholder(" << op->name << ", " << op << ")"; }); diff --git a/src/top/operation/scan_op.cc b/src/top/operation/scan_op.cc index 2ddb6bd11cc8f..62ddecb2851f7 100644 --- a/src/top/operation/scan_op.cc +++ b/src/top/operation/scan_op.cc @@ -31,8 +31,8 @@ namespace tvm { namespace top { using namespace tir; -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "scan(" << op->name << ", " << op << ")"; }); diff --git a/src/top/operation/tensor_compute_op.cc b/src/top/operation/tensor_compute_op.cc index 2cc8219288091..5011c1662296b 100644 --- a/src/top/operation/tensor_compute_op.cc +++ b/src/top/operation/tensor_compute_op.cc @@ -34,8 +34,8 @@ namespace tvm { namespace top { using namespace tir; // TensorComputeOpNode -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "tensor_compute_op(" << op->name << ", " << op << ")"; }); diff --git a/src/top/schedule/schedule_lang.cc b/src/top/schedule/schedule_lang.cc index 10d5ddc48b7b3..130d06bda8482 100644 --- a/src/top/schedule/schedule_lang.cc +++ b/src/top/schedule/schedule_lang.cc @@ -795,8 +795,8 @@ TVM_REGISTER_NODE_TYPE(SingletonNode); TVM_REGISTER_NODE_TYPE(ScheduleNode); // Printer -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); if (op->op.defined()) { p->stream << "stage(" << op->origin_op->name << ", " << op << ")"; @@ -804,11 +804,11 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->stream << "group-stage(" << op << ")"; } }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << IterVarType2String(op->iter_type); }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "split(parent="; p->Print(op->parent); @@ -818,7 +818,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->inner); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "split("; p->stream << "outer="; @@ -829,7 +829,7 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->fused); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "rebase("; p->stream << "parent="; @@ -838,13 +838,13 @@ TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) p->Print(op->rebased); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "singleton("; p->Print(op->iter); p->stream << ')'; }) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "schedule(" << op << ")"; }); diff --git a/src/top/tensor.cc b/src/top/tensor.cc index c848cc4b43674..85232b9f719c6 100644 --- a/src/top/tensor.cc +++ b/src/top/tensor.cc @@ -82,8 +82,8 @@ Tensor TensorNode::make(Array shape, return Tensor(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* t = static_cast(node.get()); p->stream << "Tensor(shape=" << t->shape << ", op.name=" << t->op->name << ')'; @@ -114,8 +114,8 @@ TensorIntrin TensorIntrinNode::make(std::string name, return TensorIntrin(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* op = static_cast(node.get()); p->stream << "TensorIntrin(name=" << op->name << ", " << op << ")"; }); @@ -139,8 +139,8 @@ TensorIntrinCall TensorIntrinCallNode::make(TensorIntrin intrin, return TensorIntrinCall(n); } -TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable) -.set_dispatch([](const ObjectRef& node, NodePrinter* p) { +TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) +.set_dispatch([](const ObjectRef& node, ReprPrinter* p) { auto* n = static_cast(node.get()); p->stream << "TensorIntrinCall(intrin=" << n->intrin << ", " << n << ")"; });