Skip to content

Commit fa47a69

Browse files
Add ChainRulesTestUtils to FAQ (#125)
* Add ChainRulesTestUtils to FAQ Update docs/src/FAQ.md Give TestUtils own FAQ * Update test info in writing rules section
1 parent a2b99e6 commit fa47a69

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

docs/src/FAQ.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,23 @@ For example in `access(xs, n) = xs[n]` then the derivative of `access` with resp
5656

5757
## When to use ChainRules vs ChainRulesCore?
5858

59-
[ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl) is a light-weight dependency for defining rules for functions in your packages, without you needing to depend on ChainRules itself. It has no dependencies of its own.
59+
[ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl) is a light-weight dependency for defining rules for functions in your packages, without you needing to depend on ChainRules.jl itself.
60+
It has almost no dependencies of its own.
61+
If you only want to define rules, not use them, then you probably only want to load ChainRulesCore.jl.
6062

61-
[ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl) provides the full functionality, in particular it has all the rules for Base Julia and the standard libraries. Its thus a much heavier package to load.
62-
63-
If you only want to define rules, not use them then you probably only want to load ChainRulesCore.
64-
AD systems making use of ChainRules should load ChainRules (rather than ChainRulesCore).
63+
[ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl) provides the full functionality for AD systems, in particular it has all the rules for Base Julia and the standard libraries.
64+
It is thus a much heavier package to load.
65+
AD systems making use of `frule`s and `rrule`s should load ChainRules.jl.
6566

6667
## Where should I put my rules?
67-
In general, we recommend adding custom sensitivities to your own packages with ChainRulesCore, rather than adding them to ChainRules.jl.
6868

69-
A few packages currently SpecialFunctions.jl and NaNMath.jl are in ChainRules.jl but this is a short-term measure.
69+
We recommend adding custom rules to your own packages with [ChainRulesCore.jl](https://github.com/JuliaDiff/ChainRulesCore.jl), rather than adding them to ChainRules.jl.
70+
A few packages - currently SpecialFunctions.jl and NaNMath.jl - have rules in ChainRules.jl as a short-term measure.
71+
72+
## How do I test my rules?
73+
74+
You can use [ChainRulesTestUtils.jl](https://github.com/JuliaDiff/ChainRulesTestUtils.jl) to test your custom rules.
75+
ChainRulesTestUtils.jl has some dependencies, so it is a separate package from ChainRulesCore.jl.
76+
This means your package can depend on the light-weight ChainRulesCore.jl, and make ChainRulesTestUtils.jl a test-only dependency.
77+
78+
Remember to read the section on [Writing Good Rules](@ref).

docs/src/writing_good_rules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ This makes it a lot simpler to debug from the stacktrace.
7676
## Write tests
7777

7878
There are fairly decent tools for writing tests based on [FiniteDifferences.jl](https://github.com/JuliaDiff/FiniteDifferences.jl).
79-
They are in [`tests/test_utils.jl`](https://github.com/JuliaDiff/ChainRules.jl/blob/master/test/test_util.jl).
80-
Take a look at existing test and you should see how to do stuff.
79+
They are in [ChainRulesTestUtils.jl](https://github.com/JuliaDiff/ChainRulesTestUtils.jl).
80+
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
8383
Use finite differencing to test derivatives.

0 commit comments

Comments
 (0)