You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to suggest including a rule for GPU reductions.
using Zygote
functionmy_loss(v)
# This works:# l = sum(v)# This does not work:
l =reduce(+, v)
return l
end
v =cu([1., 2.])
Zygote.gradient(my_loss, v)
Isn't the reduction implemented on the GPU? I don't know the details, but reducing on the GPU and then copying the result is certainly more efficient than copying the entire vector and reducing on the CPU.
Sure. The rrule for sum just calls sum again on what it's given, for the forward pass, and thus uses the same GPU code as without AD. (And the reverse pass is written using broadcasting, which also works on the GPU.)
Hi,
I'd like to suggest including a rule for GPU reductions.
See also: FluxML/Zygote.jl#730 (comment)
The text was updated successfully, but these errors were encountered: