willow-ahrens / Finch.jl

Sparse tensors in Julia and more! Datastructure-driven array programing language.
http://willowahrens.io/Finch.jl/
MIT License
157 stars 15 forks source link

[Lazy API] Error in elementwise ops for tensors with 1-size dimensions #487

Closed mtsokol closed 4 months ago

mtsokol commented 5 months ago

Hi @willow-ahrens,

While working on SpMv benchmark in sparse I found a bug in lazy API:

using Finch

a = fsprand(100, 1, 0.8)
b = fsprand(100, 1, 0.8)

permutedims(broadcast(.+, permutedims(a, (2, 1)), permutedims(b, (2, 1))), (2, 1))  # passes

a_l = lazy(a)
b_l = lazy(b)

plan = permutedims(broadcast(.+, permutedims(a_l, (2, 1)), permutedims(b_l, (2, 1))), (2, 1))
compute(plan)  # fails
ERROR: MethodError: no method matching swizzle(::Tensor{DenseLevel{Int64, SparseLevel{Int64, Finch.DictTable{…}, ElementLevel{…}}}}, ::Nothing, ::Int64)

But for the second dimension >1 it passes.

willow-ahrens commented 4 months ago

Fixed in https://github.com/willow-ahrens/Finch.jl/pull/501