From 19e7d8813b919a39b32bd7f61197c5178f68d244 Mon Sep 17 00:00:00 2001 From: Adrian Hill Date: Sun, 7 Jan 2024 22:18:16 +0100 Subject: [PATCH] Remove duplicate code (#126) --- src/AbstractDifferentiation.jl | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/src/AbstractDifferentiation.jl b/src/AbstractDifferentiation.jl index a868b37..36113e8 100644 --- a/src/AbstractDifferentiation.jl +++ b/src/AbstractDifferentiation.jl @@ -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) @@ -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...)