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

Disable + and - rules on mixed numeric types

Open oxinabox opened this issue 1 year ago • 0 comments

This is that constant tension in ChainRules between wanting to implement very general rules, but not being sure you can rely on them to work for types that you can't trust to follow your epxectations.

This is the companion to https://github.com/JuliaDiff/Diffractor.jl/pull/272

The version of this I have seen in the wild is calling Diffractor forwards mode over ForwardDiff, and then getting -(::Dual, Float64) which is defined, but this can result in -(::Tangent{<:Dual}, Float64) which is not defined.

I am not convinced this is the best point to chose. I think it might be argued that Diffractor's handling of Dual is aberant, and it should be constructing either a Tangent which is a Dual or it should be @opt_out frule(::typeof(-), ::Dual, Float64)

oxinabox avatar Mar 01 '24 05:03 oxinabox