Skip to content

Commit d66b03e

Browse files
committed
Add IndexManipulationBenchmarks
1 parent 7300439 commit d66b03e

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module IndexManipulationBenchmarks
2+
3+
include(joinpath(@__DIR__, "..", "utils", "BenchUtils.jl"))
4+
5+
using .BenchUtils
6+
using BenchmarkTools
7+
using TensorKit
8+
using TOML
9+
10+
const SUITE = BenchmarkGroup()
11+
const all_parameters = TOML.parsefile(joinpath(@__DIR__, "benchparams.toml"))
12+
13+
# permute!
14+
# --------
15+
function init_permute_tensors(T, W, p)
16+
C = randn(T, permute(W, p))
17+
A = randn(T, W)
18+
return C, A
19+
end
20+
function benchmark_permute!(benchgroup, params::Dict)
21+
haskey(benchgroup, "permute") || addgroup!(benchgroup, "permute")
22+
bench = benchgroup["permute"]
23+
for kwargs in expand_kwargs(params)
24+
benchmark_permute!(bench; kwargs...)
25+
end
26+
return nothing
27+
end
28+
function benchmark_permute!(bench; sigmas=nothing, T="Float64", I="Trivial", dims, p)
29+
T_ = parse_type(T)
30+
I_ = parse_type(I)
31+
32+
p_ = (Tuple(p[1]), Tuple(p[2]))
33+
Vs = generate_space.(I_, dims, sigmas)
34+
35+
codomain = mapreduce(Base.Fix1(getindex, Vs), , p_[1]; init=one(eltype(Vs)))
36+
domain = mapreduce(Base.Fix1(getindex, Vs), , p_[2]; init=one(eltype(Vs)))
37+
init() = init_permute_tensors(T_, codomain domain, p_)
38+
39+
bench[T, I, dims, sigmas, p] = @benchmarkable permute!(C, A, $p_) setup = ((C, A) = $init())
40+
return nothing
41+
end
42+
43+
if haskey(all_parameters, "permute")
44+
g = addgroup!(SUITE, "permute")
45+
for params in all_parameters["permute"]
46+
benchmark_permute!(g, params)
47+
end
48+
end
49+
50+
# transpose!
51+
# ----------
52+
53+
# TODO
54+
55+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[permute]]
2+
T = ["Float64"]
3+
I = "Trivial"
4+
p = [[[2, 1], []]]
5+
dims = [[7264, 7264], [43408, 1216]]
6+
7+
[[permute]]
8+
T = ["Float64"]
9+
I = "Z2Irrep"
10+
p = [[[2, 1], []]]
11+
dims = [[7264, 7264], [43408, 1216]]
12+
sigmas = [[0.5, 0.5]]

0 commit comments

Comments
 (0)