Skip to content

Slow multiplication of reshaped matrices #899

@cossio

Description

@cossio

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions