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/01/12 10:56:27 UTC

[GitHub] [tvm] willzhang4a58 opened a new pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

willzhang4a58 opened a new pull request #9911:
URL: https://github.com/apache/tvm/pull/9911


   Thanks for contributing to TVM!   Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   


-- 
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] willzhang4a58 commented on pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

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


   Fix BUG and add test case for batch_matmul [A, B, M, N] * [1, B, N, K] 
   
   cc @Huyuwei @jwfromm @kazum @mbrookhart @siju-samuel 


-- 
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] AndrewZhaoLuo commented on a change in pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

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



##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -268,6 +256,40 @@ def flatten_to_nd(x, x_shape, nd=3):
                 ],
                 0,
             )
+
+        b_type = infer_type(inputs[1])
+        # Convert to dense if the second matrix is 2d and non-dynamic
+        if b_rank == 2 and not _ty.is_dynamic(b_type.checked_type):
+            a = flatten_to_nd(inputs[0], a_shape, 2)
+            b = _op.transpose(inputs[1])
+            output = _op.nn.dense(a, b, out_dtype=out_dtype)
+        else:
+            # broadcast a and b
+            a_broadcasted_shape = _op.concatenate(
+                [
+                    out_batch,
+                    _op.strided_slice(
+                        a_shape, [infer_shape(a_shape)[0] - 2], [infer_shape(a_shape)[0]]

Review comment:
       nit: use `a_rank` instead of `infer_shape(a_shape)[0]`




-- 
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] AndrewZhaoLuo merged pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

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


   


-- 
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] AndrewZhaoLuo commented on pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

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


   Will take a look later today


-- 
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] willzhang4a58 commented on pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

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


   hi @AndrewZhaoLuo , I have fixed the comment.


-- 
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] AndrewZhaoLuo commented on a change in pull request #9911: [Fix] relay onnx frontend bug when [A, B, M, N] * [1, B, N, K]

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



##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -268,6 +256,40 @@ def flatten_to_nd(x, x_shape, nd=3):
                 ],
                 0,
             )
+
+        b_type = infer_type(inputs[1])
+        # Convert to dense if the second matrix is 2d and non-dynamic
+        if b_rank == 2 and not _ty.is_dynamic(b_type.checked_type):
+            a = flatten_to_nd(inputs[0], a_shape, 2)
+            b = _op.transpose(inputs[1])
+            output = _op.nn.dense(a, b, out_dtype=out_dtype)
+        else:
+            # broadcast a and b
+            a_broadcasted_shape = _op.concatenate(
+                [
+                    out_batch,
+                    _op.strided_slice(
+                        a_shape, [infer_shape(a_shape)[0] - 2], [infer_shape(a_shape)[0]]
+                    ),
+                ],
+                0,
+            )
+            b_broadcasted_shape = _op.concatenate(
+                [
+                    out_batch,
+                    _op.strided_slice(
+                        b_shape, [infer_shape(b_shape)[0] - 2], [infer_shape(b_shape)[0]]

Review comment:
       same here, use b_rank




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