Skip to content

Commit

Permalink
Merge 0ff02a1 into 9e4cb76
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Oct 18, 2019
2 parents 9e4cb76 + 0ff02a1 commit e9a344f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rulesets/Base/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function frule(::typeof(sum), x)
return sum(x), sum_pushforward
end

function rrule(::typeof(sum), x)
function rrule(::typeof(sum), x::AbstractArray{<:Real})
function sum_pullback(ȳ)
return (NO_FIELDS, @thunk(fill(ȳ, size(x))))
end
Expand All @@ -67,15 +67,15 @@ end
function rrule(::typeof(sum), f, x::AbstractArray{<:Real}; dims=:)
y, mr_pullback = rrule(mapreduce, f, Base.add_sum, x; dims=dims)
function sum_pullback(ȳ)
NO_FIELDS, DNE(), last(mr_pullback(ȳ))
return NO_FIELDS, DNE(), last(mr_pullback(ȳ))
end
return y, sum_pullback
end

function rrule(::typeof(sum), x::AbstractArray{<:Real}; dims=:)
y, inner_pullback = rrule(sum, identity, x; dims=dims)
function sum_pullback(ȳ)
NO_FIELDS, last(inner_pullback(ȳ))
return NO_FIELDS, last(inner_pullback(ȳ))
end
return y, sum_pullback
end
Expand Down

0 comments on commit e9a344f

Please sign in to comment.