Description
See discussion at https://discourse.julialang.org/t/chainrulescore-rrule-for-custom-struct-does-the-pullback-need-to-support-composite-explicitly/56734
We can maybe do something with zero
and similar
like Zygote does for getindex
https://github.com/FluxML/Zygote.jl/blob/956cbcf3c572c0eb09c146189bb38b1b434634ff/src/lib/array.jl#L47-L49
I find thought when i was working on the getindex
for ChainRules (JuliaDiff/ChainRules.jl#240) trying to work this out for general case is actually really hard, i gave up and restricteds to x::Array{<:Number}
.
But maybe for rand_tangent
we don't need to do so well, we just need to make something that is more likely to be what the user expects than Composite
is.
It can still screw up, but as long as it screws up less, or with a clearer error.