Enzyme.jl
Enzyme.jl copied to clipboard
Define custom adjoint for `jl_f_getfield`
trafficstars
Loss and sciml_train call (other stuff omitted for now):
function loss(p)
u0_new = copyto!(similar(u0, eltype(p)), u0)
prob = CryoGridProblem(model, u0_new, tspan, p, savevars=(:T,))
sol = solve(prob, Euler(), dt=10*60.0)
return log(abs(sum(sum(sol.u))))
end
@time res = DiffEqFlux.sciml_train(loss, p, maxiters=1)
Trace (reeeealllly long... wouldn't fit here): https://gist.github.com/bgroenks96/501f30e34724ad7e243b4aee14db726a
Julia version info:
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Enzyme:
(@v1.6) pkg> status Enzyme
Status `~/.julia/environments/v1.6/Project.toml`
[7da242da] Enzyme v0.8.1
Edit: Probably not relevant to this issue, but there was an error in the loss function as written. It should be scalar and sum(sol.u) is a vector.
declare nonnull {} addrspace(10)* @jl_f_getfield({} addrspace(10)*, {} addrspace(10)**, i32)
We should add the adjoint for this
getfield?
Fixed by https://github.com/EnzymeAD/Enzyme.jl/pull/806