Description
There is a significant optimization we can make to +
where one of the arguments is a OneElement
I wrote out the general case for it here:
https://github.com/JuliaDiff/ChainRules.jl/pull/717/files#diff-3ebfe4c6177a89aaa1620d8565d89c551d882f7def080c63c343779c16366741R114-R124
though that uses ChainRulesCore.is_inplaceable_destination
to workout if an array can be mutated which would need to be stripped before porting. Since there has been arguments against directly depending on CRC in this package in the past.
For this case on a 300x300 array it gives a 3x speedup (JuliaDiff/ChainRules.jl#717 (comment))
But there are even more optimal cases when both elements are OneElement
(at cost of complete type stability)
And possibly other types too.