Merge #1175
1175: xlogy broadcast adjoint r=MikeInnes a=MikeInnes This is helpful for performance, since it avoids having to differentiate `xlogy` itself inside of a map. Co-authored-by: Mike J Innes <mike.j.innes@gmail.com>
This commit is contained in:
commit
de39d1095b
|
@ -288,3 +288,8 @@ CuArrays.@cufunc function xlogy(x, y)
|
|||
result = x * log(y)
|
||||
ifelse(iszero(x), zero(result), result)
|
||||
end
|
||||
|
||||
@adjoint function broadcasted(::typeof(xlogy), x::Zygote.Numeric, y::Zygote.Numeric)
|
||||
res = xlogy.(x, y)
|
||||
res, Δ -> (nothing, Zygote.unbroadcast(x, xlogy.(Δ, y)), Zygote.unbroadcast(y, Δ .* x ./ y))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue