|
1 | 1 | ## Sparse Jacobian tests |
2 | | -using SparseDiffTools, |
3 | | - Symbolics, ForwardDiff, LinearAlgebra, SparseArrays, Zygote, Enzyme, Test, |
| 2 | +using ADTypes, SparseDiffTools, |
| 3 | + Symbolics, ForwardDiff, PolyesterForwardDiff, LinearAlgebra, SparseArrays, Zygote, |
| 4 | + Enzyme, Test, |
4 | 5 | StaticArrays |
| 6 | +using ADTypes: dense_ad |
5 | 7 |
|
6 | | -@static if VERSION ≥ v"1.9" |
7 | | - using PolyesterForwardDiff |
8 | | -end |
9 | | - |
10 | | -function __chunksize(::Union{AutoSparse{<:AutoForwardDiff}{C}, AutoForwardDiff{C}, |
11 | | - AutoSparse{<:AutoPolyesterForwardDiff}{C}, AutoPolyesterForwardDiff{C}}) where {C} |
| 8 | +function __chunksize(::Union{ |
| 9 | + AutoSparse{<:AutoForwardDiff{C}}, AutoForwardDiff{C}, |
| 10 | + AutoSparse{<:AutoPolyesterForwardDiff{C}}, AutoPolyesterForwardDiff{C} |
| 11 | +}) where {C} |
12 | 12 | return C |
13 | 13 | end |
14 | 14 |
|
15 | 15 | function __isinferrable(difftype) |
16 | | - return !(difftype isa AutoSparse{<:AutoForwardDiff} || difftype isa AutoForwardDiff || |
| 16 | + return !(difftype isa AutoSparse{<:AutoForwardDiff} || |
| 17 | + difftype isa AutoForwardDiff || |
17 | 18 | difftype isa AutoSparse{<:AutoPolyesterForwardDiff} || |
18 | 19 | difftype isa AutoPolyesterForwardDiff) || |
19 | 20 | (__chunksize(difftype) isa Int && __chunksize(difftype) > 0) |
@@ -51,24 +52,23 @@ SPARSITY_DETECTION_ALGS = [JacPrototypeSparsityDetection(; jac_prototype = J_spa |
51 | 52 | PrecomputedJacobianColorvec(; jac_prototype = J_sparsity, row_colorvec, col_colorvec)] |
52 | 53 |
|
53 | 54 | @testset "High-Level API" begin |
54 | | - @testset "Sparsity Detection: $(nameof(typeof(sd)))" for sd in SPARSITY_DETECTION_ALGS |
| 55 | + @testset "Sparsity Detection: $(nameof(typeof(sd))) - $(isa(ad, AutoSparse) ? $(nameof(typeof(dense_ad(ad)))) : "")" for sd in SPARSITY_DETECTION_ALGS |
55 | 56 | @info "Sparsity Detection: $(nameof(typeof(sd)))" |
56 | 57 | @info "Out of Place Function" |
57 | 58 |
|
58 | | - DIFFTYPES = [AutoSparse(AutoZygote()), AutoZygote(), AutoSparse(AutoForwardDiff()), |
59 | | - AutoForwardDiff(), AutoSparse(AutoForwardDiff(; chunksize = 0)), |
60 | | - AutoForwardDiff(; chunksize = 0), AutoSparse(AutoForwardDiff(; chunksize = 4)), |
61 | | - AutoForwardDiff(; chunksize = 4), AutoSparse(AutoFiniteDiff()), AutoFiniteDiff(), |
62 | | - AutoEnzyme(), AutoSparse(AutoEnzyme())] |
63 | | - |
64 | | - if VERSION ≥ v"1.9" |
65 | | - append!(DIFFTYPES, |
66 | | - [AutoSparse(AutoPolyesterForwardDiff()), AutoPolyesterForwardDiff(), |
67 | | - AutoSparse(AutoPolyesterForwardDiff(; chunksize = 0)), |
68 | | - AutoPolyesterForwardDiff(; chunksize = 0), |
69 | | - AutoSparse(AutoPolyesterForwardDiff(; chunksize = 4)), |
70 | | - AutoPolyesterForwardDiff(; chunksize = 4)]) |
71 | | - end |
| 59 | + DIFFTYPES = [ |
| 60 | + AutoSparse(AutoZygote()), AutoZygote(), |
| 61 | + AutoSparse(AutoForwardDiff()), AutoForwardDiff(), |
| 62 | + AutoSparse(AutoForwardDiff(; chunksize = 0)), AutoForwardDiff(; chunksize = 0), |
| 63 | + AutoSparse(AutoForwardDiff(; chunksize = 4)), AutoForwardDiff(; chunksize = 4), |
| 64 | + AutoSparse(AutoFiniteDiff()), AutoFiniteDiff(), |
| 65 | + AutoEnzyme(), AutoSparse(AutoEnzyme()), |
| 66 | + AutoSparse(AutoPolyesterForwardDiff()), AutoPolyesterForwardDiff(), |
| 67 | + AutoSparse(AutoPolyesterForwardDiff(; chunksize = 0)), |
| 68 | + AutoPolyesterForwardDiff(; chunksize = 0), |
| 69 | + AutoSparse(AutoPolyesterForwardDiff(; chunksize = 4)), |
| 70 | + AutoPolyesterForwardDiff(; chunksize = 4) |
| 71 | + ] |
72 | 72 |
|
73 | 73 | @testset "sparse_jacobian $(nameof(typeof(difftype))): Out of Place" for difftype in DIFFTYPES |
74 | 74 | @testset "Cache & Reuse" begin |
|
0 commit comments