Skip to content

Commit e4a51c9

Browse files
authored
Merge pull request #189 from JuliaDiff/ox/goodfruler
Remove reference to pushforward in writing good rules
2 parents e8ac3a4 + 889fd9a commit e4a51c9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/src/writing_good_rules.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,39 @@ Instead you probably want `transpose(a)`, unless you've already restricted `a` t
4444

4545
## Code Style
4646

47-
Use named local functions for the `pushforward`/`pullback`:
47+
Use named local functions for the `pullback` in an `rrule`.
4848

4949
```julia
5050
# good:
51-
function frule(::typeof(foo), x)
51+
function rrule(::typeof(foo), x)
5252
Y = foo(x)
53-
function foo_pushforward(_, ẋ)
54-
return bar()
53+
function foo_pullback(x̄)
54+
return NO_FIELDS, bar()
5555
end
56-
return Y, foo_pushforward
56+
return Y, foo_pullback
5757
end
5858
#== output
59-
julia> frule(foo, 2)
60-
(4, var"#foo_pushforward#11"())
59+
julia> rrule(foo, 2)
60+
(4, var"#foo_pullback#11"())
6161
==#
6262

6363
# bad:
64-
function frule(::typeof(foo), x)
65-
return foo(x), (_, ẋ) -> bar()
64+
function rrule(::typeof(foo), x)
65+
return foo(x), -> (NO_FIELDS, bar(x̄))
6666
end
6767
#== output:
68-
julia> frule(foo, 2)
68+
julia> rrule(foo, 2)
6969
(4, var"##9#10"())
7070
==#
7171
```
7272

73-
While this is more verbose, it ensures that if an error is thrown during the `pullback`/`pushforward` the [`gensym`](https://docs.julialang.org/en/v1/base/base/#Base.gensym) name of the local function will include the name you gave it.
73+
While this is more verbose, it ensures that if an error is thrown during the `pullback` the [`gensym`](https://docs.julialang.org/en/v1/base/base/#Base.gensym) name of the local function will include the name you gave it.
7474
This makes it a lot simpler to debug from the stacktrace.
7575

7676
## Write tests
7777

78-
There are fairly decent tools for writing tests based on [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl).
79-
They are in [ChainRulesTestUtils.jl](https://github.com/JuliaDiff/ChainRulesTestUtils.jl).
78+
In [ChainRulesTestUtils.jl](https://github.com/JuliaDiff/ChainRulesTestUtils.jl)
79+
there are fairly decent tools for writing tests based on [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl).
8080
Take a look at existing [ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl) tests and you should see how to do stuff.
8181

8282
!!! warning

0 commit comments

Comments
 (0)