Skip to content

Commit

Permalink
Merge pull request #562 from willow-ahrens/wma/heuristic
Browse files Browse the repository at this point in the history
add heuristic loop order
  • Loading branch information
mtsokol authored May 21, 2024
2 parents 8c107d1 + 601c727 commit c6b94f5
Show file tree
Hide file tree
Showing 93 changed files with 2,185 additions and 2,961 deletions.
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Willow Ahrens"]
name = "Finch"
uuid = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce"
version = "0.6.28"
version = "0.6.29"

[compat]
AbstractTrees = "0.3.4, 0.4"
Expand Down Expand Up @@ -47,7 +47,6 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
NPZ = "15e1cf62-19b3-5cfa-8e77-841668bca605"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -57,7 +56,7 @@ TensorMarket = "8b7d4fe7-0b45-4d0d-9dd8-5cc9b23b4b77"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "ArgParse", "LinearAlgebra", "Random", "SparseArrays", "Graphs", "SimpleWeightedGraphs", "HDF5", "NPZ", "Pkg", "TensorMarket", "Documenter", "Literate"]
test = ["Test", "ArgParse", "LinearAlgebra", "Random", "SparseArrays", "Graphs", "SimpleWeightedGraphs", "HDF5", "NPZ", "Pkg", "TensorMarket", "Documenter"]

[weakdeps]
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Expand Down
1 change: 0 additions & 1 deletion benchmark/runbenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__
using Pkg
Pkg.activate(@__DIR__)
Pkg.develop(PackageSpec(path = joinpath(@__DIR__, "..")))
Pkg.resolve()
Pkg.instantiate()
end

Expand Down
1 change: 0 additions & 1 deletion benchmark/runjudge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ if abspath(PROGRAM_FILE) == @__FILE__
using Pkg
Pkg.activate(@__DIR__)
Pkg.develop(PackageSpec(path = joinpath(@__DIR__, "..")))
Pkg.resolve()
Pkg.instantiate()
end

Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CIndices = "5a98b6c4-18fa-405d-92b3-8277d93fed36"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Finch = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
MatrixDepot = "b51810bb-c9f3-55da-ae3c-350fc1fbce05"
RewriteTools = "5969e224-3634-4c61-9f66-721b69e98b8a"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand Down
4 changes: 0 additions & 4 deletions docs/fix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ if abspath(PROGRAM_FILE) == @__FILE__
using Pkg
Pkg.activate(@__DIR__)
Pkg.develop(PackageSpec(path = joinpath(@__DIR__, "..")))
Pkg.resolve()
Pkg.instantiate()
end

using Test
using Documenter
using Literate
using Finch

root = joinpath(@__DIR__, "..")

DocMeta.setdocmeta!(Finch, :DocTestSetup, :(using Finch; using SparseArrays); recursive=true)

Literate.notebook(joinpath(@__DIR__, "src/interactive.jl"), joinpath(@__DIR__, "src"), credit = false)

doctest(Finch, fix=true)
2 changes: 0 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ if abspath(PROGRAM_FILE) == @__FILE__
using Pkg
Pkg.activate(@__DIR__)
Pkg.develop(PackageSpec(path = joinpath(@__DIR__, "..")))
Pkg.resolve()
Pkg.instantiate()
end

using Documenter
using Documenter.Remotes
using Literate
using Finch

DocMeta.setdocmeta!(Finch, :DocTestSetup, :(using Finch; using SparseArrays); recursive=true)
Expand Down
149 changes: 71 additions & 78 deletions docs/src/guides/array_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,87 +10,79 @@ For example:

```jldoctest example1; setup = :(using Finch)
julia> A = fsparse([1, 1, 2, 3], [2, 4, 5, 6], [1.0, 2.0, 3.0])
SparseCOO{2} (0.0) [:,1:6]
├─ [1, 2]: 1.0
├─ [1, 4]: 2.0
└─ [2, 5]: 3.0
3×6-Tensor
└─ SparseCOO{2} (0.0) [:,1:6]
├─ [1, 2]: 1.0
├─ [1, 4]: 2.0
└─ [2, 5]: 3.0
julia> A + 0
Dense [:,1:6]
├─ [:, 1]: Dense [1:3]
│ ├─ [1]: 0.0
│ ├─ [2]: 0.0
│ └─ [3]: 0.0
├─ [:, 2]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 0.0
│ └─ [3]: 0.0
├─ [:, 3]: Dense [1:3]
│ ├─ [1]: 0.0
│ ├─ [2]: 0.0
│ └─ [3]: 0.0
├─ [:, 4]: Dense [1:3]
│ ├─ [1]: 2.0
│ ├─ [2]: 0.0
│ └─ [3]: 0.0
├─ [:, 5]: Dense [1:3]
│ ├─ [1]: 0.0
│ ├─ [2]: 3.0
│ └─ [3]: 0.0
└─ [:, 6]: Dense [1:3]
├─ [1]: 0.0
├─ [2]: 0.0
└─ [3]: 0.0
3×6-Tensor
└─ Dense [:,1:6]
├─ [:, 1]: Dense [1:3]
│ ├─ [1]: 0.0
│ ├─ [2]: 0.0
│ └─ [3]: 0.0
├─ [:, 2]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 0.0
│ └─ [3]: 0.0
├─ ⋮
├─ [:, 5]: Dense [1:3]
│ ├─ [1]: 0.0
│ ├─ [2]: 3.0
│ └─ [3]: 0.0
└─ [:, 6]: Dense [1:3]
├─ [1]: 0.0
├─ [2]: 0.0
└─ [3]: 0.0
julia> A + 1
Dense [:,1:6]
├─ [:, 1]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 1.0
│ └─ [3]: 1.0
├─ [:, 2]: Dense [1:3]
│ ├─ [1]: 2.0
│ ├─ [2]: 1.0
│ └─ [3]: 1.0
├─ [:, 3]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 1.0
│ └─ [3]: 1.0
├─ [:, 4]: Dense [1:3]
│ ├─ [1]: 3.0
│ ├─ [2]: 1.0
│ └─ [3]: 1.0
├─ [:, 5]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 4.0
│ └─ [3]: 1.0
└─ [:, 6]: Dense [1:3]
├─ [1]: 1.0
├─ [2]: 1.0
└─ [3]: 1.0
3×6-Tensor
└─ Dense [:,1:6]
├─ [:, 1]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 1.0
│ └─ [3]: 1.0
├─ [:, 2]: Dense [1:3]
│ ├─ [1]: 2.0
│ ├─ [2]: 1.0
│ └─ [3]: 1.0
├─ ⋮
├─ [:, 5]: Dense [1:3]
│ ├─ [1]: 1.0
│ ├─ [2]: 4.0
│ └─ [3]: 1.0
└─ [:, 6]: Dense [1:3]
├─ [1]: 1.0
├─ [2]: 1.0
└─ [3]: 1.0
julia> B = A .* 2
Sparse (0.0) [:,1:6]
├─ [:, 2]: Sparse (0.0) [1:3]
│ └─ [1]: 2.0
├─ [:, 4]: Sparse (0.0) [1:3]
│ └─ [1]: 4.0
└─ [:, 5]: Sparse (0.0) [1:3]
└─ [2]: 6.0
3×6-Tensor
└─ Sparse (0.0) [:,1:6]
├─ [:, 2]: Sparse (0.0) [1:3]
│ └─ [1]: 2.0
├─ [:, 4]: Sparse (0.0) [1:3]
│ └─ [1]: 4.0
└─ [:, 5]: Sparse (0.0) [1:3]
└─ [2]: 6.0
julia> B[1:2, 1:2]
Sparse (0.0) [:,1:2]
└─ [:, 2]: Sparse (0.0) [1:2]
└─ [1]: 2.0
2×2-Tensor
└─ Sparse (0.0) [:,1:2]
└─ [:, 2]: Sparse (0.0) [1:2]
└─ [1]: 2.0
julia> map(x -> x^2, B)
Sparse (0.0) [:,1:6]
├─ [:, 2]: Sparse (0.0) [1:3]
│ └─ [1]: 4.0
├─ [:, 4]: Sparse (0.0) [1:3]
│ └─ [1]: 16.0
└─ [:, 5]: Sparse (0.0) [1:3]
└─ [2]: 36.0
3×6-Tensor
└─ Sparse (0.0) [:,1:6]
├─ [:, 2]: Sparse (0.0) [1:3]
│ └─ [1]: 4.0
├─ [:, 4]: Sparse (0.0) [1:3]
│ └─ [1]: 16.0
└─ [:, 5]: Sparse (0.0) [1:3]
└─ [2]: 36.0
```

# Array Fusion
Expand All @@ -110,13 +102,14 @@ julia> D = lazy(B);
julia> E = (C .+ D)/2;
julia> compute(E)
Sparse (0.0) [:,1:6]
├─ [:, 2]: Sparse (0.0) [1:3]
│ └─ [1]: 1.5
├─ [:, 4]: Sparse (0.0) [1:3]
│ └─ [1]: 3.0
└─ [:, 5]: Sparse (0.0) [1:3]
└─ [2]: 4.5
3×6-Tensor
└─ Sparse (0.0) [:,1:6]
├─ [:, 2]: Sparse (0.0) [1:3]
│ └─ [1]: 1.5
├─ [:, 4]: Sparse (0.0) [1:3]
│ └─ [1]: 3.0
└─ [:, 5]: Sparse (0.0) [1:3]
└─ [2]: 4.5
```

Expand Down
21 changes: 12 additions & 9 deletions docs/src/guides/interoperability.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,26 @@ julia> ptr_jl = reinterpret(CIndex{Int}, ptr_c)
4
4
6
julia> idx_jl = reinterpret(CIndex{Int}, idx_c)
5-element reinterpret(CIndex{Int64}, ::Vector{Int64}):
2
3
4
1
3
julia> A = Tensor(Dense(SparseList{CIndex{Int}}(Element{0.0, Float64, CIndex{Int}}(val_c), m, ptr_jl, idx_jl), n))
Dense [:,1:3]
├─ [:, 1]: SparseList (0.0) [1:CIndex{Int64}(4)]
│ ├─ [CIndex{Int64}(2)]: 1.1
│ ├─ [CIndex{Int64}(3)]: 2.2
│ └─ [CIndex{Int64}(4)]: 3.3
├─ [:, 2]: SparseList (0.0) [1:CIndex{Int64}(4)]
└─ [:, 3]: SparseList (0.0) [1:CIndex{Int64}(4)]
├─ [CIndex{Int64}(1)]: 4.4
└─ [CIndex{Int64}(3)]: 5.5
CIndex{Int64}(4)×3-Tensor
└─ Dense [:,1:3]
├─ [:, 1]: SparseList (0.0) [1:CIndex{Int64}(4)]
│ ├─ [CIndex{Int64}(2)]: 1.1
│ ├─ [CIndex{Int64}(3)]: 2.2
│ └─ [CIndex{Int64}(4)]: 3.3
├─ [:, 2]: SparseList (0.0) [1:CIndex{Int64}(4)]
└─ [:, 3]: SparseList (0.0) [1:CIndex{Int64}(4)]
├─ [CIndex{Int64}(1)]: 4.4
└─ [CIndex{Int64}(3)]: 5.5
```

We can also convert between representations by copying to or from `CIndex` fibers.
Loading

2 comments on commit c6b94f5

@mtsokol
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/107287

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.29 -m "<description of version>" c6b94f58c81866021bcff417810e6045eca23e58
git push origin v0.6.29

Please sign in to comment.