JuliaLang / JuliaLang/LinearAlgebra.jl
Slow multiplication of reshaped matrices
- Dominant language
- Julia
- Stars
- 77
- Forks
- 65
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 10
Description
Compare:
```
v = randn(728, 600)
w = randn(70, 728)
@time w * v # 0.017802 seconds (2 allocations: 328.172 KiB)
```
with:
```
v_ = reshape(reshape(v', 600, 728)', 728, 600)
w_ = reshape(reshape(w', 728, 70)', 70, 728)
@time w_ * v_ 0.161401 seconds (5 allocations: 358.922 KiB)
```
The second one is 10x slower. Note that the underlying data in memory is exactly the same, and with the same layout.
Can the reshape / adjoint type signature be simplified here?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the two Julia benchmark snippets in the issue and confirm the reported multiplication slowdown. Then inspect the reshape/adjoint type-signature path implicated by the report; done means the reshaped matrices no longer show the roughly 10x slowdown while retaining the same underlying layout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100