Skip to content

Commit

Permalink
Collapse arrays of CR zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
ToucheSir committed Mar 19, 2023
1 parent 4fb6daa commit 6d983d5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/chainrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Convert `dx` from the format Zygote uses internally to differentials types Chain
@inline wrap_chainrules_input(::Nothing) = ChainRules.ZeroTangent()
@inline wrap_chainrules_input(::Tuple{Vararg{Nothing}}) = ChainRules.ZeroTangent()
@inline wrap_chainrules_input(::AbstractArray{Nothing}) = ChainRules.ZeroTangent()
@inline wrap_chainrules_input(dxs::AbstractArray{T}) where {T<:AbstractZero} = first(dxs)
@inline function wrap_chainrules_input(dxs::Union{Tuple, NamedTuple})
xp = map(wrap_chainrules_input, dxs)
# This produces Tangent{Any} since it does not get to see the primal, `x`.
Expand Down

0 comments on commit 6d983d5

Please sign in to comment.