MasterJH5574 commented on a change in pull request #8467:
URL: https://github.com/apache/tvm/pull/8467#discussion_r670052969
##########
File path: src/tir/schedule/analysis.h
##########
@@ -142,6 +142,12 @@ Array<StmtSRef> GetLoops(const StmtSRef& block_sref);
* \return A list of leaf blocks
*/
Array<StmtSRef> GetChildBlocks(const ScheduleState& self, const StmtSRef&
parent_sref);
+/*!
+ * \brief Get the direct child Schedulable Stmt (Block and For)
+ * \param stmt the parent stmt.
+ * \return the list of child stmts
Review comment:
```suggestion
* \param stmt The parent stmt.
* \return The list of children stmts
```
##########
File path: src/tir/schedule/analysis/analysis.cc
##########
@@ -298,5 +298,35 @@ Array<StmtSRef> GetChildBlocks(const ScheduleState& self,
const StmtSRef& parent
throw;
}
+Array<Stmt> GetChildren(const Stmt& stmt) {
+ /*! \note Nested SeqStmt is not allowed in schedule. */
+ Stmt body;
+ if (const auto* block = stmt.as<BlockNode>()) {
+ body = block->body;
+ } else if (const auto* loop = stmt.as<ForNode>()) {
+ body = loop->body;
+ } else {
+ LOG(FATAL) << "The Stmt can only be a Block or a For";
+ }
+ if (const auto* seq = body.as<SeqStmtNode>()) {
+ Array<Stmt> ret;
+ for (const Stmt& child : seq->seq) {
+ ICHECK(!child->IsInstance<SeqStmtNode>()) << "Nested SeqStmt is not
allowed in schedule.";
+ if (child->IsInstance<BlockRealizeNode>()) {
+ ret.push_back(child.as<BlockRealizeNode>()->block);
Review comment:
This suggestion works also for the code on line 323-324.
##########
File path: include/tvm/tir/schedule/schedule.h
##########
@@ -196,6 +208,25 @@ class ScheduleNode : public runtime::Object {
*/
virtual Array<LoopRV> GetLoops(const BlockRV& block_rv) = 0;
/******** Schedule: loops manipulation ********/
+ /*!
+ * \brief Fuse consecutive loops into one. It requires:
+ * 1) The loops can't have annotations or thread bindings.
+ * 2) The (i+1)-th loop must be the only child of the i-th loop.
+ * 3) All loops must start with 0.
+ * \param loop_rvs The loops to be fused
+ * \return The fused loop
+ */
+ virtual LoopRV Fuse(const Array<LoopRV>& loop_rvs) = 0;
+ /*!
+ * \brief Split a specified loop into two or more with the specific
factor.It requires:
+ * 1) The loop can't have annotation or thread binding.
+ * 2) The loop must start with 0.
+ * \param loop_rv The loop to be split
+ * \param factors The tiling factors, and at most one of which is -1, which
means that
+ * factor is inferred.
+ * \return The loops after splitting
Review comment:
It also differs from the document in primitive.h.
##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -881,7 +883,7 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const
FloorModNode* op) {
TVM_TRY_REWRITE_IF(floormod(x + y * c1, c2), floormod(x, c2),
c2.Eval()->value > 0 && c1.Eval()->value %
c2.Eval()->value == 0);
-
+ TVM_TRY_REWRITE_IF(floormod(x * c1, x * c2), x * floormod(c1, c2),
c2.Eval()->value != 0);
Review comment:
Perhaps we don't need to remove the blank line above.
--
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]