@@ -6,17 +6,19 @@ struct ForwardDiffJacobianCache{CO, CA, J, FX, X} <: AbstractMaybeSparseJacobian
66 x:: X
77end
88
9+ struct SparseDiffToolsTag end
10+
911function sparse_jacobian_cache (ad:: Union{AutoSparseForwardDiff, AutoForwardDiff} ,
1012 sd:: AbstractMaybeSparsityDetection , f, x; fx = nothing )
1113 coloring_result = sd (ad, f, x)
1214 fx = fx === nothing ? similar (f (x)) : fx
1315 if coloring_result isa NoMatrixColoring
14- cache = ForwardDiff. JacobianConfig (f, x)
16+ cache = ForwardDiff. JacobianConfig (f, x, __chunksize (ad, x),
17+ ifelse (ad. tag === nothing , SparseDiffToolsTag (), ad. tag))
1518 jac_prototype = nothing
1619 else
1720 cache = ForwardColorJacCache (f, x, __chunksize (ad); coloring_result. colorvec,
18- dx = fx,
19- sparsity = coloring_result. jacobian_sparsity)
21+ dx = fx, sparsity = coloring_result. jacobian_sparsity, ad. tag)
2022 jac_prototype = coloring_result. jacobian_sparsity
2123 end
2224 return ForwardDiffJacobianCache (coloring_result, cache, jac_prototype, fx, x)
@@ -26,11 +28,12 @@ function sparse_jacobian_cache(ad::Union{AutoSparseForwardDiff, AutoForwardDiff}
2628 sd:: AbstractMaybeSparsityDetection , f!, fx, x)
2729 coloring_result = sd (ad, f!, fx, x)
2830 if coloring_result isa NoMatrixColoring
29- cache = ForwardDiff. JacobianConfig (f!, fx, x)
31+ cache = ForwardDiff. JacobianConfig (f!, fx, x, __chunksize (ad, x),
32+ ifelse (ad. tag === nothing , SparseDiffToolsTag (), ad. tag))
3033 jac_prototype = nothing
3134 else
3235 cache = ForwardColorJacCache (f!, x, __chunksize (ad); coloring_result. colorvec,
33- dx = fx, sparsity = coloring_result. jacobian_sparsity)
36+ dx = fx, sparsity = coloring_result. jacobian_sparsity, ad . tag )
3437 jac_prototype = coloring_result. jacobian_sparsity
3538 end
3639 return ForwardDiffJacobianCache (coloring_result, cache, jac_prototype, fx, x)
0 commit comments