shingjan commented on a change in pull request #9306:
URL: https://github.com/apache/tvm/pull/9306#discussion_r731486289
##########
File path: src/tir/schedule/error.cc
##########
@@ -24,29 +24,41 @@ namespace tir {
String ScheduleError::RenderReport(const String& primitive) const {
IRModule mod = this->mod();
std::ostringstream os;
- os << "ScheduleError: An error occurred in the schedule primitive '" <<
primitive
- << "'.\n\nThe IR is:\n"
- << AsTVMScript(mod);
+
+ // get locations of interest
Array<ObjectRef> locs = LocationsOfInterest();
+ std::unordered_set<ObjectRef, ObjectPtrHash, ObjectPtrEqual> loc_set;
int n_locs = locs.size();
std::vector<String> roi_names;
roi_names.reserve(n_locs);
+ std::string msg = DetailRenderTemplate();
if (n_locs > 0) {
- os << "Regions of interest:\n";
- for (const ObjectRef& obj : locs) {
- String name = obj->GetTypeKey() + '#' + std::to_string(roi_names.size());
- os << name << "\n" << obj;
+ for (int i = 0; i < n_locs; ++i) {
+ std::string name = locs[i]->GetTypeKey() + '#' +
std::to_string(roi_names.size());
+ std::string src = "{" + std::to_string(i) + "}";
+ for (size_t pos; (pos = msg.find(src)) != std::string::npos;) {
+ msg.replace(pos, src.length(), name);
+ }
roi_names.emplace_back(std::move(name));
- }
- os << "\n";
- }
- std::string msg = DetailRenderTemplate();
- for (int i = 0; i < n_locs; ++i) {
- std::string src = "{" + std::to_string(i) + "}";
- for (size_t pos; (pos = msg.find(src)) != std::string::npos;) {
- msg.replace(pos, src.length(), roi_names[i]);
+ loc_set.emplace(locs[i]);
}
}
+ msg = "Error message: " + std::move(msg);
+
+ // print IR module
+ runtime::TypedPackedFunc<std::string(Stmt)> annotate =
+ runtime::TypedPackedFunc<std::string(Stmt)>(
+ [&loc_set, &msg](const Stmt& expr) -> std::string {
+ auto search = loc_set.find(Downcast<ObjectRef>(expr));
+ if (search == loc_set.end()) return "";
+ return msg;
Review comment:
turned out `Array<ObjectRef>` isn't really used. I have it removed and
keep the `std::unordered_map` here only.
--
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]