From a78fbde86bd36f2f84414839712229d1f100889d Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Mon, 27 May 2024 00:48:02 +0530 Subject: [PATCH 1/3] chore: check if method literal_getproperty exists --- src/adjoint_common.jl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/adjoint_common.jl b/src/adjoint_common.jl index 6659174a4..1cf0582f0 100644 --- a/src/adjoint_common.jl +++ b/src/adjoint_common.jl @@ -652,12 +652,15 @@ function out_and_ts(_ts, duplicate_iterator_times, sol) return out, ts end -Zygote.@adjoint function Zygote.literal_getproperty(sol::AbstractTimeseriesSolution, - ::Val{:u}) - function solu_adjoint(Δ) - zerou = zero(sol.prob.u0) - _Δ = @. ifelse(Δ === nothing, (zerou,), Δ) - (SciMLBase.build_solution(sol.prob, sol.alg, sol.t, _Δ),) +if !hasmethod(Zygote.adjoint, Tuple{Zygote.AContext, typeof(Zygote.literal_getproperty), SciMLBase.AbstractTimeseriesSolution, Val{:u}}) + Zygote.@adjoint function Zygote.literal_getproperty(sol::AbstractTimeseriesSolution, + ::Val{:u}) + function solu_adjoint(Δ) + zerou = zero(sol.prob.u0) + _Δ = @. ifelse(Δ === nothing, (zerou,), Δ) + (SciMLBase.build_solution(sol.prob, sol.alg, sol.t, _Δ),) + end + @show "here" + sol.u, solu_adjoint end - sol.u, solu_adjoint end From 0a852349665d28335e8abb8b993e92d72f513d26 Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Mon, 27 May 2024 00:49:11 +0530 Subject: [PATCH 2/3] chore: rm debug --- src/adjoint_common.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/adjoint_common.jl b/src/adjoint_common.jl index 1cf0582f0..ed7d92462 100644 --- a/src/adjoint_common.jl +++ b/src/adjoint_common.jl @@ -660,7 +660,6 @@ if !hasmethod(Zygote.adjoint, Tuple{Zygote.AContext, typeof(Zygote.literal_getpr _Δ = @. ifelse(Δ === nothing, (zerou,), Δ) (SciMLBase.build_solution(sol.prob, sol.alg, sol.t, _Δ),) end - @show "here" sol.u, solu_adjoint end end From cca0c2ff0567dadadcfb86b78fbd3e10d06bfd6a Mon Sep 17 00:00:00 2001 From: DhairyaLGandhi Date: Mon, 27 May 2024 00:50:22 +0530 Subject: [PATCH 3/3] chore: format --- src/adjoint_common.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/adjoint_common.jl b/src/adjoint_common.jl index ed7d92462..e511fae81 100644 --- a/src/adjoint_common.jl +++ b/src/adjoint_common.jl @@ -652,7 +652,9 @@ function out_and_ts(_ts, duplicate_iterator_times, sol) return out, ts end -if !hasmethod(Zygote.adjoint, Tuple{Zygote.AContext, typeof(Zygote.literal_getproperty), SciMLBase.AbstractTimeseriesSolution, Val{:u}}) +if !hasmethod(Zygote.adjoint, + Tuple{Zygote.AContext, typeof(Zygote.literal_getproperty), + SciMLBase.AbstractTimeseriesSolution, Val{:u}}) Zygote.@adjoint function Zygote.literal_getproperty(sol::AbstractTimeseriesSolution, ::Val{:u}) function solu_adjoint(Δ)