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/11/17 23:27:38 UTC

[GitHub] [tvm] tkonolige opened a new pull request, #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   Add a handwritten matrix-vector multiplication implementation for dynamic cases on cpu. This avoids crashing when a dynamic shape is present.


-- 
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] tkonolige commented on pull request #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   @tvm-bot rerun


-- 
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 #13423: [TOPI] Add handwritten matvec for dynamic cases

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


##########
python/tvm/relay/op/strategy/x86.py:
##########
@@ -507,10 +507,26 @@ def matmul_strategy_cpu(attrs, inputs, out_type, target):
     return strategy
 
 
+def is_any(shape):
+    return any([isinstance(x, tir.Any) or isinstance(x, tir.SizeVar) for x in shape])
+
+
 @dense_strategy.register("cpu")
 def dense_strategy_cpu(attrs, inputs, out_type, target):
     """dense x86 strategy"""
+
     strategy = _op.OpStrategy()
+    # For dynamic shapes we use a hand written kernel. Right now it only
+    # supports matrix-vector multiplication.
+    if is_any(inputs[0].shape) or is_any(inputs[1].shape):

Review Comment:
   should we check the size of `inputs[0]` to make sure its a vector before dispatching?



##########
python/tvm/relay/op/strategy/x86.py:
##########
@@ -507,10 +507,26 @@ def matmul_strategy_cpu(attrs, inputs, out_type, target):
     return strategy
 
 
+def is_any(shape):

Review Comment:
   `is_dynamic` might be a more appropriate name for this function.



-- 
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] tkonolige commented on a diff in pull request #13423: [TOPI] Add handwritten matvec for dynamic cases

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


##########
python/tvm/relay/op/strategy/x86.py:
##########
@@ -507,10 +507,26 @@ def matmul_strategy_cpu(attrs, inputs, out_type, target):
     return strategy
 
 
+def is_any(shape):
+    return any([isinstance(x, tir.Any) or isinstance(x, tir.SizeVar) for x in shape])
+
+
 @dense_strategy.register("cpu")
 def dense_strategy_cpu(attrs, inputs, out_type, target):
     """dense x86 strategy"""
+
     strategy = _op.OpStrategy()
+    # For dynamic shapes we use a hand written kernel. Right now it only
+    # supports matrix-vector multiplication.
+    if is_any(inputs[0].shape) or is_any(inputs[1].shape):

Review Comment:
   Added a check in the implementation.



##########
python/tvm/relay/op/strategy/x86.py:
##########
@@ -507,10 +507,26 @@ def matmul_strategy_cpu(attrs, inputs, out_type, target):
     return strategy
 
 
+def is_any(shape):

Review Comment:
   renamed to `is_dynamic_shape`



-- 
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] michalpiszczek commented on pull request #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   @tvm-bot rerun


-- 
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 #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   <!---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.
   
   <!--bot-comment-ccs-start-->
    * No users to tag found in teams: `topi` <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <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] junrushao merged pull request #13423: [TOPI] Add handwritten matvec for dynamic cases

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


-- 
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] tkonolige commented on pull request #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   @jwfromm a change: the dynamic kernel usage is predicated on it being a matrix-vector multiply instead of asserting within the kernel. Apparently there are some other code paths that do dynamic matmul that I broke.


-- 
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 #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   Yeah that makes perfect sense to me, good change.


-- 
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 #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   <!---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.
   
   <!--bot-comment-ccs-start-->
    * No users to tag found in teams: `topi` <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <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] michalpiszczek commented on pull request #13423: [TOPI] Add handwritten matvec for dynamic cases

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

   @tvm-bot rerun


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