Opt out of CR.rrule if pullback is not defined #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This came up in JuliaGaussianProcesses/KernelFunctions.jl#386:
Sometimes you might want to use
grad=false
, e.g., if there is neither a rule in DiffRule nor do you want to use ForwardDiff. However, in this case therrule
will always error, even if your CR-compatible AD system could differentiate through your function just fine. This PR adds an opt-out definition if no pullback is defined so that the AD system can take over.Caveat: I don't think it's very useful in practice currently since (almost?) no CR-compatible AD system supports mutation. E.g., Zygote will just throw a mutation error instead of the custom error in the
rrule
definition. Therefore I'm not sure how useful this PR is currently (and I'm not sure how to test it properly...).