Conversation
|
I have not added tests for this explictly, but some places we still use this because we explictly want to pass special tangents in. |
|
I would say that we should wait til ChainRules is updated to use this, before merging. This is nonbreaking as the old way is deprecated. |
| function rrule_test(f, ȳ, xx̄s::Tuple{Any, Any}...; rtol::Real=1e-9, atol::Real=1e-9, fdm=_fdm, check_inferred::Bool=true, fkwargs::NamedTuple=NamedTuple(), kwargs...) | ||
| function test_rrule( | ||
| f, inputs...; | ||
| output_tangent=Auto(), |
There was a problem hiding this comment.
Should this be output_cotangent?
src/testers.jl
Outdated
| y = f(xs...; fkwargs...) | ||
| check_equal(y_ad, y; isapprox_kwargs...) # make sure primal is correct | ||
|
|
||
| ȳ = tangent(auto_primal_and_tangent(y ⊢ output_tangent)) |
There was a problem hiding this comment.
It's a bit stilly to be attaching a tangent to the primal explicitly, then pealing it off, but it makes both given and Auto() work
There was a problem hiding this comment.
Why don't we just use rand_tangent(y)? I don't understand this part of your comment:
but it makes both given and Auto() work
There was a problem hiding this comment.
the alternative is:
| ȳ = tangent(auto_primal_and_tangent(y ⊢ output_tangent)) | |
| ȳ = output_tangent === Auto() ? rand_tangent(primal) : output_tangent |
Which maybe is cleaner?
idk yesterday I was hating on branches.
I started to write auto_tangent(primal, output_tangent) and realized that it overlapped with auto_primal_and_tangent
There was a problem hiding this comment.
ȳ = output_tangent === Auto() ? rand_tangent(primal) : output_tangent is certainly much clearer, to my eyes
|
Ah, I forgot to push some changes. |
|
That's wonderful! Please ping me when it is done, happy to review |
d1b6746 to
3644e23
Compare
mzgubic
left a comment
There was a problem hiding this comment.
I love this change, makes the API so much easier to use. Should we also update the examples in the docs to reflect the new usage?
src/testers.jl
Outdated
| y = f(xs...; fkwargs...) | ||
| check_equal(y_ad, y; isapprox_kwargs...) # make sure primal is correct | ||
|
|
||
| ȳ = tangent(auto_primal_and_tangent(y ⊢ output_tangent)) |
There was a problem hiding this comment.
Why don't we just use rand_tangent(y)? I don't understand this part of your comment:
but it makes both given and Auto() work
Co-authored-by: Miha Zgubic <mzgubic@users.noreply.github.com>
|
I just got the deprecation message and it looked a bit too exotic. Why not pairs edit: maybe you need to differentiate with respect to a pair, I see now the problem |
| If `check_inferred=true`, then the inferrability of the `rrule` is checked — if `f` is | ||
| itself inferrable — along with the inferrability of the pullback it returns. | ||
| All remaining keyword arguments are passed to `isapprox`. | ||
| - `inputs` either the primal inputs `x`, or primals and their tangents: `x ⊢ ẋ` |
There was a problem hiding this comment.
ẋ should be x̄.
Maybe it should be explained also here how to produce a vdash
|
@CarloLucibello note the deprecations warning is misleading as to the correct action. |
Maybe manually define the deprecation, with a Otherwise people will do what the deprecation warning tells them to |
|
Good idea, I will see if I find time |
Closes #67
Does option 2D witth
x ⊢ ẋthat is
\vdash+ tabWe can argue about symbols though.
test_scalarorfrule_test+rrule_test#96 totest_fruleandtest_rrule. Which should make deprecations easierbefore:
After
No point declaring
xin advance any-more.Can just put the
randin-place