You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using Zygote, SciMLSensitivity, OrdinaryDiffEq
solver =Rodas3() # fails because of view https://github.com/SciML/PreallocationTools.jl/pull/32
p =rand(3)
functiondudt(u, p, t)
u .* p
endfunctionloss(p, sensealg)
prob =ODEProblem(dudt, [3.0, 2.0, 1.0], (0.0, 1.0), p)
sol =solve(prob, solver, dt =0.01, saveat =0.1, sensealg = sensealg,
abstol =1e-5, reltol =1e-5)
sum(abs2, Array(sol))
end
dp1 = Zygote.gradient(p ->loss(p, QuadratureAdjoint(autojacvec =EnzymeVJP())), p)[1]
The commit a669d4f works around SciML/PreallocationTools.jl#32 since Enzyme can only have Enzyme.DuplicatedNoNeed(y, tmp1) both as the same type. This is then required since:
functionget_tmp(dc::DiffCache, u::AbstractArray{T}) where {T <:ForwardDiff.Dual}
nelem =div(sizeof(T), sizeof(eltype(dc.dual_du))) *length(dc.du)
if nelem >length(dc.dual_du)
enlargedualcache!(dc, nelem)
end_restructure(dc.du, reinterpret(T, view(dc.dual_du, 1:nelem)))
end
the return for tmp1 is a ReinterpretedArray instead of an Array. This makes the Rosenbrock case have an unnecessary allocation as it should in theory be able to be kept as a ReinterpretedArray, but this fix requires the extra allocation that SciML/PreallocationTools.jl#32 would have otherwise eliminated.
The text was updated successfully, but these errors were encountered:
MWE:
The commit a669d4f works around SciML/PreallocationTools.jl#32 since Enzyme can only have
Enzyme.DuplicatedNoNeed(y, tmp1)
both as the same type. This is then required since:the return for
tmp1
is aReinterpretedArray
instead of anArray
. This makes the Rosenbrock case have an unnecessary allocation as it should in theory be able to be kept as aReinterpretedArray
, but this fix requires the extra allocation that SciML/PreallocationTools.jl#32 would have otherwise eliminated.The text was updated successfully, but these errors were encountered: