-
Notifications
You must be signed in to change notification settings - Fork 548
Allow af_matmul to use an existing af_array for output #2481
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
Conversation
Cool. Would that work also for batched matmul (per slice matmul) ? |
@WilliamTambellini I think that must be ensured, though I haven't added this specific test yet in the published commits. The goal is that all of the existing behavior of |
@WilliamTambellini This change is to the C-API, we will be adding a new void af::gemm(af::array& C, const array &lhs, const array &rhs,
const matProp optLhs = AF_MAT_NONE, const matProp optRhs = AF_MAT_NONE,
const float alpha = 1, const float beta = 1); C would be your pre-allocated output array. After each call to this new API, C will have |
ok tks @9prady9 B= 2 x 3 x 2 After looping over the slices with 1 gemm per slice on C shaped 3 x 3 (single slice) with beta = 1, C should be : |
092d971
to
7a7817f
Compare
17eaddc
to
b22f2b6
Compare
e749e26
to
f0ca36e
Compare
Why just matmul ? None of the other functions support using an existing af_array. |
Coming back to this after some time. Working on leaving the old behavior intact and separating the new behavior into new functions. |
0801a4c
to
9ff7862
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I understand why af_
calls are present in src/api/c/blas.cpp
- don't like it however though.
Why are tests commented out ? Do you have more changes coming in ?
@9prady9 Yes I have more coming in. Pushed some changes for now to see how they fare in different systems though. |
094fa1b
to
b26c8b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look great overall.
- I think sticking to C style arrays for alpha & beta is a good decision.
- I have some nit picky comments on variables names in our internal implementation, but we can address them in another PR.
* Make af_gemm accept preallocated arrays * Update the docs and add test for doc snippet
cc43610
to
da7e5b3
Compare
Similar to #2324, but for matmul. Still WIP as the OpenCL BLAS tests are failing. Made a PR for now so that my changes will be visible to you guys while I'm working on this.