-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BlockSparseArrays] Function for fusing dimensions of `BlockSparseArr…
…ay` (#1246)
- Loading branch information
Showing
13 changed files
with
514 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# TODO: Delete | ||
## function NDTensors.outer(s1::Base.OneTo, s2::Base.OneTo) | ||
## return Base.OneTo(length(s1) * length(s2)) | ||
## end | ||
|
||
function blockmerge(s::Base.OneTo, grouped_perm::Vector{Vector{Int}}) | ||
@assert grouped_perm == [[1]] | ||
return s | ||
end | ||
|
||
blockmergesortperm(s::Base.OneTo) = [[1]] | ||
|
||
function sub_axis(a::BlockedUnitRange, blocks) | ||
return blockedrange([length(a[b]) for b in blocks]) | ||
end | ||
|
||
function sub_axes(axes_src::Tuple, axes_parent::Tuple) | ||
return sub_axis.(axes_src, axes_parent) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function groupsorted(v) | ||
return groupcount(identity, v) | ||
end | ||
|
||
# Get the permutation for sorting, then group by common elements. | ||
# groupsortperm([2, 1, 2, 3]) == [[2], [1, 3], [4]] | ||
function groupsortperm(v) | ||
perm = sortperm(v) | ||
v_sorted = @view v[perm] | ||
group_lengths = groupsorted(v_sorted) | ||
return blocks(BlockVector(perm, collect(group_lengths))) | ||
end | ||
|
||
tuple_cat(ts::Tuple...) = reduce((x, y) -> (x..., y...), ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Extensions to BlockArrays.jl | ||
blocktuple(b::Block) = Block.(b.n) | ||
inttuple(b::Block) = b.n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.