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 2021/02/22 13:47:42 UTC

[GitHub] [tvm] leeexyz opened a new pull request #7497: [Tensorize] Support conds depend on outer loop vars inside tensorize scope

leeexyz opened a new pull request #7497:
URL: https://github.com/apache/tvm/pull/7497


   Hi Community, 
   
   I just try to let Tensorize supports conds inside its scope. See the [issue](https://discuss.tvm.apache.org/t/tensorize-support-conditions-inside-tensorize-scope/9148) background.
   
   @tqchen @merrymercy Can you please help to review? Thanks a lot!


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

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



[GitHub] [tvm] comaniac commented on a change in pull request #7497: [Tensorize] Support conds depend on outer loop vars inside tensorize scope

Posted by GitBox <gi...@apache.org>.
comaniac commented on a change in pull request #7497:
URL: https://github.com/apache/tvm/pull/7497#discussion_r585804702



##########
File path: tests/python/unittest/test_te_schedule_tensorize.py
##########
@@ -18,14 +18,22 @@
 from tvm import te
 
 
-def intrin_vadd(n):
+def intrin_vadd(xo, m, n):
     x = te.placeholder((n,), name="vx")
     y = te.placeholder((n,), name="vy")
-    z = te.compute(x.shape, lambda i: x[i] + y[i], name="z")
+    if m % n == 0:
+        body = lambda i: x[i] + y[i]
+    else:
+        body = lambda i: tvm.tir.Select(
+            xo * n + i < m, x[i] + y[i], tvm.tir.const(0, dtype=x.dtype)
+        )
+    z = te.compute(x.shape, body, name="z")
 
     def intrin_func(ins, outs):
         xx, yy = ins
         zz = outs[0]
+        # special handle needed to tackle tail loop part when m % n != 0
+        # here is tvm.min(n, m - xo * n)

Review comment:
       Is that possible to also improve `vadd` in this PR so that you can reuse the `check` function for both test cases?




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

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



[GitHub] [tvm] leeexyz commented on a change in pull request #7497: [Tensorize] Support conds depend on outer loop vars inside tensorize scope

Posted by GitBox <gi...@apache.org>.
leeexyz commented on a change in pull request #7497:
URL: https://github.com/apache/tvm/pull/7497#discussion_r586427561



##########
File path: tests/python/unittest/test_te_schedule_tensorize.py
##########
@@ -18,14 +18,22 @@
 from tvm import te
 
 
-def intrin_vadd(n):
+def intrin_vadd(xo, m, n):
     x = te.placeholder((n,), name="vx")
     y = te.placeholder((n,), name="vy")
-    z = te.compute(x.shape, lambda i: x[i] + y[i], name="z")
+    if m % n == 0:
+        body = lambda i: x[i] + y[i]
+    else:
+        body = lambda i: tvm.tir.Select(
+            xo * n + i < m, x[i] + y[i], tvm.tir.const(0, dtype=x.dtype)
+        )
+    z = te.compute(x.shape, body, name="z")
 
     def intrin_func(ins, outs):
         xx, yy = ins
         zz = outs[0]
+        # special handle needed to tackle tail loop part when m % n != 0
+        # here is tvm.min(n, m - xo * n)

Review comment:
       > Is that possible to also improve `vadd` in this PR so that you can reuse the `check` function for both test cases?
   
   Thanks for your advice. I tried, but Tensorize is a little strictly for the pattern. I cannot use the same compute in intrin_vadd for both cases. And for the two check functions, they check the different results.




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

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



[GitHub] [tvm] tqchen commented on pull request #7497: [Tensorize] Support conds depend on outer loop vars inside tensorize scope

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #7497:
URL: https://github.com/apache/tvm/pull/7497#issuecomment-786238424


   cc @comaniac @merrymercy 


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

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



[GitHub] [tvm] comaniac commented on pull request #7497: [Tensorize] Support conds depend on outer loop vars inside tensorize scope

Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #7497:
URL: https://github.com/apache/tvm/pull/7497#issuecomment-789911148


   Thanks @leeexyz 


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

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



[GitHub] [tvm] comaniac merged pull request #7497: [Tensorize] Support conds depend on outer loop vars inside tensorize scope

Posted by GitBox <gi...@apache.org>.
comaniac merged pull request #7497:
URL: https://github.com/apache/tvm/pull/7497


   


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

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