Skip to content

Commit

Permalink
Only duplicate and make_zero! if enzyme func is non-constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jul 14, 2024
1 parent b0b9421 commit 98487f2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/derivative_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,16 @@ function _vecjacobian!(dλ, y, λ, p, t, S::TS, isautojacvec::EnzymeVJP, dgrad,

isautojacvec = get_jacvec(sensealg)

Enzyme.make_zero!(_tmp6)
if Core.Compiler.isconstType(_tmp6)
Enzyme.make_zero!(_tmp6)
_f = Enzyme.Duplicated(S.diffcache.pf, _tmp6)
else
_f = S.diffcache.pf
end

if inplace_sensitivity(S)
if W === nothing
Enzyme.autodiff(Enzyme.Reverse, Enzyme.Duplicated(S.diffcache.pf, _tmp6),
Enzyme.autodiff(Enzyme.Reverse, _f,
Enzyme.Const, Enzyme.Duplicated(tmp3, tmp4),
Enzyme.Duplicated(ytmp, tmp1),
dup,
Expand Down

0 comments on commit 98487f2

Please sign in to comment.