Skip to content

Commit

Permalink
add a performance warning about matmul
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Oct 1, 2024
1 parent 29b3d3b commit 1819443
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ All of these are converted into array commands like `reshape` and `permutedims`
and `eachslice`, plus a [broadcasting expression](https://julialang.org/blog/2017/01/moredots) if needed,
and `sum` / `sum!`, or `*` / `mul!`. This package just provides a convenient notation.

> [!WARNING]
> Writing `@reduce C[i,j] := sum(k) A[i,k] * B[k,j]` is terrible way to perform matrix multiplication.
> This creates a huge array `A .* reshape(B, 1, size(B)...)` before summing, which is much slower than the built-in `A * B`.
> [See below]([#Elsewhere](#elsewhere)) for other packages which aim to be good at such operations.
From version 0.4, it relies on [TransmuteDims.jl](https://github.com/mcabbott/TransmuteDims.jl)
to handle re-ordering of dimensions, and [LazyStack.jl](https://github.com/mcabbott/LazyStack.jl)
to handle slices. It should also now work with [OffsetArrays.jl](https://github.com/JuliaArrays/OffsetArrays.jl):
Expand Down

0 comments on commit 1819443

Please sign in to comment.