@@ -10,22 +10,38 @@ using DifferentiationInterface: backend_string
1010import Markdown
1111import Diffractor, Enzyme, FastDifferentiation, FiniteDiff, FiniteDifferences, ForwardDiff, PolyesterForwardDiff, ReverseDiff, Tapir, Tracker, Zygote
1212
13- function all_backends()
14- return [
15- AutoDiffractor(),
16- AutoEnzyme(; mode=Enzyme.Forward),
17- AutoEnzyme(; mode=Enzyme.Reverse),
18- AutoFastDifferentiation(),
19- AutoFiniteDiff(),
20- AutoFiniteDifferences(; fdm=FiniteDifferences.central_fdm(3, 1)),
21- AutoForwardDiff(),
22- AutoPolyesterForwardDiff(; chunksize=1),
23- AutoReverseDiff(),
24- AutoTapir(),
25- AutoTracker(),
26- AutoZygote(),
27- ]
13+ const backend_examples = (
14+ "AutoDiffractor()",
15+ "AutoEnzyme(; mode=Enzyme.Forward)",
16+ "AutoEnzyme(; mode=Enzyme.Reverse)",
17+ "AutoFastDifferentiation()",
18+ "AutoFiniteDiff()",
19+ "AutoFiniteDifferences(; fdm=FiniteDifferences.central_fdm(3, 1))",
20+ "AutoForwardDiff()",
21+ "AutoPolyesterForwardDiff(; chunksize=1)",
22+ "AutoReverseDiff()",
23+ "AutoTapir()",
24+ "AutoTracker()",
25+ "AutoZygote()",
26+ )
27+
28+ checkmark(x::Bool) = x ? '✅' : '❌'
29+ unicode_check_available(backend) = checkmark(check_available(backend))
30+ unicode_check_hessian(backend) = checkmark(check_hessian(backend))
31+ unicode_check_twoarg(backend) = checkmark(check_twoarg(backend))
32+
33+ io = IOBuffer()
34+
35+ # Table header
36+ println(io, "| Backend | Availability | Two-argument functions | Hessian support | Example |")
37+ println(io, "|:--------|:------------:|:----------------------:|:---------------:|:--------|")
38+
39+ for example in backend_examples
40+ b = eval(Meta.parse(example)) # backend
41+ join(io, [backend_string(b), unicode_check_available(b), unicode_check_twoarg(b), unicode_check_hessian(b), "`$example`"], '|')
42+ println(io, '|' )
2843end
44+ backend_table = Markdown.parse(String(take!(io)))
2945```
3046
3147# Backends
@@ -36,44 +52,21 @@ We support all dense backend choices from [ADTypes.jl](https://github.com/SciML/
3652
3753For sparse backends, only the Jacobian and Hessian operators are implemented differently, the other operators behave the same as for the corresponding dense backend.
3854
39- ## Availability
40-
41- You can use [ ` check_available ` ] ( @ref ) to verify whether a given backend is loaded, like we did below:
42-
4355``` @example backends
44- header = "| backend | available |" # hide
45- subheader = "|:---|:---:|" # hide
46- rows = map(all_backends()) do backend # hide
47- "| `$(backend_string(backend))` | $(check_available(backend) ? '✅' : '❌') |" # hide
48- end # hide
49- Markdown.parse(join(vcat(header, subheader, rows...), "\n")) # hide
56+ backend_table #hide
5057```
5158
52- ## Mutation support
59+ ## Availability
60+
61+ You can use [ ` check_available ` ] ( @ref ) to verify whether a given backend is loaded.
62+
63+ ## Support for two-argument functions
5364
5465All backends are compatible with one-argument functions ` f(x) = y ` .
5566Only some are compatible with two-argument functions ` f!(y, x) = nothing ` .
56- You can use [ ` check_twoarg ` ] ( @ref ) to check that feature, like we did below:
57-
58- ``` @example backends
59- header = "| backend | mutation |" # hide
60- subheader = "|:---|:---:|" # hide
61- rows = map(all_backends()) do backend # hide
62- "| `$(backend_string(backend))` | $(check_twoarg(backend) ? '✅' : '❌') |" # hide
63- end # hide
64- Markdown.parse(join(vcat(header, subheader, rows...), "\n")) # hide
65- ```
67+ You can check this compatibility using [ ` check_twoarg ` ] ( @ref ) .
6668
6769## Hessian support
6870
6971Only some backends are able to compute Hessians.
70- You can use [ ` check_hessian ` ] ( @ref ) to check that feature, like we did below:
71-
72- ``` @example backends
73- header = "| backend | Hessian |" # hide
74- subheader = "|:---|:---:|" # hide
75- rows = map(all_backends()) do backend # hide
76- "| `$(backend_string(backend))` | $(check_hessian(backend) ? '✅' : '❌') |" # hide
77- end # hide
78- Markdown.parse(join(vcat(header, subheader, rows...), "\n")) # hide
79- ```
72+ You can use [ ` check_hessian ` ] ( @ref ) to check this feature.
0 commit comments