From 0f71a424b984326a82292ba468637ce2e08a7de6 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Fri, 26 Apr 2024 09:28:55 +0200 Subject: [PATCH] Fix doctest (#219) --- DifferentiationInterface/docs/src/backends.md | 7 ++++--- DifferentiationInterface/docs/src/overview.md | 2 +- .../src/translation/differentiate_with.jl | 10 +++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/DifferentiationInterface/docs/src/backends.md b/DifferentiationInterface/docs/src/backends.md index 75560516a..155c72c6b 100644 --- a/DifferentiationInterface/docs/src/backends.md +++ b/DifferentiationInterface/docs/src/backends.md @@ -70,14 +70,15 @@ You can check this compatibility using [`check_twoarg`](@ref). Only some backends are able to compute Hessians. You can use [`check_hessian`](@ref) to check this feature. - -## API Reference +## API reference !!! warning The following documentation has been re-exported from [ADTypes.jl](https://github.com/SciML/ADTypes.jl). Refer to the ADTypes documentation for more information. ```@docs +ADTypes +ADTypes.AbstractADType AutoChainRules AutoDiffractor AutoEnzyme @@ -92,4 +93,4 @@ AutoTapir AutoTracker AutoZygote AutoSparse -``` \ No newline at end of file +``` diff --git a/DifferentiationInterface/docs/src/overview.md b/DifferentiationInterface/docs/src/overview.md index afaabb42d..7590ff244 100644 --- a/DifferentiationInterface/docs/src/overview.md +++ b/DifferentiationInterface/docs/src/overview.md @@ -123,7 +123,7 @@ We make this available for all backends with the following operators: | :--------------------------------- | :---------------------------------- | | [`value_and_pullback_split`](@ref) | [`value_and_pullback!_split`](@ref) | -## Translation +### Translation The wrapper [`DifferentiateWith`](@ref) allows you to take a function and specify that it should be differentiated with the backend of your choice. In other words, when you try to differentiate `dw = DifferentiateWith(f, backend1)` with `backend2`, then `backend1` steps in and `backend2` does nothing. diff --git a/DifferentiationInterface/src/translation/differentiate_with.jl b/DifferentiationInterface/src/translation/differentiate_with.jl index fe551c8f5..75edcb0de 100644 --- a/DifferentiationInterface/src/translation/differentiate_with.jl +++ b/DifferentiationInterface/src/translation/differentiate_with.jl @@ -20,7 +20,7 @@ This works by defining new rules overriding the behavior of the outer backend th # Example -```@repl +```jldoctest using DifferentiationInterface import ForwardDiff, Zygote @@ -32,8 +32,12 @@ end dw = DifferentiateWith(f, AutoForwardDiff()); -gradient(dw, AutoZygote(), [1.0, 2.0]) # works because it calls ForwardDiff instead -gradient(f, AutoZygote(), [1.0, 2.0]) # fails +gradient(dw, AutoZygote(), [2.0]) # calls ForwardDiff instead + +# output + +1-element Vector{Float64}: + 1.0 ``` """ struct DifferentiateWith{F,B<:AbstractADType}