You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/09/06 19:24:50 UTC

[GitHub] [tvm] vinx13 opened a new pull request, #12717: [TIR, Schedule] Generate consumer-in-bound predicate after reverse_compute_inline

vinx13 opened a new pull request, #12717:
URL: https://github.com/apache/tvm/pull/12717

   When the producer region is larger than the consumer region, `reverse_compute_inline` should generate predicates to prevent out-of-bound access to the consumer region.
   
   cc @spectrometerHBH @Hzfengsy 


-- 
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-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] jwfromm commented on a diff in pull request #12717: [TIR, Schedule] Check consumer in-bound and covered in reverse_compute_inline

Posted by GitBox <gi...@apache.org>.
jwfromm commented on code in PR #12717:
URL: https://github.com/apache/tvm/pull/12717#discussion_r966383754


##########
tests/python/unittest/test_tir_schedule_compute_inline.py:
##########
@@ -822,5 +848,15 @@ def test_compute_inline_opaque_access_with_tvm_access_ptr(use_block_name):
     )
 
 
+def test_reverse_compute_inline_overcomputed_producer(use_block_name):
+    """Test reverse compute inline overcomputed producer"""
+    sch = tir.Schedule(elementwise_overcomputed_producer, debug_mask="all")
+    compute = "C" if use_block_name else sch.get_block("C")
+    sch.reverse_compute_inline(compute)
+    tvm.ir.assert_structural_equal(
+        elementwise_overcomputed_producer_reverse_inlined, sch.mod["main"]
+    )
+

Review Comment:
   Should we also add a test for the opposite case where a consumer has a larger domain than the producer?



-- 
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-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] jwfromm commented on a diff in pull request #12717: [TIR, Schedule] Check consumer in-bound and covered in reverse_compute_inline

Posted by GitBox <gi...@apache.org>.
jwfromm commented on code in PR #12717:
URL: https://github.com/apache/tvm/pull/12717#discussion_r966384283


##########
src/tir/schedule/primitive/compute_inline.cc:
##########
@@ -571,6 +596,34 @@ class ReverseComputeInliner : public BaseInliner {
   using BaseInliner::VisitExpr_;
   using BaseInliner::VisitStmt_;
 
+  /*! \brief Generate the predicate after inlining based on the consumer predicate */
+  PrimExpr BuildInlinedConsumerPredicate(const BlockRealizeNode* producer_block_realize) {
+    // Bind the producer block iter domains for simplification
+    Map<Var, PrimExpr> subst_map;
+    for (int i = 0, n = producer_block_realize->iter_values.size(); i < n; ++i) {
+      const IterVar& iter = producer_block_realize->block->iter_vars[i];
+      analyzer.Bind(iter->var, Range::FromMinExtent(iter->dom->min, iter->dom->extent));
+      subst_map.Set(iter->var, producer_block_realize->iter_values[i]);
+    }
+    // Substitute the consumer block iters with the corresponding iters in the producer blocks
+    PrimExpr predicate = Substituter(this)(consumer_predicate_);
+    // Simplify the predicate using the producer block iter domains
+    predicate = analyzer.Simplify(predicate);

Review Comment:
   Just for my understanding, how does this bit work? I'm having a hard time seeing how the domain of consumer_predicate is compared to the producer domain through this substitution.



-- 
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-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] jwfromm commented on pull request #12717: [TIR, Schedule] Check consumer in-bound and covered in reverse_compute_inline

Posted by GitBox <gi...@apache.org>.
jwfromm commented on PR #12717:
URL: https://github.com/apache/tvm/pull/12717#issuecomment-1241409641

   Thank you @vinx13, this now merged!


-- 
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-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] jwfromm merged pull request #12717: [TIR, Schedule] Check consumer in-bound and covered in reverse_compute_inline

Posted by GitBox <gi...@apache.org>.
jwfromm merged PR #12717:
URL: https://github.com/apache/tvm/pull/12717


-- 
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-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org