-
-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Description
I've just noticed that RecursiveArrayTools.jl
has something similar to ProductRepr
from Manifolds.jl
, and here it's called PartitionArray
. It would be nice if both efforts could be unified to mutually gain from new developments. The main difference seems to be in the way they handle broadcasting. I don't know why they differ but the first difference I've noticed is that ProductRepr
broadcasting is faster:
julia> a = ArrayPartition(SA[1, 2], SA[1 2; 3 4])
([1, 2], [1 2; 3 4])
julia> b = ArrayPartition(SA[1, 2], SA[1 2; 3 4])
([1, 2], [1 2; 3 4])
julia> c = ArrayPartition((@MVector [1, 2]), (@MMatrix [1 2; 3 4]))
([1, 2], [1 2; 3 4])
julia> ap = ProductRepr(SA[1, 2], SA[1 2; 3 4])
ProductRepr with 2 submanifold components:
Component 1 =
2-element SVector{2, Int64} with indices SOneTo(2):
1
2
Component 2 =
2×2 SMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
1 2
3 4
julia> bp = ProductRepr(SA[1, 2], SA[1 2; 3 4])
ProductRepr with 2 submanifold components:
Component 1 =
2-element SVector{2, Int64} with indices SOneTo(2):
1
2
Component 2 =
2×2 SMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
1 2
3 4
julia> cp = ProductRepr((@MVector [1, 2]), (@MMatrix [1 2; 3 4]))
ProductRepr with 2 submanifold components:
Component 1 =
2-element MVector{2, Int64} with indices SOneTo(2):
1
2
Component 2 =
2×2 MMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
1 2
3 4
julia> f(a, b) = a .+ b
f (generic function with 1 method)
julia> f!(c, a, b) = c.= a .+ b
f! (generic function with 1 method)
julia> @benchmark f($a, $b)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
Range (min … max): 3.196 ns … 9.457 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 3.284 ns ┊ GC (median): 0.00%
Time (mean ± σ): 3.299 ns ± 0.146 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▁▄▃██▄▇▆ ▁
▁▁▁▁▁▁▁▃▄▅██████████▆▄▄▃▂▂▂▂▂▂▁▁▂▁▁▂▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
3.2 ns Histogram: frequency by time 3.52 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark f($ap, $bp)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
Range (min … max): 0.023 ns … 4.012 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 0.025 ns ┊ GC (median): 0.00%
Time (mean ± σ): 0.026 ns ± 0.040 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█
▃▁▁▁▁▁▁▁▁▁▁▅▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▆▁▁▁▁▁▁▁▁▁▁▂ ▂
023 ns Histogram: frequency by time 028 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark f!($c, $a, $b)
BenchmarkTools.Trial: 10000 samples with 71 evaluations.
Range (min … max): 836.789 ns … 83.129 μs ┊ GC (min … max): 0.00% … 98.49%
Time (median): 878.359 ns ┊ GC (median): 0.00%
Time (mean ± σ): 975.382 ns ± 2.561 μs ┊ GC (mean ± σ): 8.28% ± 3.12%
▁▄▆███▇▇▇▆▆▅▄▄▄▃▂▂▂▂▁ ▁ ▁▁▁ ▁▁▁▁▁ ▃
▄▆▇█████████████████████████████████████████▇█▇█▇▇▆▆▆▇▇▆▇▆▆▆ █
837 ns Histogram: log(frequency) by time 1.1 μs <
Memory estimate: 672 bytes, allocs estimate: 12.
julia> @benchmark f!($cp, $ap, $bp)
BenchmarkTools.Trial: 10000 samples with 755 evaluations.
Range (min … max): 177.677 ns … 6.882 μs ┊ GC (min … max): 0.00% … 97.06%
Time (median): 185.719 ns ┊ GC (median): 0.00%
Time (mean ± σ): 227.402 ns ± 472.338 ns ┊ GC (mean ± σ): 17.13% ± 7.94%
▂▆██▇▅▄▂▂▂▁▂▁▁▁▁▁ ▂
▄██████████████████▇▇▇▆▆▇▇▄▅▆▅▄▅▄▁▃▃▁▃▄▁▁▁▁▃▁▃▁▁▃▁▃▃▅▅▅▆▆▆▆▇▇ █
178 ns Histogram: log(frequency) by time 290 ns <
Memory estimate: 416 bytes, allocs estimate: 8.
Would someone here be willing to review some changes to broadcasting?
Metadata
Metadata
Assignees
Labels
No labels