-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathIndexManipulationBenchmarks.jl
More file actions
55 lines (44 loc) · 1.42 KB
/
IndexManipulationBenchmarks.jl
File metadata and controls
55 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module IndexManipulationBenchmarks
include(joinpath(@__DIR__, "..", "utils", "BenchUtils.jl"))
using .BenchUtils
using BenchmarkTools
using TensorKit
using TOML
const SUITE = BenchmarkGroup()
const all_parameters = TOML.parsefile(joinpath(@__DIR__, "benchparams.toml"))
# permute!
# --------
function init_permute_tensors(T, W, p)
C = randn(T, permute(W, p))
A = randn(T, W)
return C, A
end
function benchmark_permute!(benchgroup, params::Dict)
haskey(benchgroup, "permute") || addgroup!(benchgroup, "permute")
bench = benchgroup["permute"]
for kwargs in expand_kwargs(params)
benchmark_permute!(bench; kwargs...)
end
return nothing
end
function benchmark_permute!(bench; sigmas=nothing, T="Float64", I="Trivial", dims, p)
T_ = parse_type(T)
I_ = parse_type(I)
p_ = (Tuple(p[1]), Tuple(p[2]))
Vs = generate_space.(I_, dims, sigmas)
codomain = mapreduce(Base.Fix1(getindex, Vs), ⊗, p_[1]; init=one(eltype(Vs)))
domain = mapreduce(Base.Fix1(getindex, Vs), ⊗, p_[2]; init=one(eltype(Vs)))
init() = init_permute_tensors(T_, codomain ← domain, p_)
bench[T, I, dims, sigmas, p] = @benchmarkable permute!(C, A, $p_) setup = ((C, A) = $init())
return nothing
end
if haskey(all_parameters, "permute")
g = addgroup!(SUITE, "permute")
for params in all_parameters["permute"]
benchmark_permute!(g, params)
end
end
# transpose!
# ----------
# TODO
end