Open vchuravy opened 1 month ago
depending on the array type, I think doing copyto! would let you do
function JVP!(y, f::F, u, v) where F
Enzyme.autodiff(Forward,
(temp, v) -> (temp .= f(v); nothing),
Const,
DuplicatedNoNeed(any undef thing,, y),
DuplicatedNoNeed(u, v))
return nothing
end
I think the same applies for zero(w), the copy(w) however is harder
For future reference:
# https://www.aanda.org/articles/aa/full_html/2016/02/aa27339-15/aa27339-15.html
function JVP_Finite_Diff(F,u,v)
λ = 10e-6
δ = λ * (λ + norm(u, Inf)/norm(v,Inf))
(F(u + δ .* v) - F(u)) ./ δ
end
"any undef thing" you mean a "Vector{Float64}(undef, 0)" would work?
I think so, in c we get away with passing a literal nullptr in these kinds of cases
Do you plan to add jvp
and jtvp
in the API on Enzyme.jl ?
Just to know if I should wait before adding an example in the documentation ok Krylov.jl.
cc: @michel2323 & @amontoison
With @lcandiot I was wondering how to write a proper JVP J'VP with Enzyme and finally converged.
This might turn into a nice example one of these days. @wsmoses any ideas on how to avoid the calls to
zero(y)
andzero(w)
/copy(w)
?