Rationale: printer is a common infra that is shared across all nodes.
}
return ret;
}
-
-// Printer infra.
-/*! \brief A Pretty printer class to print the IR. */
-class IRPrinter {
- public:
- /*! \brief The output stream */
- std::ostream& stream;
- /*! \brief The indentation level. */
- int indent{0};
- explicit IRPrinter(std::ostream& stream) // NOLINT(*)
- : stream(stream) {}
-
- /*! \brief The node to be printed. */
- TVM_DLL void Print(const ObjectRef& node);
- /*! \brief Print indent to the stream */
- TVM_DLL void PrintIndent();
- // Allow registration to be printer.
- using FType = NodeFunctor<void(const ObjectRef&, IRPrinter *)>;
- TVM_DLL static FType& vtable();
-};
-} // namespace tvm
-
-namespace tvm {
-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(*)
- IRPrinter(os).Print(n);
- return os;
-}
-} // namespace runtime
} // namespace tvm
namespace std {
#define TVM_NODE_FUNCTOR_H_
#include <dmlc/logging.h>
-#include <tvm/runtime/registry.h>
-#include <tvm/node/node.h>
+#include <tvm/runtime/object.h>
#include <vector>
#include <type_traits>
#include <utility>
namespace tvm {
+
+using runtime::ObjectRef;
+
/*!
* \brief A dynamically dispatched functor on the type of the first argument.
*
* \brief Useful macro to set NodeFunctor dispatch in a global static field.
*
* \code
- * // Use NodeFunctor to implement IRPrinter similar to Visitor Pattern.
+ * // Use NodeFunctor to implement NodePrinter similar to Visitor Pattern.
* // vtable allows easy patch of new Node types, without changing
- * // interface of IRPrinter.
+ * // interface of NodePrinter.
*
- * class IRPrinter {
+ * class NodePrinter {
* public:
* std::ostream& stream;
* // the dispatch function.
* f(e, this);
* }
*
- * using FType = NodeFunctor<void (const ObjectRef&, IRPrinter *)>;
+ * using FType = NodeFunctor<void (const ObjectRef&, NodePrinter* )>;
* // function to return global function table
* static FType& vtable();
* };
*
* // in cpp/cc file
- * IRPrinter::FType& IRPrinter::vtable() { // NOLINT(*)
+ * NodePrinter::FType& NodePrinter::vtable() { // NOLINT(*)
* static FType inst; return inst;
* }
*
- * TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
- * .set_dispatch<Add>([](const ObjectRef& ref, IRPrinter* p) {
+ * TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+ * .set_dispatch<Add>([](const ObjectRef& ref, NodePrinter* p) {
* auto* n = static_cast<const Add*>(ref.get());
* p->print(n->a);
* p->stream << '+'
#include <tvm/runtime/object.h>
#include <tvm/runtime/memory.h>
#include <tvm/node/reflection.h>
+#include <tvm/node/printer.h>
#include <string>
#include <vector>
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*!
+ * \file tvm/node/printer.h
+ * \brief Printer class to print repr string of each AST/IR nodes.
+ */
+#ifndef TVM_NODE_PRINTER_H_
+#define TVM_NODE_PRINTER_H_
+
+#include <tvm/node/functor.h>
+#include <iostream>
+
+namespace tvm {
+/*! \brief A printer class to print the AST/IR nodes. */
+class NodePrinter {
+ public:
+ /*! \brief The output stream */
+ std::ostream& stream;
+ /*! \brief The indentation level. */
+ int indent{0};
+
+ explicit NodePrinter(std::ostream& stream) // NOLINT(*)
+ : stream(stream) {}
+
+ /*! \brief The node to be printed. */
+ TVM_DLL void Print(const ObjectRef& node);
+ /*! \brief Print indent to the stream */
+ TVM_DLL void PrintIndent();
+ // Allow registration to be printer.
+ using FType = NodeFunctor<void(const ObjectRef&, NodePrinter*)>;
+ TVM_DLL static FType& vtable();
+};
+} // namespace tvm
+
+namespace tvm {
+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);
+ return os;
+}
+} // namespace runtime
+} // namespace tvm
+#endif // TVM_NODE_PRINTER_H_
}
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ConstIntBoundNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ConstIntBoundNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ConstIntBoundNode*>(node.get());
p->stream << "ConstIntBound[";
PrintBoundValue(p->stream, op->min_value);
TVM_REGISTER_NODE_TYPE(IntervalSetNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<IntervalSetNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<IntervalSetNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const IntervalSetNode*>(node.get());
p->stream << "IntervalSet"
<< "[" << op->min_value << ", "
data_ = std::move(node);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ModularSetNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ModularSetNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ModularSetNode*>(node.get());
p->stream << "ModularSet("
<< "coeff=" << op->coeff << ", base="
TVM_REGISTER_NODE_TYPE(TargetNode);
TVM_REGISTER_NODE_TYPE(GenericFuncNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TargetNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TargetNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const TargetNode*>(node.get());
p->stream << op->str();
});
TVM_REGISTER_NODE_TYPE(BuildConfigNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<BuildConfigNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<BuildConfigNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const BuildConfigNode*>(node.get());
p->stream << "build_config(";
p->stream << "data_alignment=" << op->data_alignment << ", ";
* \brief ARM specific code generator
*/
#ifdef TVM_LLVM_VERSION
+
+#include <tvm/runtime/registry.h>
+
#include "codegen_cpu.h"
namespace tvm {
* \brief X86-64 specific code generator
*/
#ifdef TVM_LLVM_VERSION
+
+#include <tvm/runtime/registry.h>
#include "codegen_cpu.h"
#include "llvm/MC/MCSubtargetInfo.h"
* \brief LLVM runtime module for TVM
*/
#ifdef TVM_LLVM_VERSION
+
#include <tvm/runtime/packed_func.h>
+#include <tvm/runtime/registry.h>
#include <tvm/codegen.h>
#include <mutex>
#include "llvm_common.h"
* \brief Source code module, only for viewing
*/
#include <tvm/runtime/packed_func.h>
+#include <tvm/runtime/registry.h>
#include "codegen_source_base.h"
#include "../runtime/file_util.h"
#include "../runtime/meta_data.h"
/*!
* \file codegen_hybrid.cc
*/
+#include <tvm/runtime/registry.h>
#include <iomanip>
#include <cctype>
#include "codegen_hybrid.h"
* \brief The span data structure.
*/
#include <tvm/ir/span.h>
+#include <tvm/runtime/registry.h>
#include <tvm/packed_func_ext.h>
namespace tvm {
TVM_REGISTER_GLOBAL("relay._make.SourceName")
.set_body_typed(SourceName::Get);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<SourceNameNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<SourceNameNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const SourceNameNode*>(ref.get());
p->stream << "SourceName(" << node->name << ", " << node << ")";
});
TVM_REGISTER_GLOBAL("relay._make.Span")
.set_body_typed(SpanNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<SpanNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<SpanNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const SpanNode*>(ref.get());
p->stream << "Span(" << node->source << ", " << node->lineno << ", "
<< node->col_offset << ")";
* \brief Common type system AST nodes throughout the IR.
*/
#include <tvm/ir/type.h>
+#include <tvm/runtime/registry.h>
#include <tvm/packed_func_ext.h>
namespace tvm {
return TypeVarNode::make(name, static_cast<TypeKind>(kind));
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TypeVarNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TypeVarNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TypeVarNode*>(ref.get());
p->stream << "TypeVar(" << node->name_hint << ", "
<< node->kind << ")";
return GlobalTypeVarNode::make(name, static_cast<TypeKind>(kind));
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<GlobalTypeVarNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<GlobalTypeVarNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const GlobalTypeVarNode*>(ref.get());
p->stream << "GlobalTypeVar(" << node->name_hint << ", "
<< node->kind << ")";
TVM_REGISTER_GLOBAL("relay._make.FuncType")
.set_body_typed(FuncTypeNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<FuncTypeNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<FuncTypeNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const FuncTypeNode*>(ref.get());
p->stream << "FuncType(" << node->type_params << ", "
<< node->arg_types << ", " << node->ret_type << ", "
return Attrs(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<DictAttrsNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<DictAttrsNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const DictAttrsNode*>(node.get());
p->stream << op->dict;
});
return Buffer(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<BufferNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<BufferNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const BufferNode*>(node.get());
p->stream << "buffer(" << op->name << ", " << op << ")";
});
return -1;
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<LayoutNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<LayoutNode>([](const ObjectRef& node, NodePrinter* p) {
auto* l = static_cast<const LayoutNode*>(node.get());
p->stream << "Layout(" << l->name << ")";
});
return BijectiveLayout(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<BijectiveLayoutNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<BijectiveLayoutNode>([](const ObjectRef& node, NodePrinter* p) {
auto* b = static_cast<const BijectiveLayoutNode*>(node.get());
p->stream << "BijectiveLayout(" << b->src_layout.name()
<< "->" << b->dst_layout.name() << ")";
return Var(name_hint, t);
}
-void IRPrinter::Print(const ObjectRef& ir) {
- static const FType& f = vtable();
- if (!ir.defined()) {
- stream << "(nullptr)";
- } else {
- if (f.can_dispatch(ir)) {
- f(ir, this);
- } else {
- // default value, output type key and addr.
- stream << ir->GetTypeKey() << "(" << ir.get() << ")";
- }
- }
-}
-
-void IRPrinter::PrintIndent() {
- for (int i = 0; i < indent; ++i) {
- stream << ' ';
- }
-}
-
-IRPrinter::FType& IRPrinter::vtable() {
- static FType inst;
- return inst;
-}
-
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<IntImm>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<IntImm>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const IntImm*>(node.get());
if (op->dtype == DataType::Int(32)) {
p->stream << op->value;
}
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<IterVarNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<IterVarNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const IterVarNode*>(node.get());
p->stream << "iter_var(";
if (op->var->name_hint.length() != 0) {
p->stream << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RangeNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RangeNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const RangeNode*>(node.get());
p->stream << "range(min=" << op->min << ", ext=" << op->extent << ')';
});
}
// Printers
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<UIntImm>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<UIntImm>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const UIntImm*>(node.get());
p->stream << "(" << op->dtype << ")" << op->value;
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<FloatImm>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<FloatImm>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const FloatImm*>(node.get());
auto& stream = p->stream;
switch (op->dtype.bits()) {
}
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<StringImm>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<StringImm>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const StringImm*>(node.get());
auto& stream = p->stream;
stream << '"';
stream << '"';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Cast>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Cast>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Cast*>(node.get());
p->stream << op->dtype << '(';
p->Print(op->value);
p->stream << ')';
})
-.set_dispatch<Variable>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Variable>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Variable*>(node.get());
// omit the type
// stream << op->name << "." << op->type;
p->stream << op->name_hint;
})
-.set_dispatch<Add>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Add>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Add*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<Sub>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Sub>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Sub*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<Mul>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Mul>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Mul*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<Div>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Div>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Div*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<Mod>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Mod>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Mod*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<Min>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Min>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Min*>(node.get());
p->stream << "min(";
p->Print(op->a);
p->Print(op->b);
p->stream << ")";
})
-.set_dispatch<Max>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<Max>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Max*>(node.get());
p->stream << "max(";
p->Print(op->a);
p->Print(op->b);
p->stream << ")";
})
-.set_dispatch<EQ>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<EQ>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const EQ*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<NE>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<NE>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const NE*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<LT>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<LT>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const LT*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<LE>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<LE>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const LE*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<GT>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<GT>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const GT*>(node.get());
p->stream << '(';
p->Print(op->a);
p->Print(op->b);
p->stream << ')';
})
-.set_dispatch<GE>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<GE>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const GE*>(node.get());
p->stream << '(';
p->Print(op->a);
p->stream << ')';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<FloorDiv>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<FloorDiv>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const FloorDiv*>(node.get());
p->stream << "floordiv(" << op->a << ", " << op->b << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<FloorMod>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<FloorMod>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const FloorMod*>(node.get());
p->stream << "floormod(" << op->a << ", " << op->b << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<And>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<And>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const And*>(node.get());
p->stream << '(';
p->Print(op->a);
p->stream << ')';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Or>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Or>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Or*>(node.get());
p->stream << '(';
p->Print(op->a);
p->stream << ')';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Not>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Not>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Not*>(node.get());
p->stream << '!';
p->Print(op->a);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Select>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Select>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Select*>(node.get());
p->stream << "select(";
p->Print(op->condition);
p->stream << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Load>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Load>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Load*>(node.get());
p->stream << op->buffer_var << "[";
p->Print(op->index);
}
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Ramp>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Ramp>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Ramp*>(node.get());
p->stream << "ramp(";
p->Print(op->base);
p->stream << ", " << op->lanes << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Broadcast>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Broadcast>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Broadcast*>(node.get());
p->stream << "x" << op->lanes << "(";
p->Print(op->value);
p->stream << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Call>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Call>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Call*>(node.get());
p->stream << op->name << "(";
for (size_t i = 0; i < op->args.size(); ++i) {
p->stream << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Let>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Let>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Let*>(node.get());
p->stream << "(let " << op->var << " = ";
p->Print(op->value);
p->stream << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<LetStmt>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<LetStmt>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const LetStmt*>(node.get());
p->PrintIndent();
p->stream << "let " << op->var << " = ";
p->Print(op->body);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<AttrStmt>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<AttrStmt>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const AttrStmt*>(node.get());
p->PrintIndent();
p->stream << "// attr [";
p->Print(op->body);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<AssertStmt>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<AssertStmt>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const AssertStmt*>(node.get());
p->PrintIndent();
p->stream << "assert(";
p->Print(op->body);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ProducerConsumer>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ProducerConsumer>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ProducerConsumer*>(node.get());
if (op->is_producer) {
p->PrintIndent();
return out;
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<For>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<For>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const For*>(node.get());
p->PrintIndent();
p->stream << op->for_type << " (" << op->loop_var << ", ";
p->stream << "}\n";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Store>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Store>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Store*>(node.get());
p->PrintIndent();
p->stream << op->buffer_var << "[";
p->stream << '\n';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Provide>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Provide>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Provide*>(node.get());
p->PrintIndent();
p->stream << op->func->func_name() << "(";
p->stream << '\n';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Allocate>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Allocate>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Allocate*>(node.get());
p->PrintIndent();
p->stream << "allocate " << op->buffer_var << "[" << op->dtype;
p->Print(op->body);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Free>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Free>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Free*>(node.get());
p->PrintIndent();
p->stream << "free " << op->buffer_var;
p->stream << '\n';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Realize>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Realize>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Realize*>(node.get());
p->PrintIndent();
p->stream << "realize " << op->func->func_name() << "(";
p->stream << "}\n";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Prefetch>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Prefetch>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Prefetch*>(node.get());
p->PrintIndent();
p->stream << "prefetch " << op->func->func_name() << "(";
}
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Block>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Block>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Block*>(node.get());
p->Print(op->first);
if (op->rest.defined()) p->Print(op->rest);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<IfThenElse>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<IfThenElse>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const IfThenElse*>(node.get());
p->PrintIndent();
while (true) {
p->stream << "}\n";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Evaluate>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Evaluate>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Evaluate*>(node.get());
p->PrintIndent();
p->Print(op->value);
});
template<typename T>
-void PrintList(const Array<T> &exprs, IRPrinter* p) {
+void PrintList(const Array<T> &exprs, NodePrinter* p) {
for (size_t i = 0; i < exprs.size(); ++i) {
p->Print(exprs[i]);
if (i < exprs.size() - 1) {
}
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Shuffle>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Shuffle>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Shuffle*>(node.get());
p->stream << "shuffle(";
PrintList(op->vectors, p);
});
// Container printer
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ArrayNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ArrayNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ArrayNode*>(node.get());
p->stream << '[';
for (size_t i = 0 ; i < op->data.size(); ++i) {
p->stream << ']';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<MapNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<MapNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const MapNode*>(node.get());
p->stream << '{';
for (auto it = op->data.begin(); it != op->data.end(); ++it) {
p->stream << '}';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<StrMapNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<StrMapNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const StrMapNode*>(node.get());
p->stream << '{';
for (auto it = op->data.begin(); it != op->data.end(); ++it) {
p->stream << '}';
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Reduce>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Reduce>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const Reduce*>(node.get());
p->stream << "reduce(combiner="
<< op->combiner;
p->stream << ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<CommReducerNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<CommReducerNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const CommReducerNode*>(node.get());
p->stream << "comm_reducer(result=" << op->result
<< ", lhs=" << op->lhs
<< ")";
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<Any>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<Any>([](const ObjectRef& node, NodePrinter* p) {
p->stream << "?";
});
namespace tvm {
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<LoweredFuncNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<LoweredFuncNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const LoweredFuncNode*>(node.get());
p->stream << "LoweredFunc(" << op->name << ", " << op << ")";
});
namespace tvm {
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<MemoryInfoNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<MemoryInfoNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const MemoryInfoNode*>(node.get());
p->stream << "mem-info("
<< "unit_bits=" << op->unit_bits << ", "
return Tensor(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TensorNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TensorNode>([](const ObjectRef& node, NodePrinter* p) {
auto* t = static_cast<const TensorNode*>(node.get());
p->stream << "Tensor(shape=" << t->shape
<< ", op.name=" << t->op->name << ')';
return TensorIntrin(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TensorIntrinNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TensorIntrinNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const TensorIntrinNode*>(node.get());
p->stream << "TensorIntrin(name=" << op->name << ", " << op << ")";
});
return TensorIntrinCall(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TensorIntrinCallNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TensorIntrinCallNode>([](const ObjectRef& node, NodePrinter* p) {
auto* n = static_cast<const TensorIntrinCallNode*>(node.get());
p->stream << "TensorIntrinCall(intrin=" << n->intrin << ", " << n << ")";
});
namespace tvm {
+
using runtime::PackedFunc;
using runtime::TVMArgs;
using runtime::TVMRetValue;
-
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<EnvFuncNode>([](const ObjectRef& node, IRPrinter *p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<EnvFuncNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const EnvFuncNode*>(node.get());
p->stream << "EnvFunc(" << op->name << ")";
});
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * Printer utilities
+ * \file node/printer.cc
+ */
+#include <tvm/node/printer.h>
+
+namespace tvm {
+
+void NodePrinter::Print(const ObjectRef& node) {
+ static const FType& f = vtable();
+ if (!node.defined()) {
+ stream << "(nullptr)";
+ } else {
+ if (f.can_dispatch(node)) {
+ f(node, this);
+ } else {
+ // default value, output type key and addr.
+ stream << node->GetTypeKey() << "(" << node.get() << ")";
+ }
+ }
+}
+
+void NodePrinter::PrintIndent() {
+ for (int i = 0; i < indent; ++i) {
+ stream << ' ';
+ }
+}
+
+NodePrinter::FType& NodePrinter::vtable() {
+ static FType inst;
+ return inst;
+}
+} // namespace tvm
using namespace ir;
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ComputeOpNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ComputeOpNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ComputeOpNode*>(node.get());
p->stream << "compute(" << op->name << ", " << op << ")";
});
namespace tvm {
using namespace ir;
// ExternOpNode
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ExternOpNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ExternOpNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ExternOpNode*>(node.get());
p->stream << "extern(" << op->name << ", " << op << ")";
});
namespace tvm {
using namespace ir;
// HybridOpNode
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<HybridOpNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<HybridOpNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const HybridOpNode*>(node.get());
p->stream << "hybrid(" << op->name << ", " << op << ")";
});
namespace tvm {
// PlaceholderOpNode
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PlaceholderOpNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PlaceholderOpNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const PlaceholderOpNode*>(node.get());
p->stream << "placeholder(" << op->name << ", " << op << ")";
});
using namespace ir;
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ScanOpNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ScanOpNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ScanOpNode*>(node.get());
p->stream << "scan(" << op->name << ", " << op << ")";
});
namespace tvm {
using namespace ir;
// TensorComputeOpNode
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TensorComputeOpNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TensorComputeOpNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const TensorComputeOpNode*>(node.get());
p->stream << "tensor_compute_op(" << op->name << ", " << op << ")";
});
TVM_REGISTER_GLOBAL("relay._make.Closure")
.set_body_typed(ClosureNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ClosureNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ClosureNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ClosureNode*>(ref.get());
p->stream << "ClosureNode(" << node->func << ", " << node->env << ")";
});
TVM_REGISTER_GLOBAL("relay._make.RecClosure")
.set_body_typed(RecClosureNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RecClosureNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RecClosureNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const RecClosureNode*>(ref.get());
p->stream << "RecClosureNode(" << node->clos << ")";
});
TVM_REGISTER_GLOBAL("relay._make.TupleValue")
.set_body_typed(TupleValueNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TupleValueNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TupleValueNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TupleValueNode*>(ref.get());
p->stream << "TupleValueNode(" << node->fields << ")";
});
return TensorValue(n);
}
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TensorValueNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TensorValueNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TensorValueNode*>(ref.get());
auto to_str = GetPackedFunc("relay._tensor_value_repr");
std::string data_str = to_str(GetRef<TensorValue>(node));
TVM_REGISTER_NODE_TYPE(RefValueNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RefValueNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RefValueNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const RefValueNode*>(ref.get());
p->stream << "RefValueNode(" << node->value << ")";
});
TVM_REGISTER_NODE_TYPE(ConstructorValueNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ConstructorValueNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ConstructorValueNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ConstructorValueNode*>(ref.get());
p->stream << "ConstructorValueNode(" << node->tag << ","
<< node->fields << ")";
TVM_REGISTER_GLOBAL("relay._make.PatternWildcard")
.set_body_typed(PatternWildcardNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PatternWildcardNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PatternWildcardNode>([](const ObjectRef& ref, NodePrinter* p) {
p->stream << "PatternWildcardNode()";
});
TVM_REGISTER_GLOBAL("relay._make.PatternVar")
.set_body_typed(PatternVarNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PatternVarNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PatternVarNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const PatternVarNode*>(ref.get());
p->stream << "PatternVarNode(" << node->var << ")";
});
TVM_REGISTER_GLOBAL("relay._make.PatternConstructor")
.set_body_typed(PatternConstructorNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PatternConstructorNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PatternConstructorNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const PatternConstructorNode*>(ref.get());
p->stream << "PatternConstructorNode(" << node->constructor
<< ", " << node->patterns << ")";
TVM_REGISTER_GLOBAL("relay._make.PatternTuple")
.set_body_typed(PatternTupleNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PatternTupleNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PatternTupleNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const PatternTupleNode*>(ref.get());
p->stream << "PatternTupleNode(" << node->patterns << ")";
});
TVM_REGISTER_GLOBAL("relay._make.Constructor")
.set_body_typed(ConstructorNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ConstructorNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ConstructorNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ConstructorNode*>(ref.get());
p->stream << "ConstructorNode(" << node->name_hint << ", "
<< node->inputs << ", " << node->belong_to << ")";
TVM_REGISTER_GLOBAL("relay._make.TypeData")
.set_body_typed(TypeDataNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TypeDataNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TypeDataNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TypeDataNode*>(ref.get());
p->stream << "TypeDataNode(" << node->header << ", " << node->type_vars << ", "
<< node->constructors << ")";
TVM_REGISTER_GLOBAL("relay._make.Clause")
.set_body_typed(ClauseNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ClauseNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ClauseNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ClauseNode*>(ref.get());
p->stream << "ClauseNode(" << node->lhs << ", "
<< node->rhs << ")";
TVM_REGISTER_GLOBAL("relay._make.Match")
.set_body_typed(MatchNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<MatchNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<MatchNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const MatchNode*>(ref.get());
p->stream << "MatchNode(" << node->data << ", "
<< node->clauses << ", " << node->complete << ")";
namespace tvm {
namespace relay {
-using tvm::IRPrinter;
+using tvm::NodePrinter;
using namespace tvm::runtime;
Constant ConstantNode::make(runtime::NDArray data) {
TVM_REGISTER_GLOBAL("relay._make.Constant")
.set_body_typed(ConstantNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ConstantNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ConstantNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ConstantNode*>(ref.get());
const PackedFunc* fprint = Registry::Get("relay._constant_repr");
CHECK(fprint) << "unable to find printing function for constants";
TVM_REGISTER_GLOBAL("relay._make.Tuple")
.set_body_typed(TupleNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TupleNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TupleNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TupleNode*>(ref.get());
p->stream << "Tuple(" << node->fields << ")";
});
TVM_REGISTER_GLOBAL("relay._make.Var")
.set_body_typed(static_cast<Var (*)(std::string, Type)>(VarNode::make));
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<VarNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<VarNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const VarNode*>(ref.get());
p->stream << "Var(" << node->name_hint();
if (node->type_annotation.defined()) {
TVM_REGISTER_GLOBAL("relay._make.GlobalVar")
.set_body_typed(GlobalVarNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<GlobalVarNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<GlobalVarNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const GlobalVarNode*>(ref.get());
p->stream << "GlobalVar(" << node->name_hint << ")";
});
TVM_REGISTER_GLOBAL("relay._make.Function")
.set_body_typed(FunctionNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<FunctionNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<FunctionNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const FunctionNode*>(ref.get());
p->stream << "FunctionNode(" << node->params << ", " << node->ret_type
<< ", " << node->body << ", " << node->type_params << ", "
TVM_REGISTER_GLOBAL("relay._make.Call")
.set_body_typed(CallNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<CallNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<CallNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const CallNode*>(ref.get());
p->stream << "CallNode(" << node->op << ", " << node->args << ", "
<< node->attrs << ", " << node->type_args << ")";
TVM_REGISTER_GLOBAL("relay._make.Let")
.set_body_typed(LetNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<LetNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<LetNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const LetNode*>(ref.get());
p->stream << "LetNode(" << node->var << ", " << node->value
<< ", " << node->body << ")";
TVM_REGISTER_GLOBAL("relay._make.If")
.set_body_typed(IfNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<IfNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<IfNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const IfNode*>(ref.get());
p->stream << "IfNode(" << node->cond << ", " << node->true_branch
<< ", " << node->false_branch << ")";
TVM_REGISTER_GLOBAL("relay._make.TupleGetItem")
.set_body_typed(TupleGetItemNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TupleGetItemNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TupleGetItemNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TupleGetItemNode*>(ref.get());
p->stream << "TupleGetItemNode(" << node->tuple << ", " << node->index << ")";
});
TVM_REGISTER_GLOBAL("relay._make.RefCreate")
.set_body_typed(RefCreateNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RefCreateNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RefCreateNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const RefCreateNode*>(ref.get());
p->stream << "RefCreateNode(" << node->value << ")";
});
TVM_REGISTER_GLOBAL("relay._make.RefRead")
.set_body_typed(RefReadNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RefReadNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RefReadNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const RefReadNode*>(ref.get());
p->stream << "RefReadNode(" << node->ref << ")";
});
TVM_REGISTER_GLOBAL("relay._make.RefWrite")
.set_body_typed(RefWriteNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RefWriteNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RefWriteNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const RefWriteNode*>(ref.get());
p->stream << "RefWriteNode(" << node->ref << ", " << node->value << ")";
});
namespace tvm {
namespace relay {
-using tvm::IRPrinter;
+using tvm::NodePrinter;
using namespace runtime;
Module ModuleNode::make(tvm::Map<GlobalVar, Function> global_funcs,
mod->ImportFromStd(path);
});;
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ModuleNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ModuleNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ModuleNode*>(ref.get());
p->stream << "ModuleNode( " << node->functions << ")";
});
return static_cast<const OpNode*>(n)->name;
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<OpNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<OpNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const OpNode*>(ref.get());
p->stream << "Op(" << node->name << ")";
});
namespace tvm {
namespace relay {
-using tvm::IRPrinter;
+using tvm::NodePrinter;
using namespace tvm::runtime;
TensorType TensorTypeNode::make(Array<IndexExpr> shape, DataType dtype) {
TVM_REGISTER_GLOBAL("relay._make.TensorType")
.set_body_typed(TensorTypeNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TensorTypeNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TensorTypeNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TensorTypeNode*>(ref.get());
p->stream << "TensorType(" << node->shape << ", " << node->dtype << ")";
});
TVM_REGISTER_GLOBAL("relay._make.TypeCall")
.set_body_typed(TypeCallNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TypeCallNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TypeCallNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TypeCallNode*>(ref.get());
p->stream << "TypeCallNode(" << node->func << ", "
<< node->args << ")";
return IncompleteTypeNode::make(static_cast<Kind>(kind));
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<IncompleteTypeNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<IncompleteTypeNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const IncompleteTypeNode*>(ref.get());
p->stream << "IncompleteTypeNode(" << node->kind << ", " << node << ")";
});
TVM_REGISTER_GLOBAL("relay._make.TypeRelation")
.set_body_typed(TypeRelationNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TypeRelationNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TypeRelationNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TypeRelationNode*>(ref.get());
p->stream << "TypeRelationNode("
<< node->func->name
TVM_REGISTER_GLOBAL("relay._make.TupleType")
.set_body_typed(TupleTypeNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<TupleTypeNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<TupleTypeNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const TupleTypeNode*>(ref.get());
p->stream << "TupleTypeNode(" << node->fields << ")";
});
TVM_REGISTER_NODE_TYPE(RefTypeNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<RefTypeNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<RefTypeNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const RefTypeNode*>(ref.get());
p->stream << "RefTypeNode(" << node->value << ")";
});
namespace relay {
namespace transform {
-using tvm::IRPrinter;
+using tvm::NodePrinter;
struct RelayPassContextThreadLocalEntry {
/*! \brief The default pass context. */
*ret = pass->Info();
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PassInfoNode>([](const ObjectRef& ref, tvm::IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PassInfoNode>([](const ObjectRef& ref, tvm::NodePrinter* p) {
auto* node = static_cast<const PassInfoNode*>(ref.get());
p->stream << "The meta data of the pass: ";
p->stream << "pass name: " << node->name;
*ret = pass(mod);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<ModulePassNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<ModulePassNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const ModulePassNode*>(ref.get());
const PassInfo info = node->Info();
p->stream << "Run Module pass: " << info->name
TVM_REGISTER_GLOBAL("relay._transform.MakeFunctionPass")
.set_body_typed(FunctionPassNode::make);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<FunctionPassNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<FunctionPassNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const FunctionPassNode*>(ref.get());
const PassInfo info = node->Info();
p->stream << "Run Function pass: " << info->name
*ret = Sequential(passes, pass_info);
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<SequentialNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<SequentialNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const SequentialNode*>(ref.get());
const PassInfo info = node->Info();
p->stream << "Run Sequential pass: " << info->name
*ret = pctx;
});
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<PassContextNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<PassContextNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* node = static_cast<const PassContextNode*>(ref.get());
p->stream << "Pass context information: " << "\n";
p->stream << "\topt_level: " << node->opt_level << "\n";
TVM_REGISTER_NODE_TYPE(QConfigNode);
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<QConfigNode>([](const ObjectRef& ref, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<QConfigNode>([](const ObjectRef& ref, NodePrinter* p) {
auto* op = static_cast<const QConfigNode*>(ref.get());
p->stream << "qconfig(";
p->stream << "nbit_input=" << op->nbit_input << ", ";
TVM_REGISTER_NODE_TYPE(ScheduleNode);
// Printer
-TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
-.set_dispatch<StageNode>([](const ObjectRef& node, IRPrinter* p) {
+TVM_STATIC_IR_FUNCTOR(NodePrinter, vtable)
+.set_dispatch<StageNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const StageNode*>(node.get());
if (op->op.defined()) {
p->stream << "stage(" << op->origin_op->name << ", " << op << ")";
p->stream << "group-stage(" << op << ")";
}
})
-.set_dispatch<IterVarAttrNode>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<IterVarAttrNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const IterVarAttrNode*>(node.get());
p->stream << IterVarType2String(op->iter_type);
})
-.set_dispatch<SplitNode>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<SplitNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const SplitNode*>(node.get());
p->stream << "split(parent=";
p->Print(op->parent);
p->Print(op->inner);
p->stream << ')';
})
-.set_dispatch<FuseNode>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<FuseNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const FuseNode*>(node.get());
p->stream << "split(";
p->stream << "outer=";
p->Print(op->fused);
p->stream << ')';
})
-.set_dispatch<RebaseNode>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<RebaseNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const RebaseNode*>(node.get());
p->stream << "rebase(";
p->stream << "parent=";
p->Print(op->rebased);
p->stream << ')';
})
-.set_dispatch<SingletonNode>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<SingletonNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const SingletonNode*>(node.get());
p->stream << "singleton(";
p->Print(op->iter);
p->stream << ')';
})
-.set_dispatch<ScheduleNode>([](const ObjectRef& node, IRPrinter* p) {
+.set_dispatch<ScheduleNode>([](const ObjectRef& node, NodePrinter* p) {
auto* op = static_cast<const ScheduleNode*>(node.get());
p->stream << "schedule(" << op << ")";
});