You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "junrushao (via GitHub)" <gi...@apache.org> on 2023/06/27 05:29:14 UTC

[GitHub] [tvm] junrushao opened a new pull request, #15163: [TIR] Fix RenewDef for symbolic input shapes

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

   There are cases where the shapes of input buffers are symbolic, but the first symbol is a composite PrimExpr rather than a TIR Var, which the original implementation does not take this into account.
   
   Example:
   
   ```python
   @T.prim_func
   def main(a: T.handle, b: T.handle):
       m = T.int64()
       A = T.match_buffer(a, (m * 2,))  // `m` first appears as composite
       B = T.match_buffer(b, (m, 2))
   ```


-- 
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] junrushao commented on a diff in pull request #15163: [TIR] Fix RenewDef for symbolic input shapes

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15163:
URL: https://github.com/apache/tvm/pull/15163#discussion_r1243165989


##########
tests/python/unittest/test_tir_renew_defs.py:
##########
@@ -169,5 +170,21 @@ def symbolic_func(a: T.handle, b: T.handle, n: T.int32):
     tvm.ir.assert_structural_equal(f1, f2)
 
 
+def test_buffer_map():
+    @T.prim_func
+    def main(a: T.handle, b: T.handle):
+        m = T.int64()
+        A = T.match_buffer(a, (m * 2,))
+        B = T.match_buffer(b, (m, 2))
+        for i, j in T.grid(m, 2):
+            with T.block("B"):
+                vi, vj = T.axis.remap("SS", [i, j])
+                B[vi, vj] = A[vi * 2 + vj]
+
+    f1 = main
+    f2 = tvm.tir.stmt_functor.renew_defs(main)
+    tvm.ir.assert_structural_equal(f1, f2)

Review Comment:
   added



-- 
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] tvm-bot commented on pull request #15163: [TIR] Fix RenewDef for symbolic input shapes

Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #15163:
URL: https://github.com/apache/tvm/pull/15163#issuecomment-1608822044

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


-- 
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] tqchen merged pull request #15163: [TIR] Fix RenewDef for symbolic input shapes

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #15163:
URL: https://github.com/apache/tvm/pull/15163


-- 
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] junrushao commented on a diff in pull request #15163: [TIR] Fix RenewDef for symbolic input shapes

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao commented on code in PR #15163:
URL: https://github.com/apache/tvm/pull/15163#discussion_r1243164258


##########
tests/python/unittest/test_tir_renew_defs.py:
##########
@@ -169,5 +170,21 @@ def symbolic_func(a: T.handle, b: T.handle, n: T.int32):
     tvm.ir.assert_structural_equal(f1, f2)
 
 
+def test_buffer_map():
+    @T.prim_func
+    def main(a: T.handle, b: T.handle):
+        m = T.int64()
+        A = T.match_buffer(a, (m * 2,))
+        B = T.match_buffer(b, (m, 2))
+        for i, j in T.grid(m, 2):
+            with T.block("B"):
+                vi, vj = T.axis.remap("SS", [i, j])
+                B[vi, vj] = A[vi * 2 + vj]
+
+    f1 = main
+    f2 = tvm.tir.stmt_functor.renew_defs(main)
+    tvm.ir.assert_structural_equal(f1, f2)

Review Comment:
   sg



-- 
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] Hzfengsy commented on a diff in pull request #15163: [TIR] Fix RenewDef for symbolic input shapes

Posted by "Hzfengsy (via GitHub)" <gi...@apache.org>.
Hzfengsy commented on code in PR #15163:
URL: https://github.com/apache/tvm/pull/15163#discussion_r1243160477


##########
tests/python/unittest/test_tir_renew_defs.py:
##########
@@ -169,5 +170,21 @@ def symbolic_func(a: T.handle, b: T.handle, n: T.int32):
     tvm.ir.assert_structural_equal(f1, f2)
 
 
+def test_buffer_map():
+    @T.prim_func
+    def main(a: T.handle, b: T.handle):
+        m = T.int64()
+        A = T.match_buffer(a, (m * 2,))
+        B = T.match_buffer(b, (m, 2))
+        for i, j in T.grid(m, 2):
+            with T.block("B"):
+                vi, vj = T.axis.remap("SS", [i, j])
+                B[vi, vj] = A[vi * 2 + vj]
+
+    f1 = main
+    f2 = tvm.tir.stmt_functor.renew_defs(main)
+    tvm.ir.assert_structural_equal(f1, f2)

Review Comment:
   Please check the `m` in `f1` and `f2` are not the same object



-- 
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