Skip to content

Commit

Permalink
Reexport backends from ADTypes (#217)
Browse files Browse the repository at this point in the history
* Reexport ADTypes

* Remove ADTypes namespacing when possible

* Include reexported ADTypes in API reference

* Minor fixes

* Move backend API reference to "Backends" page
  • Loading branch information
adrhill authored Apr 26, 2024
1 parent 32b70a2 commit fac64b7
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
8 changes: 5 additions & 3 deletions DifferentiationInterface/docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DifferentiationInterface as DI
using Documenter
using DocumenterMermaid

using ADTypes
using ADTypes: ADTypes
using Diffractor: Diffractor
using Enzyme: Enzyme
using FastDifferentiation: FastDifferentiation
Expand Down Expand Up @@ -37,16 +37,18 @@ extensions = [
]

makedocs(;
modules=[DifferentiationInterface, extensions...],
modules=[DifferentiationInterface, ADTypes, extensions...],
authors="Guillaume Dalle, Adrian Hill",
sitename="DifferentiationInterface.jl",
format=Documenter.HTML(),
pages=[
"Home" => "index.md", #
"Home" => "index.md",
"Start here" => ["tutorial.md", "overview.md", "backends.md"],
"API reference" => "api.md",
"Advanced" => ["design.md", "extensions.md", "overloads.md"],
],
checkdocs=:exports,
warnonly=[:missing_docs, :cross_references],
)

deploydocs(;
Expand Down
25 changes: 24 additions & 1 deletion DifferentiationInterface/docs/src/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CollapsedDocStrings = true
```

```@setup backends
using ADTypes
using DifferentiationInterface
using DifferentiationInterface: backend_string
import Markdown
Expand Down Expand Up @@ -70,3 +69,27 @@ 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

!!! 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
AutoChainRules
AutoDiffractor
AutoEnzyme
AutoFastDifferentiation
AutoFiniteDiff
AutoFiniteDifferences
AutoForwardDiff
AutoPolyesterForwardDiff
AutoReverseDiff
AutoSymbolics
AutoTapir
AutoTracker
AutoZygote
AutoSparse
```
2 changes: 1 addition & 1 deletion DifferentiationInterface/docs/src/overloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Each cell can have three values:
Check marks (✅) are clickable and link to the source code.

```@setup overloads
using ADTypes
using ADTypes: AbstractADType
using DifferentiationInterface
using DifferentiationInterface: backend_string, mutation_support, MutationSupported
using Markdown: Markdown
Expand Down
17 changes: 17 additions & 0 deletions DifferentiationInterface/src/DifferentiationInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,21 @@ export prepare_second_derivative, prepare_hvp, prepare_hessian

export check_available, check_twoarg, check_hessian

# Re-export backends from ADTypes
export AutoChainRules
export AutoDiffractor
export AutoEnzyme
export AutoFastDifferentiation
export AutoFiniteDiff
export AutoFiniteDifferences
export AutoForwardDiff
export AutoPolyesterForwardDiff
export AutoReverseDiff
export AutoSymbolics
export AutoTapir
export AutoTracker
export AutoZygote

export AutoSparse

end # module
1 change: 1 addition & 0 deletions DifferentiationInterface/src/utils/printing.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
backend_package_name(b::AbstractADType) = strip(string(b), ['(', ')'])
backend_package_name(b::AutoSparse) = backend_package_name(dense_ad(b))

backend_package_name(::AutoChainRules) = "ChainRules"
backend_package_name(::AutoDiffractor) = "Diffractor"
Expand Down
4 changes: 2 additions & 2 deletions DifferentiationInterfaceTest/docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We present a typical workflow with DifferentiationInterfaceTest.jl, building on

```@repl tuto
using DifferentiationInterface, DifferentiationInterfaceTest
import ADTypes, ForwardDiff, Enzyme
import ForwardDiff, Enzyme
import DataFrames, Markdown, PrettyTables, Printf
```

Expand All @@ -17,7 +17,7 @@ import DataFrames, Markdown, PrettyTables, Printf
The AD backends we want to compare are [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) and [Enzyme.jl](https://github.com/EnzymeAD/Enzyme.jl).

```@repl tuto
backends = [ADTypes.AutoForwardDiff(), ADTypes.AutoEnzyme(; mode=Enzyme.Reverse)]
backends = [AutoForwardDiff(), AutoEnzyme(; mode=Enzyme.Reverse)]
```

To do that, we are going to take gradients of a simple function:
Expand Down

0 comments on commit fac64b7

Please sign in to comment.