Skip to content

Commit

Permalink
Fix and test ForwardDiff type stability (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle authored Sep 19, 2024
1 parent a1d9c26 commit 71ea7fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,24 @@ function DI.value_derivative_and_second_derivative!(
return y, der, der2
end

## HVP

function DI.prepare_hvp(f::F, backend::AutoForwardDiff, x, tx::Tangents) where {F}
return DI.prepare_hvp(f, SecondOrder(backend, backend), x, tx)
end

function DI.hvp(
f::F, extras::HVPExtras, backend::AutoForwardDiff, x, tx::Tangents
) where {F}
return DI.hvp(f, extras, SecondOrder(backend, backend), x, tx)
end

function DI.hvp!(
f::F, tg::Tangents, extras::HVPExtras, backend::AutoForwardDiff, x, tx::Tangents
) where {F}
return DI.hvp!(f, tg, extras, SecondOrder(backend, backend), x, tx)
end

## Hessian

### Unprepared
Expand Down
11 changes: 4 additions & 7 deletions DifferentiationInterface/test/Back/ForwardDiff/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ end

## Dense backends

test_differentiation(dense_backends, default_scenarios(); logging=LOGGING);
test_differentiation(
dense_backends, default_scenarios(; include_constantified=true); logging=LOGGING
);

test_differentiation(
dense_backends,
default_scenarios(; include_constantified=true);
correctness=false,
type_stability=true,
second_order=false,
logging=LOGGING,
dense_backends; correctness=false, type_stability=true, logging=LOGGING
);

test_differentiation(
Expand Down

0 comments on commit 71ea7fd

Please sign in to comment.