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 for 3d MatMul #44

Merged
merged 2 commits into from
Apr 2, 2024
Merged

support for 3d MatMul #44

merged 2 commits into from
Apr 2, 2024

Conversation

AUTOMATIC1111
Copy link
Contributor

This makes it possible to use MatMul nodes with 3d tensors; currently the program only supports 2d.

3d MatMul is needed for Attention layers. Some implementations use einsum, some 3d matmul, but neither are supported at the moment.

I tested the added code on the model I'm working on, and it works well, faster than pytorch on a single CPU thread. I didn't do any other tests.

@kraiskil
Copy link
Owner

kraiskil commented Apr 1, 2024

Thanks for your patch. Looks good at a glance, I'll have a closer look soonest. (mostly on what 3d matmul even means. Last I checked, matrix multiplication was defined only for 2d. But times change :) )

I tried enabling the ONNX test for matmul3d. Seems to pass now. Matmul4d (whatever that is) does not.

Also, your contribution is significant enough to be copyrightable - if you want, please add yourself to the list (file LICENSE.txt.

@AUTOMATIC1111
Copy link
Contributor Author

All right. Thanks. 3d MatMul means you just have many matrices and you independently multiply them between each other like you normally do with 2d MatMul. Same with 4d, I'm sure.

@kraiskil kraiskil merged commit 316b67b into kraiskil:master Apr 2, 2024
@kraiskil
Copy link
Owner

kraiskil commented Apr 2, 2024

Thanks :)

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.

2 participants