Re:Julia Summer of Einsum
by under-Peter on Wednesday June 05, 2019 @03:57PM
(#20108489)
Heya,
for standard arrays that are small, the einsum-macro from Einsum.jl can be faster than BLAS. Einsum.jl translates the code simply into three loops and if cache-access patterns (presumably what most of BLAS optimisation is concerned with) isn't an issue, the for-loops are very fast.
A quick check shows that for a simple matrix multiplication, Einsum is faster for 5x5 matrices but slower for 10x10. (This is ignoring the compilation-time that calling a julia function for the first time incurs)
Re:Julia Summer of Einsum
by eigenspace on Wednesday June 05, 2019 @03:14PM
(#20108089)
Depends on the implementation of `@einsum`. If the macro is implemented well, that’ll actually just lower to a matrix multiplication call and you’ll have zero runtime overhead.
Otherwise, you might end up lowering to a naïve for loop which would be significantly slower. TensorCast.jl and TensorOperations.jl know how to make matrix multiplication calls but currently Einsum isn't that smart.
Macros are just syntax transformations.
Would
@einsum c[i,j] = a[i,k] * b[k,j]
be slower than direct matrix multiplication?