Enzyme.jl icon indicating copy to clipboard operation
Enzyme.jl copied to clipboard

Add split mode

Open vchuravy opened this issue 2 years ago • 1 comments

using Enzyme

julia> f(x) = x^2
f (generic function with 1 method)

julia> ((tape, res), backward) = Enzyme.forward_back(f, Active, Active(2.0))
((Ptr{Nothing} @0x0000000003da4c80, 4.0), Enzyme.Compiler.AdjointThunk{typeof(f), Active{Float64}, Tuple{Active{Float64}}, Nothing}(f, Ptr{Nothing} @0x00007fc41b835060, nothing))

julia> backward(Active(2.0), 1.0, tape)
(4.0,)

~@wsmoses I don't understand why I have to pass Active(1.0) to the backwards pass. I expected it to be Active(2.0)~

vchuravy avatar Mar 04 '22 20:03 vchuravy

You should be passing Active(2.0)

d/dx x^2 = 2x = 4 (evaluated at 2)

wsmoses avatar Mar 04 '22 20:03 wsmoses

Superceeded by https://github.com/EnzymeAD/Enzyme.jl/pull/664

wsmoses avatar Mar 15 '23 15:03 wsmoses