Skip to content

Commit

Permalink
Prefer numeric zero over ZeroTangent for numeric arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick committed Sep 15, 2024
1 parent 0759953 commit 24edc21
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 @@ -162,6 +162,7 @@ end
# For arrays, whitelist the safe ones, but always look inside Any[]:
@inline wrap_chainrules_input(dxs::AbstractArray{<:Number}) = dxs
@inline wrap_chainrules_input(dxs::AbstractArray{<:AbstractArray{<:Number}}) = dxs
@inline wrap_chainrules_input(dxs::AbstractArray{<:Union{Nothing,T}}) where T <: Number = map(x -> x === nothing ? zero(T) : x, dxs)
@inline wrap_chainrules_input(dxs::AbstractArray) = map(wrap_chainrules_input, dxs)

#=
Expand Down

0 comments on commit 24edc21

Please sign in to comment.