-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Multiplication of tensors with rank > 2 #582
Comments
i'm interested in this as well |
i will be the first to submit a PR for GPT in Arraymancer, if all the pieces are available to build attention |
@lucidrains I actually requested this as I started writing a PR to add attention in arraymancer myself 😅, however I am a big fan of your work and it would be great if you have to possibility to add attention Regarding this issue, I might have time to implement it, however I have little knowledge about possible implementations |
Sorry, I was off for a couple months and didn't check my long list of Github notifications. batch matrix multiplication is something I've wanted to implement like 4 years ago. My main issue is that some libraries provide it:
but not OpenBLAS or
It's easy to add a naive version that for-loops over matrix multiplication, but because all the BLAS libraries use OpenMP and OpenMP doesn't support nesting properly, you can't utilize the new level of parallelism exposed at all. Which:
Which brings to engineering issues. For now Arraymancer doesn't use a custom threadpool because it's a very involved change and I need to port some LAPACK functions as well besides just matrix multiplication, things here: https://github.com/mratsim/Arraymancer/tree/master/src/arraymancer/linear_algebra/helpers
So batch matrix multiplication would be very welcome. But probably just start humble with a for loop over normal matrix multiplication. |
I apologize in advance if my question is too basic. Just out of curiosity, is there any workaround for this issue? Let say for example, if I want to do something like, L (double dot product) P = L_ijkl P_lk. Can I convert this operation to a loop over rank 2 matrices? |
The einsum operator should work, but it would be non-parallelized and slow. And otherwise you do it like im2col convolution Arraymancer/src/arraymancer/nn_primitives/fallback/conv.nim Lines 99 to 103 in 12610a3
|
Hello!
Currently, * operator only supports matrix-matrix and matrix-vector multiplication. Are there any plans to add support for batch matrix-matrix multiplication? It would be really useful for stuff like Attention which I am trying to implement
Thanks!
The text was updated successfully, but these errors were encountered: