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

Commit 8106c43

Browse files
Merge pull request #105 from JuliaDiff/nesting
Fix Dual tag nesting
2 parents 639a567 + 8878eaf commit 8106c43

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/differentiation/compute_jacobian_ad.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ function ForwardColorJacCache(f,x,_chunksize = nothing;
3232
end
3333

3434
p = adapt.(parameterless_type(x),generate_chunked_partials(x,colorvec,chunksize))
35-
_t = Dual{ForwardDiff.Tag(f,eltype(vec(x)))}.(vec(x),first(p))
35+
_t = Dual{typeof(ForwardDiff.Tag(f,eltype(vec(x))))}.(vec(x),first(p))
3636
t = ArrayInterface.restructure(x,_t)
3737
if dx isa Nothing
3838
fx = similar(t)
3939
_dx = similar(x)
4040
else
4141
tup = ArrayInterface.allowed_getindex(ArrayInterface.allowed_getindex(p,1),1) .* false
4242
_pi = adapt(parameterless_type(dx),[tup for i in 1:length(dx)])
43-
fx = reshape(Dual{ForwardDiff.Tag(f,eltype(vec(x)))}.(vec(dx),_pi),size(dx)...)
43+
fx = reshape(Dual{typeof(ForwardDiff.Tag(f,eltype(vec(x))))}.(vec(dx),_pi),size(dx)...)
4444
_dx = dx
4545
end
4646

@@ -97,7 +97,7 @@ function forwarddiff_color_jacobian(f,x::AbstractArray{<:Number},jac_cache::Forw
9797

9898
for i in eachindex(p)
9999
partial_i = p[i]
100-
t = reshape(Dual{ForwardDiff.Tag(f,eltype(vecx))}.(vecx, partial_i),size(t))
100+
t = reshape(Dual{typeof(ForwardDiff.Tag(f,eltype(vecx)))}.(vecx, partial_i),size(t))
101101
fx = f(t)
102102
if !(sparsity isa Nothing)
103103
for j in 1:chunksize
@@ -171,7 +171,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
171171

172172
for i in eachindex(p)
173173
partial_i = p[i]
174-
vect .= Dual{ForwardDiff.Tag(f,eltype(vecx))}.(vecx, partial_i)
174+
vect .= Dual{typeof(ForwardDiff.Tag(f,eltype(vecx)))}.(vecx, partial_i)
175175
f(fx,t)
176176
if !(sparsity isa Nothing)
177177
for j in 1:chunksize

0 commit comments

Comments
 (0)