Skip to content

Commit

Permalink
move rule to Iterators.Zip to not break Zygote
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Oct 19, 2022
1 parent 4f144fd commit 51f1ed4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rulesets/Base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ end
##### `zip`
#####

function rrule(::typeof(zip), xs::AbstractArray...)
# Attaching the rule to `zip` breaks Zygote, whose rule is on `Iterators.Zip`.
# function rrule(::typeof(zip), xs::AbstractArray...)
function rrule(::Type{<:Iterators.Zip}, xs::Tuple{Vararg{AbstractArray}})
function zip_pullback(dy)
@debug "zip array pullback" summary(dy)
dxs = _tangent_unzip(unthunk(dy))
Expand Down Expand Up @@ -52,7 +54,7 @@ end

# For testing
function rrule(::ComposedFunction{typeof(collect), typeof(zip)}, xs::AbstractArray...)
y, back = rrule(zip, xs...)
y, back = rrule(Iterators.Zip, xs)
return collect(y), back
end

0 comments on commit 51f1ed4

Please sign in to comment.