Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support vector inputs in MatMul operator #418

Merged
merged 1 commit into from
Nov 29, 2024
Merged

Support vector inputs in MatMul operator #418

merged 1 commit into from
Nov 29, 2024

Conversation

robertknight
Copy link
Owner

@robertknight robertknight commented Nov 29, 2024

The ONNX spec states that the MatMul operator is a "Matrix product that behaves like numpy.matmul". TIL that numpy.matmul supports vector inputs:

If the first argument is 1-D, it is promoted to a matrix by prepending a 1
to its dimensions. After matrix multiplication the prepended 1 is removed.
If the second argument is 1-D, it is promoted to a matrix by appending a 1
to its dimensions. After matrix multiplication the appended 1 is removed.

Implement this behavior in RTen.

The ONNX spec states that the MatMul operator is a "Matrix product that behaves
like numpy.matmul". `numpy.matmul` supports vector inputs:

> If the first argument is 1-D, it is promoted to a matrix by prepending a 1
> to its dimensions. After matrix multiplication the prepended 1 is removed.
> If the second argument is 1-D, it is promoted to a matrix by appending a 1
> to its dimensions. After matrix multiplication the appended 1 is removed.

Implement this behavior in RTen.
@robertknight robertknight merged commit 2bfd667 into main Nov 29, 2024
2 checks passed
@robertknight robertknight deleted the matmul-vec branch November 29, 2024 21:05
@robertknight
Copy link
Owner Author

A corresponding change will also be needed for MatMulInteger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant