junrushao commented on code in PR #13962:
URL: https://github.com/apache/tvm/pull/13962#discussion_r1103750608
##########
src/script/printer/ir/ir.cc:
##########
@@ -26,21 +26,31 @@ namespace printer {
TVM_REGISTER_NODE_TYPE(IRFrameNode);
+std::pair<int, std::string> SortKey(const std::pair<GlobalVar, BaseFunc>& obj)
{
+ String name = obj.first->name_hint;
+ // "PrimFunc" -> "relax.expr.ExternFunc" -> "relax.expr.Function"
+ int priority = 0;
+ if (name == "main") {
+ priority = 1000;
+ } else if (obj.second->GetTypeKey() == "tir.PrimFunc") {
+ priority = 1;
+ } else if (obj.second->GetTypeKey() == "relax.expr.ExternFunc") {
+ priority = 2;
+ } else if (obj.second->GetTypeKey() == "relax.expr.Function") {
+ priority = 3;
+ } else {
+ LOG(FATAL) << "TypeError: TVMScript cannot print functions of type: " <<
obj.second->GetTypeKey();
+ }
+ return {priority, name};
+}
+
TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable)
.set_dispatch<IRModule>("", [](IRModule mod, ObjectPath p, IRDocsifier d)
-> Doc {
std::vector<std::pair<GlobalVar, BaseFunc>>
functions{mod->functions.begin(),
mod->functions.end()};
// print "main" first
std::sort(functions.begin(), functions.end(), [](const auto& lhs, const
auto& rhs) {
- String lhs_name = lhs.first->name_hint;
- String rhs_name = rhs.first->name_hint;
- if (lhs_name == "main") {
Review Comment:
Thanks! Updated accordingly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]