ChainRules.jl
ChainRules.jl copied to clipboard
Rules for zip missing
Probably this generalises to others in Base.Iterators
Sometimes this works in Zygote and sometimes it doesn't - i haven't worked out what the difference is:
x, y = rand(3,), rand(3,)
Zygote.gradient(() -> sum(first(zip(x, y)))) # works
Zygote.gradient(() -> sum(map(_ -> 1.0, (x, y)))) # works
Zygote.gradient(() -> sum(map(_ -> 1.0, zip(x, y)))) # errors Need an adjoint for constructor Base.Iterators.Zip{Tuple{Vector{Float64}, Vector{Float64}}}
Anyway, it looks like zip is missing from CR.
Xref an attempt to do this within Zygote: https://github.com/FluxML/Zygote.jl/pull/785 Which always got stuck on yet more weird cases.