From d110e83a09181f929c3c45f4ee151a0eeecaeb9d Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Sat, 21 Dec 2024 21:15:25 +0100 Subject: [PATCH] Update the documentation --- docs/src/backend.md | 10 +++++----- docs/src/predefined.md | 14 ++++++++++++++ src/predefined_backend.jl | 8 ++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/docs/src/backend.md b/docs/src/backend.md index 7e073675..c2894dcb 100644 --- a/docs/src/backend.md +++ b/docs/src/backend.md @@ -10,11 +10,11 @@ The functions used internally to define the NLPModel API and the possible backen | Functions | FowardDiff backends | ReverseDiff backends | Zygote backends | Enzyme backend | Sparse backend | | --------- | ------------------- | -------------------- | --------------- | -------------- | -------------- | | `gradient` and `gradient!` | `ForwardDiffADGradient`/`GenericForwardDiffADGradient` | `ReverseDiffADGradient`/`GenericReverseDiffADGradient` | `ZygoteADGradient` | `EnzymeADGradient` | -- | -| `jacobian` | `ForwardDiffADJacobian` | `ReverseDiffADJacobian` | `ZygoteADJacobian` | -- | `SparseADJacobian` | -| `hessian` | `ForwardDiffADHessian` | `ReverseDiffADHessian` | `ZygoteADHessian` | -- | `SparseADHessian`/`SparseReverseADHessian` | -| `Jprod` | `ForwardDiffADJprod`/`GenericForwardDiffADJprod` | `ReverseDiffADJprod`/`GenericReverseDiffADJprod` | `ZygoteADJprod` | -- | -- | -| `Jtprod` | `ForwardDiffADJtprod`/`GenericForwardDiffADJtprod` | `ReverseDiffADJtprod`/`GenericReverseDiffADJtprod` | `ZygoteADJtprod` | -- | -- | -| `Hvprod` | `ForwardDiffADHvprod`/`GenericForwardDiffADHvprod` | `ReverseDiffADHvprod`/`GenericReverseDiffADHvprod` | -- | -- | -- | +| `jacobian` | `ForwardDiffADJacobian` | `ReverseDiffADJacobian` | `ZygoteADJacobian` | `EnzymeADJacobian` | `SparseADJacobian` | +| `hessian` | `ForwardDiffADHessian` | `ReverseDiffADHessian` | `ZygoteADHessian` | `EnzymeADHessian` | `SparseADHessian`/`SparseReverseADHessian` | +| `Jprod` | `ForwardDiffADJprod`/`GenericForwardDiffADJprod` | `ReverseDiffADJprod`/`GenericReverseDiffADJprod` | `ZygoteADJprod` | `EnzymeADJprod` | -- | +| `Jtprod` | `ForwardDiffADJtprod`/`GenericForwardDiffADJtprod` | `ReverseDiffADJtprod`/`GenericReverseDiffADJtprod` | `ZygoteADJtprod` | `EnzymeADJtprod` | -- | +| `Hvprod` | `ForwardDiffADHvprod`/`GenericForwardDiffADHvprod` | `ReverseDiffADHvprod`/`GenericReverseDiffADHvprod` | -- | `EnzymeADHvprod` | -- | | `directional_second_derivative` | `ForwardDiffADGHjvprod` | -- | -- | -- | -- | The functions `hess_structure!`, `hess_coord!`, `jac_structure!` and `jac_coord!` defined in `ad.jl` are generic to all the backends for now. diff --git a/docs/src/predefined.md b/docs/src/predefined.md index 15793aae..6068d518 100644 --- a/docs/src/predefined.md +++ b/docs/src/predefined.md @@ -46,3 +46,17 @@ It is possible to use these pre-defined backends using the keyword argument `bac nlp = ADNLPModel!(f, x0, lvar, uvar, c!, lcon, ucon, backend = :optimized) get_adbackend(nlp) ``` + +The backend `:enzyme` focuses on backend based on [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl). + +```@example ex1 +nlp = ADNLPModel!(f, x0, lvar, uvar, c!, lcon, ucon, backend = :enzyme) +get_adbackend(nlp) +``` + +The backend `:zygote` focuses on backend based on [Zygote.jl](https://github.com/FluxML/Zygote.jl). + +```@example ex1 +nlp = ADNLPModel!(f, x0, lvar, uvar, c!, lcon, ucon, backend = :zygote) +get_adbackend(nlp) +``` diff --git a/src/predefined_backend.jl b/src/predefined_backend.jl index 1595d054..c612504b 100644 --- a/src/predefined_backend.jl +++ b/src/predefined_backend.jl @@ -48,14 +48,14 @@ enzyme_backend = Dict( :jprod_backend => EnzymeReverseADJprod, :jtprod_backend => EnzymeReverseADJtprod, :hprod_backend => EnzymeReverseADHvprod, - :jacobian_backend => EnzymeReverseADJacobian, - :hessian_backend => EnzymeReverseADHessian, + :jacobian_backend => SparseEnzymeADJacobian, + :hessian_backend => SparseEnzymeADHessian, :ghjvprod_backend => ForwardDiffADGHjvprod, :jprod_residual_backend => EnzymeReverseADJprod, :jtprod_residual_backend => EnzymeReverseADJtprod, :hprod_residual_backend => EnzymeReverseADHvprod, - :jacobian_residual_backend => EnzymeReverseADJacobian, - :hessian_residual_backend => EnzymeReverseADHessian, + :jacobian_residual_backend => SparseEnzymeADJacobian, + :hessian_residual_backend => SparseEnzymeADHessian, ) zygote_backend = Dict(