-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathDifferentiationInterfaceTestChairmarksExt.jl
More file actions
127 lines (120 loc) · 3.2 KB
/
DifferentiationInterfaceTestChairmarksExt.jl
File metadata and controls
127 lines (120 loc) · 3.2 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
module DifferentiationInterfaceTestChairmarksExt
using ADTypes: AbstractADType
using Chairmarks: @be, Benchmark, Sample
import DifferentiationInterface as DI
using DifferentiationInterface:
prepare_pushforward,
prepare_pushforward_same_point,
prepare!_pushforward,
pushforward,
pushforward!,
value_and_pushforward,
value_and_pushforward!,
prepare_pullback,
prepare_pullback_same_point,
prepare!_pullback,
pullback,
pullback!,
value_and_pullback,
value_and_pullback!,
prepare_derivative,
prepare!_derivative,
derivative,
derivative!,
value_and_derivative,
value_and_derivative!,
prepare_gradient,
prepare!_gradient,
gradient,
gradient!,
value_and_gradient,
value_and_gradient!,
prepare_jacobian,
prepare!_jacobian,
jacobian,
jacobian!,
value_and_jacobian,
value_and_jacobian!,
prepare_second_derivative,
prepare!_second_derivative,
second_derivative,
second_derivative!,
value_derivative_and_second_derivative,
value_derivative_and_second_derivative!,
prepare_hvp,
prepare_hvp_same_point,
prepare!_hvp,
hvp,
hvp!,
gradient_and_hvp,
gradient_and_hvp!,
prepare_hessian,
prepare!_hessian,
hessian,
hessian!,
value_gradient_and_hessian,
value_gradient_and_hessian!
import DifferentiationInterfaceTest as DIT
using DifferentiationInterfaceTest:
ALL_OPS,
CallCounter, CallsResult, DifferentiationBenchmarkDataRow, DifferentiationBenchmark, Scenario,
mysimilar, reset_count!
using Test: Test, @test
function failed_bench()
evals = 0.0
time = NaN
allocs = NaN
bytes = NaN
gc_fraction = NaN
compile_fraction = NaN
recompile_fraction = NaN
warmup = NaN
checksum = NaN
sample = Sample(
evals,
time,
allocs,
bytes,
gc_fraction,
compile_fraction,
recompile_fraction,
warmup,
checksum,
)
return Benchmark([sample])
end
@kwdef struct BenchmarkResult
prepared_valop::Benchmark = failed_bench()
prepared_op::Benchmark = failed_bench()
preparation::Benchmark = failed_bench()
unprepared_valop::Benchmark = failed_bench()
unprepared_op::Benchmark = failed_bench()
end
function record!(
data::DifferentiationBenchmark;
backend::AbstractADType,
scenario::Scenario,
operator::String,
prepared::Union{Nothing, Bool},
bench::Benchmark,
calls::Integer,
aggregation,
)
row = DifferentiationBenchmarkDataRow(;
backend = backend,
scenario = scenario,
operator = Symbol(operator),
prepared = prepared,
calls = calls,
samples = length(bench.samples),
evals = Int(bench.samples[1].evals),
time = aggregation(getfield.(bench.samples, :time)),
allocs = aggregation(getfield.(bench.samples, :allocs)),
bytes = aggregation(getfield.(bench.samples, :bytes)),
gc_fraction = aggregation(getfield.(bench.samples, :gc_fraction)),
compile_fraction = aggregation(getfield.(bench.samples, :compile_fraction)),
)
return push!(data.rows, row)
end
include("benchmark_eval.jl")
end