Skip to content

Commit 53cc142

Browse files
chore: add accum patch
1 parent 584f8c3 commit 53cc142

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/SciMLBaseZygoteExt.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,20 @@ end
303303
@_adjoint_keepthunks function Zygote.literal_getfield(x::ODEProblem, ::Val{f}) where f
304304
val = getfield(x, f)
305305
function back(Δ)
306+
# error()
306307
Zygote.accum_param(__context__, val, Δ) === nothing && return
307308
if isimmutable(x)
309+
error()
308310
dx = (; Zygote.nt_nothing(x)..., pair(Val(f), Δ, x)...)
309311
(_project(x, dx), nothing)
310312
else
311313
dx = Zygote.grad_mut(__context__, x)
312314
dx[] = (; dx[]..., pair(Val(f), Zygote.accum(getfield(dx[], f), Δ))...)
313-
return (dx[],nothing)
315+
return (dx,nothing)
314316
end
315317
end
316318
Zygote.unwrap(val), back
317319
end
320+
Zygote.accum(::Tuple{}, ::NamedTuple{}) = ()
318321

319322
end

0 commit comments

Comments
 (0)