@@ -29,12 +29,14 @@ J_sparsity = Symbolics.jacobian_sparsity(fdiff, similar(x), x);
2929SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection (jac_prototype = J_sparsity),
3030 SymbolicsSparsityDetection (), NoSparsityDetection ()]
3131
32- @testset " Sparsity Detection: $(nameof (typeof (sd))) " for sd in SPARSITY_DETECTION_ALGS
33- @info " Sparsity Detection: $(nameof (typeof (sd))) "
34- @info " Out of Place Function"
35- @testset " sparse_jacobian: Out of Place" begin
36- for difftype in (AutoSparseZygote (), AutoZygote (), AutoSparseForwardDiff (),
37- AutoForwardDiff (), AutoSparseFiniteDiff (), AutoFiniteDiff ())
32+ @testset " High-Level API" begin
33+ @testset " Sparsity Detection: $(nameof (typeof (sd))) " for sd in SPARSITY_DETECTION_ALGS
34+ @info " Sparsity Detection: $(nameof (typeof (sd))) "
35+ @info " Out of Place Function"
36+
37+ @testset " sparse_jacobian $(nameof (typeof (difftype))) : Out of Place" for difftype in (AutoSparseZygote (),
38+ AutoZygote (), AutoSparseForwardDiff (), AutoForwardDiff (),
39+ AutoSparseFiniteDiff (), AutoFiniteDiff ())
3840 @testset " Cache & Reuse" begin
3941 cache = sparse_jacobian_cache (difftype, sd, fdiff, x)
4042 J = SparseDiffTools. __init_𝒥 (cache)
@@ -50,7 +52,10 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
5052 J = sparse_jacobian (difftype, cache, fdiff, x)
5153
5254 @test J ≈ J_true
53- # @inferred sparse_jacobian(difftype, cache, fdiff, x)
55+
56+ if ! (difftype isa AutoSparseForwardDiff || difftype isa AutoForwardDiff)
57+ @inferred sparse_jacobian (difftype, cache, fdiff, x)
58+ end
5459
5560 t₂ = @elapsed sparse_jacobian (difftype, cache, fdiff, x)
5661 @info " $(nameof (typeof (difftype))) () `sparse_jacobian` (with matrix allocation) time: $(t₂) s"
@@ -60,7 +65,9 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
6065 J = sparse_jacobian (difftype, sd, fdiff, x)
6166
6267 @test J ≈ J_true
63- # @inferred sparse_jacobian(difftype, sd, fdiff, x)
68+ if ! (difftype isa AutoSparseForwardDiff || difftype isa AutoForwardDiff)
69+ @inferred sparse_jacobian (difftype, sd, fdiff, x)
70+ end
6471
6572 t₁ = @elapsed sparse_jacobian (difftype, sd, fdiff, x)
6673 @info " $(nameof (typeof (difftype))) () `sparse_jacobian` (complete) time: $(t₁) s"
@@ -77,14 +84,14 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
7784 @info " $(nameof (typeof (difftype))) () `sparse_jacobian!` (with matrix coloring) time: $(t₂) s"
7885 end
7986 end
80- end
8187
82- @info " Inplace Place Function"
83- @testset " sparse_jacobian: In place " begin
84- for difftype in (AutoSparseForwardDiff (), AutoForwardDiff (), AutoSparseFiniteDiff (),
85- AutoFiniteDiff ())
88+ @info " Inplace Place Function"
89+
90+ @testset " sparse_jacobian $( nameof ( typeof (difftype))) : In place " for difftype in (AutoSparseForwardDiff (),
91+ AutoForwardDiff (), AutoSparseFiniteDiff (), AutoFiniteDiff ())
8692 y = similar (x)
8793 cache = sparse_jacobian_cache (difftype, sd, fdiff, y, x)
94+
8895 @testset " Cache & Reuse" begin
8996 J = SparseDiffTools. __init_𝒥 (cache)
9097 sparse_jacobian! (J, difftype, cache, fdiff, y, x)
@@ -98,7 +105,9 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
98105 J = sparse_jacobian (difftype, cache, fdiff, y, x)
99106
100107 @test J ≈ J_true
101- # @inferred sparse_jacobian(difftype, cache, fdiff, y, x)
108+ if ! (difftype isa AutoSparseForwardDiff || difftype isa AutoForwardDiff)
109+ @inferred sparse_jacobian (difftype, cache, fdiff, y, x)
110+ end
102111
103112 t₂ = @elapsed sparse_jacobian (difftype, cache, fdiff, y, x)
104113 @info " $(nameof (typeof (difftype))) () `sparse_jacobian` (with jacobian allocation) time: $(t₂) s"
@@ -108,7 +117,9 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
108117 J = sparse_jacobian (difftype, sd, fdiff, y, x)
109118
110119 @test J ≈ J_true
111- # @inferred sparse_jacobian(difftype, sd, fdiff, y, x)
120+ if ! (difftype isa AutoSparseForwardDiff || difftype isa AutoForwardDiff)
121+ @inferred sparse_jacobian (difftype, sd, fdiff, y, x)
122+ end
112123
113124 t₁ = @elapsed sparse_jacobian (difftype, sd, fdiff, y, x)
114125 @info " $(nameof (typeof (difftype))) () `sparse_jacobian` (complete) time: $(t₁) s"
@@ -125,7 +136,8 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
125136 end
126137 end
127138
128- for difftype in (AutoSparseZygote (), AutoZygote ())
139+ @testset " sparse_jacobian $(nameof (typeof (difftype))) : In place" for difftype in (AutoSparseZygote (),
140+ AutoZygote ())
129141 y = similar (x)
130142 cache = sparse_jacobian_cache (difftype, sd, fdiff, y, x)
131143 J = SparseDiffTools. __init_𝒥 (cache)
@@ -141,4 +153,4 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(jac_prototype = J_spars
141153 end
142154 end
143155 end
144- end
156+ end
0 commit comments