Skip to content

Commit fd6a675

Browse files
committed
make docs build
1 parent 874da9f commit fd6a675

3 files changed

Lines changed: 14 additions & 53 deletions

File tree

docs/make.jl

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,23 @@
1-
using ChainRulesCore
1+
using ChainRulesOverloadGeneration
2+
using ChainRulesCore: ChainRulesCore
23
using Documenter
34
using DocThemeIndigo
45
using Markdown
56

6-
DocMeta.setdocmeta!(
7-
ChainRulesOverloadGeneration,
8-
:DocTestSetup,
9-
quote
10-
using Random
11-
Random.seed!(0) # frule doctest shows output
12-
13-
using ChainRulesCore
14-
# These rules are all actually defined in ChainRules.jl, but we redefine them here to
15-
# avoid the dependency.
16-
@scalar_rule(sin(x), cos(x)) # frule and rrule doctest
17-
@scalar_rule(sincos(x), @setup((sinx, cosx) = Ω), cosx, -sinx) # frule doctest
18-
@scalar_rule(hypot(x::Real, y::Real), (x / Ω, y / Ω)) # rrule doctest
19-
end
20-
)
21-
227
indigo = DocThemeIndigo.install(ChainRulesOverloadGeneration)
238

249
makedocs(
2510
modules=[ChainRulesOverloadGeneration],
2611
format=Documenter.HTML(
2712
prettyurls=false,
2813
assets=[indigo],
29-
mathengine=MathJax3(
30-
Dict(
31-
:tex => Dict(
32-
"inlineMath" => [["\$","\$"], ["\\(","\\)"]],
33-
"tags" => "ams",
34-
# TODO: remove when using physics package
35-
"macros" => Dict(
36-
"ip" => ["{\\left\\langle #1, #2 \\right\\rangle}", 2],
37-
"Re" => "{\\operatorname{Re}}",
38-
"Im" => "{\\operatorname{Im}}",
39-
"tr" => "{\\operatorname{tr}}",
40-
),
41-
),
42-
),
43-
),
4414
),
4515
sitename="ChainRules",
46-
authors="Jarrett Revels and other contributors",
16+
authors="Lyndon White and other contributors",
4717
pages=[
4818
"Introduction" => "index.md",
49-
"FAQ" => "FAQ.md",
50-
"Writing Good Rules" => "writing_good_rules.md",
51-
"Complex Numbers" => "complex.md",
52-
"Deriving Array Rules" => "arrays.md",
53-
"Debug Mode" => "debug_mode.md",
54-
"Gradient Accumulation" => "gradient_accumulation.md",
55-
"Usage in AD" => [
56-
"Overview" => "autodiff/overview.md",
57-
"Operator Overloading" => "autodiff/operator_overloading.md",
58-
],
59-
"Design" => [
60-
"Changing the Primal" => "design/changing_the_primal.md",
61-
"Many Differential Types" => "design/many_differentials.md",
62-
],
6319
"API" => "api.md",
64-
],
20+
],
6521
strict=true,
6622
checkdocs=:exports,
6723
)

docs/src/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```@autodocs
44
Modules = [ChainRulesOverloadGeneration]
5-
Pages = ["rule_definition_tools.jl"]
5+
Pages = ["ruleset_loading.jl"]
66
Private = false
77
```
88

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Operator Overloading
1+
# Operator Overloading AD with ChainRulesOverloadGeneration.jl
2+
3+
The ChainRulesOverloadGeneration package provides a suite of methods for using [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl) rules in operator overloaded based AD systems.
4+
It tracks what rules are defined at any point in time, and lets you trigger functions to which can use `@eval` in order to define the matching operator overloads.
5+
26

37
The principal interface for using the operator overload generation method is [`on_new_rule`](@ref).
48
This function allows one to register a hook to be run every time a new rule is defined.
@@ -14,7 +18,7 @@ or more simply you can just use conditions for this.
1418
For example if your AD only supports `AbstractMatrix{Float64}` and `Float64` inputs you might write:
1519
```julia
1620
const ACCEPT_TYPE = Union{Float64, AbstractMatrix{Float64}}
17-
function define_overload(sig::Type{<:Tuple{F, Vararg{ACCEPT_TYPE}}) where F
21+
function define_overload(sig::Type{<:Tuple{F, Vararg{ACCEPT_TYPE}}}) where F
1822
@eval quote
1923
# ...
2024
end
@@ -54,6 +58,7 @@ When the rules are refreshed (automatically or manually), the hooks are only tri
5458
It is useful to undo [`on_new_rule`] hook registration if you are iteratively developing your overload generation function.
5559

5660
## Examples
61+
Here we define two fairly simplistic operator overloading based AD Systems to demonstrate how this is used.
5762

5863
### ForwardDiffZero
5964
The overload generation hook in this example is: `define_dual_overload`.
@@ -62,7 +67,7 @@ The overload generation hook in this example is: `define_dual_overload`.
6267
using Markdown
6368
Markdown.parse("""
6469
```julia
65-
$(read(joinpath(@__DIR__,"../../../test/demos/forwarddiffzero.jl"), String))
70+
$(read(joinpath(@__DIR__,"../../test/demos/forwarddiffzero.jl"), String))
6671
```
6772
""")
6873
````
@@ -74,7 +79,7 @@ The overload generation hook in this example is: `define_tracked_overload`.
7479
using Markdown
7580
Markdown.parse("""
7681
```julia
77-
$(read(joinpath(@__DIR__,"../../../test/demos/reversediffzero.jl"), String))
82+
$(read(joinpath(@__DIR__,"../../test/demos/reversediffzero.jl"), String))
7883
```
7984
""")
8085
````

0 commit comments

Comments
 (0)