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

Commit 655cdd1

Browse files
committed
add kwarg argument to accept forwarddiff tag in JacVec, HesVec, HesVecGrad
1 parent c831947 commit 655cdd1

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/differentiation/jaches_products.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ function (L::FwdModeAutoDiffVecProd)(dv, v, p, t)
228228
L.vecprod!(dv, L.f, L.u, v, L.cache...)
229229
end
230230

231-
function JacVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoForwardDiff(),
232-
kwargs...)
231+
function JacVec(f, u::AbstractArray, p = nothing, t = nothing;
232+
autodiff = AutoForwardDiff(), tag = DeivVecTag(), kwargs...)
233233
cache, vecprod, vecprod! = if autodiff isa AutoFiniteDiff
234234
cache1 = similar(u)
235235
cache2 = similar(u)
236236

237237
(cache1, cache2), num_jacvec, num_jacvec!
238238
elseif autodiff isa AutoForwardDiff
239239
cache1 = Dual{
240-
typeof(ForwardDiff.Tag(DeivVecTag(), eltype(u))), eltype(u), 1
240+
typeof(ForwardDiff.Tag(tag, eltype(u))), eltype(u), 1
241241
}.(u, ForwardDiff.Partials.(tuple.(u)))
242242

243243
cache2 = copy(cache1)
@@ -305,16 +305,15 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing; autodiff = AutoFo
305305
end
306306

307307
function HesVecGrad(f, u::AbstractArray, p = nothing, t = nothing;
308-
autodiff = AutoForwardDiff(),
309-
kwargs...)
308+
autodiff = AutoForwardDiff(), tag = DeivVecTag(), kwargs...)
310309
cache, vecprod, vecprod! = if autodiff isa AutoFiniteDiff
311310
cache1 = similar(u)
312311
cache2 = similar(u)
313312

314313
(cache1, cache2), num_hesvecgrad, num_hesvecgrad!
315314
elseif autodiff isa AutoForwardDiff
316315
cache1 = Dual{
317-
typeof(ForwardDiff.Tag(DeivVecTag(), eltype(u))), eltype(u), 1
316+
typeof(ForwardDiff.Tag(tag, eltype(u))), eltype(u), 1
318317
}.(u, ForwardDiff.Partials.(tuple.(u)))
319318
cache2 = copy(cache1)
320319

0 commit comments

Comments
 (0)