Skip to content

Commit

Permalink
Fix doctest (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle authored Apr 26, 2024
1 parent 66f1fdc commit 0f71a42
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions DifferentiationInterface/docs/src/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -92,4 +93,4 @@ AutoTapir
AutoTracker
AutoZygote
AutoSparse
```
```
2 changes: 1 addition & 1 deletion DifferentiationInterface/docs/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions DifferentiationInterface/src/translation/differentiate_with.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down

0 comments on commit 0f71a42

Please sign in to comment.