Skip to content

Commit

Permalink
Remove duplicate code (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill authored Jan 7, 2024
1 parent 211b675 commit 19e7d88
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/AbstractDifferentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,6 @@ function value_and_hessian(ab::AbstractBackend, f, x)
return value, hess
end

function value_and_hessian(ab::HigherOrderBackend, f, x)
if x isa Tuple
# only support computation of Hessian for functions with single input argument
x = only(x)
end

value = f(x)
hess = jacobian(second_lowest(ab), (_x,) -> begin
g = gradient(lowest(ab), f, _x)
return g[1] # gradient returns a tuple
end, x)

return value, hess
end

"""
AD.value_gradient_and_hessian(ab::AD.AbstractBackend, f, x)
Expand All @@ -200,23 +185,6 @@ function value_gradient_and_hessian(ab::AbstractBackend, f, x)
return value, (grads,), hess
end

function value_gradient_and_hessian(ab::HigherOrderBackend, f, x)
if x isa Tuple
# only support computation of Hessian for functions with single input argument
x = only(x)
end

value = f(x)
grads, hess = value_and_jacobian(
second_lowest(ab), _x -> begin
g = gradient(lowest(ab), f, _x)
return g[1] # gradient returns a tuple
end, x
)

return value, (grads,), hess
end

"""
AD.pushforward_function(ab::AD.AbstractBackend, f, xs...)
Expand Down

0 comments on commit 19e7d88

Please sign in to comment.