-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Multiplying Adjoint
with Symmetric
uses slow generic matmul
#850
Comments
Since |
Not, sure, a bit surprising, but also nice with some more performance. I'm primarily worried about avoiding generic matmul, though. Here is another example with common types where generic matmul strikes again. julia> n = 500; A = randn(n,n); B = rand(Bool, n, n); @btime $A*$B;
301.147 ms (8 allocations: 1.91 MiB) |
Some eltype mismatches are copied to avoid this, e.g. there's a method julia> A = rand(Float32,100,100); B = rand(100,100);
julia> @btime $A * $B; # special method which copies
36.000 μs (4 allocations: 156.41 KiB)
julia> @btime Float64.($A) * $B; # copy by hand, same speed & same alloc.
34.875 μs (4 allocations: 156.41 KiB)
julia> A = rand(Bool,100,100); B = rand(100,100);
julia> @btime $A * $B; # generic matmul
490.875 μs (8 allocations: 78.53 KiB)
julia> @btime Float64.($A) * $B;
38.500 μs (4 allocations: 156.41 KiB) |
Multiplying an
Adjoint
with aSymmetric
matrix falls back to a very slow generic matmul.Converting
A'
toMatrix
makes it a lot fasterThe break-even poirnt for when converting
A'
toMatrix
is faster isn = 5
.This seems a bit slow? Should this be fixed in
Base
or should one convert toMatrix
explicitly?Perhaps fallback conversion to
Matrix
should be used more widely wheneltype(A) <: BlasFloat
?The text was updated successfully, but these errors were encountered: