Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to DifferentiationInterface v0.6 #310

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 4 additions & 8 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -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)
@@ -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)
@@ -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

@@ -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)
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -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"