Skip to content

Commit

Permalink
Merge pull request #310 from gdalle/optim
Browse files Browse the repository at this point in the history
Update to DifferentiationInterface v0.6
  • Loading branch information
ocots authored Dec 12, 2024
2 parents fa8fc5d + 0f65f29 commit 0b8a8e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CTBasePlots = "Plots"

[compat]
DataStructures = "0.18"
DifferentiationInterface = "0.5"
DifferentiationInterface = "0.6"
DocStringExtensions = "0.9"
ForwardDiff = "0.10"
Interpolations = "0.15"
Expand Down
12 changes: 4 additions & 8 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ $(TYPEDSIGNATURES)
Return the gradient of `f` at `x`.
"""
function ctgradient(f::Function, x::ctNumber; backend = __get_AD_backend())
extras = prepare_derivative(f, backend, x)
return derivative(f, backend, x, extras)
return derivative(f, backend, x)
end

function __ctgradient(f::Function, x::ctNumber)
Expand All @@ -88,8 +87,7 @@ $(TYPEDSIGNATURES)
Return the gradient of `f` at `x`.
"""
function ctgradient(f::Function, x; backend = __get_AD_backend())
extras = prepare_gradient(f, backend, x)
return gradient(f, backend, x, extras)
return gradient(f, backend, x)
end

function __ctgradient(f::Function, x)
Expand All @@ -112,8 +110,7 @@ Return the Jacobian of `f` at `x`.
"""
function ctjacobian(f::Function, x::ctNumber; backend = __get_AD_backend())
f_number_to_number = only f only
extras = prepare_derivative(f_number_to_number, backend, x)
der = derivative(f_number_to_number, backend, x, extras)
der = derivative(f_number_to_number, backend, x)
return [der;;]
end

Expand All @@ -127,8 +124,7 @@ $(TYPEDSIGNATURES)
Return the Jacobian of `f` at `x`.
"""
function ctjacobian(f::Function, x; backend = __get_AD_backend())
extras = prepare_jacobian(f, backend, x)
return jacobian(f, backend, x, extras)
return jacobian(f, backend, x)
end

__ctjacobian(f::Function, x) = ForwardDiff.jacobian(f, x)
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Aqua = "0.8"
DifferentiationInterface = "0.5"
DifferentiationInterface = "0.6"
JSON3 = "1"
JLD2 = "0.5"
Plots = "1"

0 comments on commit 0b8a8e7

Please sign in to comment.