pydata / sparse

Sparse multi-dimensional arrays for the PyData ecosystem
https://sparse.pydata.org
BSD 3-Clause "New" or "Revised" License
581 stars 123 forks source link

Add `SpMV` example #677

Closed mtsokol closed 2 months ago

mtsokol commented 2 months ago

Hi @willow-ahrens @hameerabbasi,

This is the third one (and last) PR with an example: SpMV. Here it looks that Finch is x50 times slower than Numba/Scipy.

Here's a debug mode plan:

```julia Executing: :(function var"##compute#289"(prgm) begin V = ((((((((((((((((((((((((((((prgm.children[1]).children[2]).children[1]).children[1]).children[2]).children[1]).children[2]).children[1]).children[1]).children[1]).children[1]).children[2]).children[3]).children[1]).children[1]).children[1]).children[2]).children[1]).children[2]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[2]).tns.val::Tensor{DenseLevel{Int64, SparseListLevel{Int64, PlusOneVector{Int32}, PlusOneVector{Int32}, ElementLevel{0.0, Float64, Int64, PyArray{Float64, 1, true, true, Float64}}}}} V_2 = ((((((((((((((((((((((((((((((prgm.children[1]).children[2]).children[1]).children[1]).children[2]).children[1]).children[2]).children[1]).children[1]).children[1]).children[1]).children[2]).children[3]).children[1]).children[1]).children[1]).children[2]).children[1]).children[3]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[2]).tns.val::Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, PyArray{Float64, 1, true, true, Float64}}}}} V_3 = ((((((((((((((prgm.children[1]).children[2]).children[1]).children[1]).children[2]).children[1]).children[3]).children[1]).children[1]).children[1]).children[1]).children[1]).children[1]).children[2]).tns.val::Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, PyArray{Float64, 1, true, true, Float64}}}}} A0 = V::Tensor{DenseLevel{Int64, SparseListLevel{Int64, PlusOneVector{Int32}, PlusOneVector{Int32}, ElementLevel{0.0, Float64, Int64, PyArray{Float64, 1, true, true, Float64}}}}} A2 = V_2::Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, PyArray{Float64, 1, true, true, Float64}}}}} A5 = Tensor(Dense(SparseDict(Element{0.0, Float64}()), 1))::Tensor{DenseLevel{Int64, SparseLevel{Int64, Finch.DictTable{Int64, Int64, Vector{Int64}, Vector{Int64}, Vector{Int64}, Dict{Tuple{Int64, Int64}, Int64}}, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}} @finch mode = :fast begin A5 .= 0.0 for i31 = _ for i30 = 1:1 for i29 = _ A5[i29, i30] << + >>= (*)(A0[i29, i31], A2[1, i31]) end end end return A5 end A7 = V_3::Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, PyArray{Float64, 1, true, true, Float64}}}}} A10 = Tensor(Dense(Dense(Element{0.0, Float64}()), 1))::Tensor{DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}} @finch mode = :fast begin A10 .= 0.0 for i43 = _ for i44 = _ A10[i44, i43] << Finch.FinchNotation.InitWriter{0.0}() >>= (+)(A5[i44, i43], A7[1, i44]) end end return A10 end return (A10,) end end) ```
github-actions[bot] commented 2 months ago

Test Results

5 923 tests  ±0   5 890 :white_check_mark: +2   9m 13s :stopwatch: -17s     1 suites ±0      33 :zzz:  - 2      1 files   ±0       0 :x: ±0 

Results for commit 26118f77. ± Comparison against base commit eb787373.

This pull request skips 2 and un-skips 4 tests. ``` sparse.numba_backend.tests.test_compressed ‑ test_reductions_float16[f4-1-sum-kwargs0] sparse.numba_backend.tests.test_coo ‑ test_reductions_float16[i4-None-sum-kwargs0] ``` ``` sparse.numba_backend.tests.test_compressed ‑ test_reductions_float16[i4-None-sum-kwargs0] sparse.numba_backend.tests.test_compressed ‑ test_reductions_float16[i8-None-sum-kwargs0] sparse.numba_backend.tests.test_coo ‑ test_reductions_float16[f8-1-sum-kwargs0] sparse.numba_backend.tests.test_coo ‑ test_reductions_float16[i8-None-sum-kwargs0] ```

:recycle: This comment has been updated with latest results.

mtsokol commented 2 months ago

Done!