Skip to content

Commit 78d3d99

Browse files
authored
Update docs for Tapir (#125)
1 parent 5460c32 commit 78d3d99

11 files changed

Lines changed: 99 additions & 39 deletions

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
8484
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
8585
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
8686
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
87+
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
8788
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8889
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
8990
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
9091

9192
[targets]
92-
test = ["ADTypes", "Aqua", "Chairmarks", "DataFrames", "Diffractor", "Documenter", "Enzyme", "FastDifferentiation", "FiniteDiff", "FiniteDifferences", "ForwardDiff", "JET", "JuliaFormatter", "Pkg", "PolyesterForwardDiff", "ReverseDiff", "SparseArrays", "SparseDiffTools", "Symbolics", "Test", "Tracker", "Zygote"]
93+
test = ["ADTypes", "Aqua", "Chairmarks", "DataFrames", "Diffractor", "Documenter", "Enzyme", "FastDifferentiation", "FiniteDiff", "FiniteDifferences", "ForwardDiff", "JET", "JuliaFormatter", "Pkg", "PolyesterForwardDiff", "ReverseDiff", "SparseArrays", "SparseDiffTools", "Symbolics", "Tapir", "Test", "Tracker", "Zygote"]

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Coverage](https://codecov.io/gh/gdalle/DifferentiationInterface.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/gdalle/DifferentiationInterface.jl)
66
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
77

8-
An interface to various automatic differentiation backends in Julia.
8+
An interface to various automatic differentiation (AD) backends in Julia.
99

1010
## Goal
1111

@@ -39,20 +39,21 @@ We support most of the backends defined by [ADTypes.jl](https://github.com/SciML
3939
| [Tracker.jl](https://github.com/FluxML/Tracker.jl) | `AutoTracker()` |
4040
| [Zygote.jl](https://github.com/FluxML/Zygote.jl) | `AutoZygote()` |
4141

42-
We also provide one additional backend:
42+
We also support additional (experimental) backends:
4343

4444
| backend | object |
4545
| :------------------------------------------------------------------------------- | :-------------------------- |
4646
| [FastDifferentiation.jl](https://github.com/brianguenter/FastDifferentiation.jl) | `AutoFastDifferentiation()` |
47+
| [Tapir.jl](https://github.com/withbayes/Tapir.jl) | `AutoTapir()` |
4748

4849
## Example
4950

5051
```jldoctest readme
51-
julia> import ADTypes, ForwardDiff
52+
julia> import ForwardDiff
5253
5354
julia> using DifferentiationInterface
5455
55-
julia> backend = ADTypes.AutoForwardDiff();
56+
julia> backend = AutoForwardDiff();
5657
5758
julia> f(x) = sum(abs2, x);
5859

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
1919
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
2020
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2121
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
22+
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
23+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
24+
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
2225
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2326
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
2427
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

docs/make.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ using FiniteDifferences: FiniteDifferences
1818
using ForwardDiff: ForwardDiff
1919
using PolyesterForwardDiff: PolyesterForwardDiff
2020
using ReverseDiff: ReverseDiff
21+
using Symbolics: Symbolics
22+
using SparseDiffTools: SparseDiffTools
23+
using Tapir: Tapir
2124
using Tracker: Tracker
2225
using Zygote: Zygote
2326

@@ -49,6 +52,8 @@ makedocs(;
4952
get_extension(DI, :DifferentiationInterfaceForwardDiffExt),
5053
get_extension(DI, :DifferentiationInterfacePolyesterForwardDiffExt),
5154
get_extension(DI, :DifferentiationInterfaceReverseDiffExt),
55+
get_extension(DI, :DifferentiationInterfaceSparseDiffToolsExt),
56+
get_extension(DI, :DifferentiationInterfaceTapirExt),
5257
get_extension(DI, :DifferentiationInterfaceTrackerExt),
5358
get_extension(DI, :DifferentiationInterfaceZygoteExt),
5459
],

docs/src/backends.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function all_backends()
2020
AutoForwardDiff(),
2121
AutoPolyesterForwardDiff(; chunksize=2),
2222
AutoReverseDiff(),
23+
AutoTapir(),
2324
AutoTracker(),
2425
AutoZygote(),
2526
]
@@ -36,32 +37,43 @@ end
3637

3738
## Types
3839

39-
Most backend choices are defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
40+
We support (and re-export) most backend choices from [ADTypes.jl](https://github.com/SciML/ADTypes.jl), and we provide a few more of our own.
4041

4142
!!! warning
42-
Only the backends listed here are supported by DifferentiationInterface.jl, even though ADTypes.jl defines more.
43+
Only the backends listed below are supported by DifferentiationInterface.jl, even though ADTypes.jl defines more.
44+
45+
### Dense
4346

4447
```@docs
4548
AutoChainRules
4649
AutoDiffractor
4750
AutoEnzyme
51+
AutoFastDifferentiation
4852
AutoForwardDiff
4953
AutoForwardDiff()
5054
AutoFiniteDiff
5155
AutoFiniteDifferences
5256
AutoPolyesterForwardDiff
5357
AutoPolyesterForwardDiff()
5458
AutoReverseDiff
59+
AutoTapir
5560
AutoTracker
5661
AutoZygote
5762
```
5863

59-
We also provide a few of our own:
64+
### Sparse
65+
66+
!!! danger
67+
Sparsity support is still experimental, use at your own risk.
6068

6169
```@docs
62-
AutoFastDifferentiation
6370
AutoSparseFastDifferentiation
64-
AutoTapir
71+
AutoSparseFiniteDiff
72+
AutoSparseForwardDiff
73+
AutoSparseForwardDiff()
74+
AutoSparsePolyesterForwardDiff
75+
AutoSparseReverseDiff
76+
AutoSparseZygote
6577
```
6678

6779
## Availability
@@ -111,6 +123,8 @@ Modules = [
111123
Base.get_extension(DifferentiationInterface, :DifferentiationInterfaceForwardDiffExt),
112124
Base.get_extension(DifferentiationInterface, :DifferentiationInterfacePolyesterForwardDiffExt),
113125
Base.get_extension(DifferentiationInterface, :DifferentiationInterfaceReverseDiffExt),
126+
Base.get_extension(DifferentiationInterface, :DifferentiationInterfaceSparseDiffToolsExt),
127+
Base.get_extension(DifferentiationInterface, :DifferentiationInterfaceTapirExt),
114128
Base.get_extension(DifferentiationInterface, :DifferentiationInterfaceTrackerExt),
115129
Base.get_extension(DifferentiationInterface, :DifferentiationInterfaceZygoteExt)
116130
]

docs/src/developer.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,31 @@ For simplicity, we remove `value_` in the operator names below.
2222
!!! note "Edge labels"
2323

2424
Full edges in the following graphs require a single call to the destination.
25-
Dotted edges require multiple calls to the destination, the number is indicated above.
25+
Dotted edges require multiple calls to the destination, the number is indicated on the edge.
2626

27-
### Forward mode, allocating functions
27+
### First order
2828

2929
```mermaid
3030
flowchart LR
31-
pushforward!! --> pushforward
32-
derivative --> pushforward
33-
derivative!! --> pushforward!!
34-
gradient .-> |n|pushforward
35-
gradient!! .-> |n|pushforward!!
36-
jacobian .-> |n|pushforward
37-
jacobian!! .-> |n|pushforward!!
38-
```
39-
40-
### Reverse mode, allocating functions
41-
42-
```mermaid
43-
flowchart LR
44-
pullback!! --> pullback
45-
derivative .-> |m|pullback
46-
derivative!! .-> |m|pullback!!
47-
gradient --> pullback
48-
gradient!! --> pullback!!
49-
jacobian .-> |m|pullback
50-
jacobian!! .-> |m|pullback!!
31+
direction LR
32+
subgraph Out-of-place
33+
pushforward
34+
pullback
35+
derivative --> pushforward
36+
gradient --> pullback
37+
jacobian .-> |n|pushforward
38+
jacobian .-> |m|pullback
39+
end
40+
41+
subgraph In-place
42+
pushforward!! --> pushforward
43+
pullback!! --> pullback
44+
derivative!! --> pushforward!!
45+
gradient!! --> pullback!!
46+
jacobian!! .-> |n|pushforward!!
47+
jacobian!! .-> |m|pullback!!
48+
end
49+
50+
pushforward .-> |m|pullback
51+
pullback .-> |n|pushforward
5152
```

docs/src/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ We only define two variants for now:
6969
| [`hessian`](@ref) | [`hessian!!`](@ref) |
7070

7171
!!! danger
72-
This is an experimental functionality, use at your own risk.
72+
Second-order differentiation is still experimental, use at your own risk.
7373

7474
## Preparation
7575

76-
In many cases, automatic differentiation can be accelerated if the function has been run at least once (e.g. to record a tape) and if some cache objects are provided.
76+
In many cases, AD can be accelerated if the function has been run at least once (e.g. to record a tape) and if some cache objects are provided.
7777
This is a backend-specific procedure, but we expose a common syntax to achieve it.
7878

7979
| operator | preparation function |

docs/src/tutorial.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ CurrentModule = Main
77
We present a typical workflow with DifferentiationInterface.jl and showcase its potential performance benefits.
88

99
```@repl tuto
10-
using ADTypes, BenchmarkTools, DifferentiationInterface
10+
using DifferentiationInterface
11+
using BenchmarkTools
1112
import ForwardDiff, Enzyme, DataFrames
1213
```
1314

1415
## Computing a gradient
1516

16-
A common use case of Automatic Differentiation (AD) is optimizing real-valued functions with first- or second-order methods.
17+
A common use case of AD is optimizing real-valued functions with first- or second-order methods.
1718
Let's define a simple objective
1819

1920
```@repl tuto
@@ -28,7 +29,7 @@ x = [1.0, 2.0, 3.0]
2829

2930
To compute its gradient, we need to choose a "backend", i.e. an AD package that DifferentiationInterface.jl will call under the hood.
3031
[ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) is very efficient for low-dimensional inputs, so we'll go with that one.
31-
Backend types are defined and exported by [ADTypes.jl](https://github.com/SciML/ADTypes.jl):
32+
Most backend types are defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl) and re-exported by DifferentiationInterface.jl:
3233

3334
```@repl tuto
3435
backend = AutoForwardDiff()

src/DifferentiationInterface.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ using ADTypes:
1616
AbstractFiniteDifferencesMode,
1717
AbstractReverseMode,
1818
AbstractSymbolicDifferentiationMode
19+
using ADTypes:
20+
AutoChainRules,
21+
AutoDiffractor,
22+
AutoEnzyme,
23+
AutoFiniteDiff,
24+
AutoFiniteDifferences,
25+
AutoForwardDiff,
26+
AutoPolyesterForwardDiff,
27+
AutoReverseDiff,
28+
AutoSparseFiniteDiff,
29+
AutoSparseForwardDiff,
30+
AutoSparsePolyesterForwardDiff,
31+
AutoSparseReverseDiff,
32+
AutoSparseZygote,
33+
AutoTracker,
34+
AutoZygote
1935
using DocStringExtensions
2036
using FillArrays: OneElement
2137
using LinearAlgebra: Symmetric, dot
@@ -67,6 +83,22 @@ include("hessian.jl")
6783

6884
include("backends.jl")
6985

86+
export AutoChainRules,
87+
AutoDiffractor,
88+
AutoEnzyme,
89+
AutoFiniteDiff,
90+
AutoFiniteDifferences,
91+
AutoForwardDiff,
92+
AutoPolyesterForwardDiff,
93+
AutoReverseDiff,
94+
AutoSparseFiniteDiff,
95+
AutoSparseForwardDiff,
96+
AutoSparsePolyesterForwardDiff,
97+
AutoSparseReverseDiff,
98+
AutoSparseZygote,
99+
AutoTracker,
100+
AutoZygote
101+
70102
export AutoFastDifferentiation, AutoSparseFastDifferentiation, AutoTapir
71103
export SecondOrder
72104

src/second_order.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
44
Combination of two backends for second-order differentiation.
55
6+
# Constructor
7+
8+
SecondOrder(outer, inner)
9+
610
# Fields
711
812
$(TYPEDFIELDS)

0 commit comments

Comments
 (0)