Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit d5e3e49

Browse files
Merge pull request #290 from avik-pal/ap/untag
Don't use custom tags
2 parents df8e05a + 541683d commit d5e3e49

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

.github/workflows/Downstream.yml

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
@info "Not compatible with this release. No problem." exception=err
5151
exit(0) # Exit immediately, as a success
5252
end
53+
env:
54+
RETESTITEMS_NWORKERS: 4
55+
RETESTITEMS_NWORKER_THREADS: 2
5356
- uses: julia-actions/julia-processcoverage@v1
5457
- uses: codecov/codecov-action@v3
5558
with:

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseDiffTools"
22
uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
33
authors = ["Pankaj Mishra <pankajmishra1511@gmail.com>", "Chris Rackauckas <contact@chrisrackauckas.com>"]
4-
version = "2.17.0"
4+
version = "2.17.1"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

ext/SparseDiffToolsPolyesterForwardDiffExt.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import SparseDiffTools: AbstractMaybeSparseJacobianCache, AbstractMaybeSparsityD
66
ForwardColorJacCache, NoMatrixColoring, sparse_jacobian_cache,
77
sparse_jacobian!,
88
sparse_jacobian_static_array, __standard_tag, __chunksize,
9-
polyesterforwarddiff_color_jacobian,
10-
polyesterforwarddiff_color_jacobian!
9+
polyesterforwarddiff_color_jacobian
1110

1211
struct PolyesterForwardDiffJacobianCache{CO, CA, J, FX, X} <:
1312
AbstractMaybeSparseJacobianCache
@@ -27,7 +26,7 @@ function sparse_jacobian_cache(
2726
cache = __chunksize(ad, x)
2827
jac_prototype = nothing
2928
else
30-
tag = __standard_tag(nothing, x)
29+
tag = __standard_tag(nothing, f, x)
3130
# Colored ForwardDiff passes `tag` directly into Dual so we need the `typeof`
3231
cache = ForwardColorJacCache(f, x, __chunksize(ad); coloring_result.colorvec,
3332
dx = fx, sparsity = coloring_result.jacobian_sparsity, tag = typeof(tag))
@@ -47,7 +46,7 @@ function sparse_jacobian_cache(
4746
@warn """Currently PolyesterForwardDiff does not support sparsity detection
4847
natively for inplace functions. Falling back to using
4948
ForwardDiff.jl""" maxlog=1
50-
tag = __standard_tag(nothing, x)
49+
tag = __standard_tag(nothing, f!, x)
5150
# Colored ForwardDiff passes `tag` directly into Dual so we need the `typeof`
5251
cache = ForwardColorJacCache(f!, x, __chunksize(ad); coloring_result.colorvec,
5352
dx = fx, sparsity = coloring_result.jacobian_sparsity, tag = typeof(tag))

src/highlevel/forward_mode.jl

+5-12
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,15 @@ end
88

99
__getfield(c::ForwardDiffJacobianCache, ::Val{:jac_prototype}) = c.jac_prototype
1010

11-
struct SparseDiffToolsTag end
12-
13-
function ForwardDiff.checktag(::Type{<:ForwardDiff.Tag{<:SparseDiffToolsTag, <:T}}, f::F,
14-
x::AbstractArray{T}) where {T, F}
15-
return true
16-
end
17-
18-
__standard_tag(::Nothing, x) = ForwardDiff.Tag(SparseDiffToolsTag(), eltype(x))
19-
__standard_tag(tag::ForwardDiff.Tag, _) = tag
20-
__standard_tag(tag, x) = ForwardDiff.Tag(tag, eltype(x))
11+
__standard_tag(::Nothing, f::F, x) where {F} = ForwardDiff.Tag(f, eltype(x))
12+
__standard_tag(tag::ForwardDiff.Tag, ::F, _) where {F} = tag
13+
__standard_tag(tag, f::F, x) where {F} = ForwardDiff.Tag(f, eltype(x))
2114

2215
function sparse_jacobian_cache(ad::Union{AutoSparseForwardDiff, AutoForwardDiff},
2316
sd::AbstractMaybeSparsityDetection, f::F, x; fx = nothing) where {F}
2417
coloring_result = sd(ad, f, x)
2518
fx = fx === nothing ? similar(f(x)) : fx
26-
tag = __standard_tag(ad.tag, x)
19+
tag = __standard_tag(ad.tag, f, x)
2720
if coloring_result isa NoMatrixColoring
2821
cache = ForwardDiff.JacobianConfig(f, x, __chunksize(ad, x), tag)
2922
jac_prototype = nothing
@@ -39,7 +32,7 @@ end
3932
function sparse_jacobian_cache(ad::Union{AutoSparseForwardDiff, AutoForwardDiff},
4033
sd::AbstractMaybeSparsityDetection, f!::F, fx, x) where {F}
4134
coloring_result = sd(ad, f!, fx, x)
42-
tag = __standard_tag(ad.tag, x)
35+
tag = __standard_tag(ad.tag, f!, x)
4336
if coloring_result isa NoMatrixColoring
4437
cache = ForwardDiff.JacobianConfig(f!, fx, x, __chunksize(ad, x), tag)
4538
jac_prototype = nothing

0 commit comments

Comments
 (0)