From 18194436426506813195ff8c5ba3798fd7f2a700 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Mon, 30 Sep 2024 20:44:39 -0400 Subject: [PATCH] add a performance warning about matmul --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5193506..707eb14 100644 --- a/README.md +++ b/README.md @@ -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):