Skip to content

Commit

Permalink
Fix ordering of the promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed May 16, 2024
1 parent d3a3cf7 commit 436d627
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Chris Rackauckas <[email protected]>"]
version = "6.150.0"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down Expand Up @@ -60,6 +61,7 @@ DiffEqBaseTrackerExt = "Tracker"
DiffEqBaseUnitfulExt = "Unitful"

[compat]
Adapt = "4"
ArrayInterface = "7.8"
ChainRulesCore = "1"
ConcreteStructs = "0.2.3"
Expand Down
4 changes: 3 additions & 1 deletion ext/DiffEqBaseTrackerExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ if isdefined(Base, :get_extension)
using DiffEqBase
import DiffEqBase: value
import Tracker
import Adapt
else
using ..DiffEqBase
import ..DiffEqBase: value
import ..Tracker
import ..Adapt
end

DiffEqBase.value(x::Type{Tracker.TrackedReal{T}}) where {T} = T
Expand Down Expand Up @@ -99,7 +101,7 @@ Tracker.@grad function DiffEqBase.solve_up(prob,
kwargs...)
out = DiffEqBase._solve_adjoint(prob, sensealg, Tracker.data(u0), Tracker.data(p),
SciMLBase.TrackerOriginator(), args...; kwargs...)
Array(out[1]), out[2]
convert(AbstractArray, out[1]), out[2]

Check warning on line 104 in ext/DiffEqBaseTrackerExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/DiffEqBaseTrackerExt.jl#L104

Added line #L104 was not covered by tests
end

end
12 changes: 6 additions & 6 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1130,23 +1130,23 @@ function get_concrete_problem(prob::AbstractJumpProblem, isadapt; kwargs...)
end

function get_concrete_problem(prob::SteadyStateProblem, isadapt; kwargs...)
u0 = get_concrete_u0(prob, isadapt, Inf, kwargs)
u0 = promote_u0(u0, prob.p, nothing)
p = get_concrete_p(prob, kwargs)
u0 = get_concrete_u0(prob, isadapt, Inf, kwargs)
u0 = promote_u0(u0, p, nothing)
remake(prob; u0 = u0, p = p)
end

function get_concrete_problem(prob::NonlinearProblem, isadapt; kwargs...)
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
u0 = promote_u0(u0, prob.p, nothing)
p = get_concrete_p(prob, kwargs)
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
u0 = promote_u0(u0, p, nothing)
remake(prob; u0 = u0, p = p)
end

function get_concrete_problem(prob::NonlinearLeastSquaresProblem, isadapt; kwargs...)
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
u0 = promote_u0(u0, prob.p, nothing)
p = get_concrete_p(prob, kwargs)
u0 = get_concrete_u0(prob, isadapt, nothing, kwargs)
u0 = promote_u0(u0, p, nothing)
remake(prob; u0 = u0, p = p)
end

Expand Down

0 comments on commit 436d627

Please sign in to comment.