mbrookhart commented on a change in pull request #6681:
URL: https://github.com/apache/incubator-tvm/pull/6681#discussion_r505024398
##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -532,10 +534,18 @@ def flatten_to_3d(x, x_shape):
b = _op.transpose(b, [0, 2, 1])
# Perform a batch matmul.
output = _op.nn.batch_matmul(a, b)
+ # Determine the output batch dimension.
+ if a_rank >= b_rank:
+ out_batch = _op.strided_slice(a_shape, [0],
[infer_shape(a_shape)[0] - 2])
+ else:
+ out_batch = _op.strided_slice(b_shape, [0],
[infer_shape(b_shape)[0] - 2])
Review comment:
I think the only place this might fail is if the input shapes are both
3D, but the a shape starts with a 1, i.e a.shape = (1, 6, 6) and b.shape = (3,
6, 6) and the output shape actually needs to be (3, 6, 6).
I'm not sure how to handle that case correctly, though.
----------------------------------------------------------------
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:
[email protected]