junrushao1994 commented on a change in pull request #8767: URL: https://github.com/apache/tvm/pull/8767#discussion_r693412063
########## File path: src/tir/schedule/primitive/loop_transformation.cc ########## @@ -385,6 +511,113 @@ StmtSRef Fuse(ScheduleState self, const Array<StmtSRef>& loop_srefs) { return self->stmt2ref.at(new_stmt.get()); } +void Reorder(ScheduleState self, const Array<StmtSRef>& ordered_loop_srefs) { + std::unordered_set<const StmtSRefNode*> loop_srefs; + loop_srefs.reserve(ordered_loop_srefs.size()); + if (ordered_loop_srefs.empty() || ordered_loop_srefs.size() == 1) { + return; + } + // Step 1. check uniqueness + for (const StmtSRef& loop_sref : ordered_loop_srefs) { + const ForNode* loop = TVM_SREF_TO_FOR(loop, loop_sref); + // uniqueness check + auto inserted = loop_srefs.insert(loop_sref.get()); + if (!inserted.second) { + throw LoopMultiAppearanceError(self->mod, GetRef<For>(loop)); + } + } + // Step 2. gather loops to be reordered Review comment: Chatted with Hongyi again and we improved the algorithm again :-) -- 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: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org