Skip to content

Commit b020a2a

Browse files
committed
move rule to Iterators.Zip to not break Zygote
1 parent f80ef94 commit b020a2a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/rulesets/Base/iterators.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ end
2121
##### `zip`
2222
#####
2323

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

5355
# For testing
5456
function rrule(::ComposedFunction{typeof(collect), typeof(zip)}, xs::AbstractArray...)
55-
y, back = rrule(zip, xs...)
57+
y, back = rrule(Iterators.Zip, xs)
5658
return collect(y), back
5759
end
5860

0 commit comments

Comments
 (0)