@@ -5,6 +5,14 @@ using ADTypes, SparseDiffTools,
5
5
StaticArrays
6
6
using ADTypes: dense_ad
7
7
8
+ function nice_string (ad:: AbstractADType )
9
+ if ad isa AutoSparse
10
+ return " AutoSparse($(nice_string (dense_ad (ad))) )"
11
+ else
12
+ return nameof (typeof (ad))
13
+ end
14
+ end
15
+
8
16
function __chunksize (:: Union {
9
17
AutoSparse{<: AutoForwardDiff{C} }, AutoForwardDiff{C},
10
18
AutoSparse{<: AutoPolyesterForwardDiff{C} }, AutoPolyesterForwardDiff{C}
@@ -70,7 +78,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
70
78
AutoPolyesterForwardDiff (; chunksize = 4 )
71
79
]
72
80
73
- @testset " sparse_jacobian $(nameof ( typeof ( difftype) )) : Out of Place" for difftype in DIFFTYPES
81
+ @testset " sparse_jacobian $(nice_string ( difftype)) : Out of Place" for difftype in DIFFTYPES
74
82
@testset " Cache & Reuse" begin
75
83
cache = sparse_jacobian_cache (difftype, sd, fdiff, x)
76
84
J = init_jacobian (cache)
@@ -81,7 +89,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
81
89
@inferred sparse_jacobian! (J, difftype, cache, fdiff, x)
82
90
83
91
t₁ = @elapsed sparse_jacobian! (J, difftype, cache, fdiff, x)
84
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian!` (only differentiation) time: $(t₁) s"
92
+ @info " $(nice_string ( difftype)) () `sparse_jacobian!` (only differentiation) time: $(t₁) s"
85
93
86
94
J = sparse_jacobian (difftype, cache, fdiff, x)
87
95
@@ -92,7 +100,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
92
100
end
93
101
94
102
t₂ = @elapsed sparse_jacobian (difftype, cache, fdiff, x)
95
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian` (with matrix allocation) time: $(t₂) s"
103
+ @info " $(nice_string ( difftype)) () `sparse_jacobian` (with matrix allocation) time: $(t₂) s"
96
104
end
97
105
98
106
@testset " Single Use" begin
@@ -104,7 +112,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
104
112
end
105
113
106
114
t₁ = @elapsed sparse_jacobian (difftype, sd, fdiff, x)
107
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian` (complete) time: $(t₁) s"
115
+ @info " $(nice_string ( difftype)) () `sparse_jacobian` (complete) time: $(t₁) s"
108
116
109
117
cache = sparse_jacobian_cache (difftype, sd, fdiff, x)
110
118
J = init_jacobian (cache)
@@ -115,13 +123,13 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
115
123
@inferred sparse_jacobian! (J, difftype, sd, fdiff, x)
116
124
117
125
t₂ = @elapsed sparse_jacobian! (J, difftype, sd, fdiff, x)
118
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian!` (with matrix coloring) time: $(t₂) s"
126
+ @info " $(nice_string ( difftype)) () `sparse_jacobian!` (with matrix coloring) time: $(t₂) s"
119
127
end
120
128
end
121
129
122
130
@info " Inplace Place Function"
123
131
124
- @testset " sparse_jacobian $(nameof ( typeof ( difftype) )) : In place" for difftype in (
132
+ @testset " sparse_jacobian $(nice_string ( difftype)) : In place" for difftype in (
125
133
AutoSparse (AutoForwardDiff ()), AutoForwardDiff (),
126
134
AutoSparse (AutoForwardDiff (; chunksize = 0 )), AutoForwardDiff (; chunksize = 0 ),
127
135
AutoSparse (AutoForwardDiff (; chunksize = 4 )), AutoForwardDiff (; chunksize = 4 ),
@@ -138,7 +146,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
138
146
@inferred sparse_jacobian! (J, difftype, cache, fdiff, y, x)
139
147
140
148
t₁ = @elapsed sparse_jacobian! (J, difftype, cache, fdiff, y, x)
141
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian!` (only differentiation) time: $(t₁) s"
149
+ @info " $(nice_string ( difftype)) () `sparse_jacobian!` (only differentiation) time: $(t₁) s"
142
150
143
151
J = sparse_jacobian (difftype, cache, fdiff, y, x)
144
152
@@ -148,7 +156,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
148
156
end
149
157
150
158
t₂ = @elapsed sparse_jacobian (difftype, cache, fdiff, y, x)
151
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian` (with jacobian allocation) time: $(t₂) s"
159
+ @info " $(nice_string ( difftype)) () `sparse_jacobian` (with jacobian allocation) time: $(t₂) s"
152
160
end
153
161
154
162
@testset " Single Use" begin
@@ -160,7 +168,7 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
160
168
end
161
169
162
170
t₁ = @elapsed sparse_jacobian (difftype, sd, fdiff, y, x)
163
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian` (complete) time: $(t₁) s"
171
+ @info " $(nice_string ( difftype)) () `sparse_jacobian` (complete) time: $(t₁) s"
164
172
165
173
J = init_jacobian (cache)
166
174
@@ -170,11 +178,11 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa
170
178
@inferred sparse_jacobian! (J, difftype, sd, fdiff, y, x)
171
179
172
180
t₂ = @elapsed sparse_jacobian! (J, difftype, sd, fdiff, y, x)
173
- @info " $(nameof ( typeof ( difftype) )) () `sparse_jacobian!` (with matrix coloring) time: $(t₂) s"
181
+ @info " $(nice_string ( difftype)) () `sparse_jacobian!` (with matrix coloring) time: $(t₂) s"
174
182
end
175
183
end
176
184
177
- @testset " sparse_jacobian $(nameof ( typeof ( difftype) )) : In place" for difftype in (
185
+ @testset " sparse_jacobian $(nice_string ( difftype)) : In place" for difftype in (
178
186
AutoSparse (AutoZygote ()),
179
187
AutoZygote ())
180
188
y = similar (x)
0 commit comments