Tullio.jl icon indicating copy to clipboard operation
Tullio.jl copied to clipboard

Opt out of CR.rrule if pullback is not defined

Open devmotion opened this issue 4 years ago • 0 comments

This came up in https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/pull/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 the rrule 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...).

devmotion avatar Oct 28 '21 21:10 devmotion