Skip to content

Commit c36d81c

Browse files
committed
include debugging example
1 parent 0cf721a commit c36d81c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

docs/src/index.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
```@meta
2-
DocTestFilters = r"[0-9\.]+s"
2+
DocTestFilters = [r"[0-9\.]+s",r"isapprox\(.*\)"]
33
```
44
# ChainRulesTestUtils
55

@@ -41,12 +41,12 @@ end
4141
# output
4242
4343
```
44-
and `rrule`
44+
and `rrule` which contains a mistake in the first cotangent
4545
```jldoctest ex
4646
function ChainRulesCore.rrule(::typeof(two2three), x1, x2)
4747
y = two2three(x1, x2)
4848
function two2three_pullback(Ȳ)
49-
return (NoTangent(), 2.0*Ȳ[2], 3.0*Ȳ[3])
49+
return (NoTangent(), 2.1*Ȳ[2], 3.0*Ȳ[3])
5050
end
5151
return y, two2three_pullback
5252
end
@@ -69,22 +69,27 @@ julia> using ChainRulesTestUtils;
6969
7070
julia> test_frule(two2three, 3.33, -7.77);
7171
Test Summary: | Pass Total Time
72-
test_frule: two2three on Float64,Float64 | 6 6 2.4s
72+
test_frule: two2three on Float64,Float64 | 6 6 2.7s
7373
7474
```
7575

7676
### Testing the `rrule`
7777

78-
[`test_rrule`](@ref) takes in the function `f`, and primal inputsr `x`.
78+
[`test_rrule`](@ref) takes in the function `f`, and primal inputs `x`.
7979
The call will test the `rrule` for function `f` at the point `x`, and similarly to `frule` some rules should be tested at multiple points in the domain.
8080

8181
```jldoctest ex
8282
julia> test_rrule(two2three, 3.33, -7.77);
83-
Test Summary: | Pass Total Time
84-
test_rrule: two2three on Float64,Float64 | 10 10 0.9s
85-
83+
test_rrule: two2three on Float64,Float64: Test Failed at /home/lior/.julia/dev/ChainRulesTestUtils/src/check_result.jl:24
84+
Expression: isapprox(actual, expected; kwargs...)
85+
Problem: cotangent for input 2, Float64
86+
Evaluated: isapprox(-4.032, -3.840000000001641; rtol = 1.0e-9, atol = 1.0e-9)
87+
[...]
8688
```
8789

90+
The output of the test indicates to us the cause of the failure under "Problem:" with the expected (`rrule` derived) and actual finite difference results.
91+
The Problem lies with the cotangent corresponding to input 2 of `rrule`, which is the first cotangent as expected.
92+
8893
## Scalar example
8994

9095
For functions with a single argument and a single output, such as e.g. ReLU,
@@ -109,7 +114,7 @@ call.
109114
```jldoctest ex
110115
julia> test_scalar(relu, 0.5);
111116
Test Summary: | Pass Total Time
112-
test_scalar: relu at 0.5 | 12 12 1.0s
117+
test_scalar: relu at 0.5 | 12 12 1.2s
113118
114119
115120
julia> test_scalar(relu, -0.5);

0 commit comments

Comments
 (0)