Skip to content

Commit

Permalink
feat: update to new DI.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Sep 25, 2024
1 parent c48ef4f commit 93d3b5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleNonlinearSolve"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
authors = ["SciML"]
version = "1.12.2"
version = "1.12.3"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -43,7 +43,7 @@ ChainRulesCore = "1.23"
ConcreteStructs = "0.2.3"
DiffEqBase = "6.149"
DiffResults = "1.1"
DifferentiationInterface = "0.5"
DifferentiationInterface = "0.6"
ExplicitImports = "1.5.0"
FastClosures = "0.3.2"
FiniteDiff = "2.23.1"
Expand Down
8 changes: 4 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ end

function value_and_jacobian(
ad, prob::AbstractNonlinearProblem, f::F, y, x, cache; J = nothing) where {F}
x isa Number && return DI.value_and_derivative(f, ad, x, cache)
x isa Number && return DI.value_and_derivative(f, cache, ad, x)

if isinplace(prob)
if cache isa HasAnalyticJacobian
prob.f.jac(J, x, prob.p)
f(y, x)
return y, J
end
return DI.value_and_jacobian!(f, y, J, ad, x, cache)
return DI.value_and_jacobian!(f, y, J, cache, ad, x)
else
cache isa HasAnalyticJacobian && return f(x), prob.f.jac(x, prob.p)
J === nothing && return DI.value_and_jacobian(f, ad, x, cache)
y, J = DI.value_and_jacobian!(f, J, ad, x, cache)
J === nothing && return DI.value_and_jacobian(f, cache, ad, x)
y, J = DI.value_and_jacobian!(f, J, cache, ad, x)
return y, J
end
end
Expand Down

0 comments on commit 93d3b5b

Please sign in to comment.