Octavian.jl
Octavian.jl copied to clipboard
Feature request: `Octavian.batched_mul` and `Octavian.batched_mul!`
NNlib.jl has the following nice functions:
| Function | Description |
|---|---|
batched_mul(A, B) -> C |
Batched matrix multiplication. Result has C[:,:,k] == A[:,:,k] * B[:,:,k] for all k. If size(B,3) == 1 then instead C[:,:,k] == A[:,:,k] * B[:,:,1], and similarly for A. |
batched_mul!(C, A, B) -> C and batched_mul!(C, A, B, α=1, β=0) |
In-place batched matrix multiplication, equivalent to mul!(C[:,:,k], A[:,:,k], B[:,:,k], α, β) for all k. If size(B,3) == 1 then every batch uses B[:,:,1] instead. |
Of course, under the hood, all of these functions call LinearAlgebra.mul!. It would be nice if Octavian could have its own batched_mul and batched_mul! that calls our own pure Julia matmul routines.
Octavian.batched_mul and Octavian.batched_mul! would be public functions, i.e. we would document them and put them in the manual. But we probably won't export them, just so we don't clash with NNlib.
It's worth exploring if some sort of repacking could improve performance, in particular for large batches of small matrices.