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

Commit d536c70

Browse files
committed
Fix dual cache reset logic
1 parent ed73696 commit d536c70

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ext/SparseDiffToolsZygote.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function SparseDiffTools.autoback_hesvec!(dy, f, x, v,
5252
g = let f = f
5353
(dx, x) -> dx .= first(Zygote.gradient(f, x))
5454
end
55-
cache1 .= Dual{typeof(ForwardDiff.Tag(DeivVecTag(), eltype(x))), eltype(x), 1
56-
}.(x, ForwardDiff.Partials.(Tuple.(reshape(v, size(x)))))
55+
# Reset each dual number in cache1 to primal = dual = 1.
56+
cache1 .= eltype(cache1).(x, ForwardDiff.Partials.(Tuple.(reshape(v, size(x)))))
5757
g(cache2, cache1)
5858
dy .= partials.(cache2, 1)
5959
end

0 commit comments

Comments
 (0)