diff --git a/src/lib/broadcast.jl b/src/lib/broadcast.jl index 8c0d3c54c..98124bd03 100644 --- a/src/lib/broadcast.jl +++ b/src/lib/broadcast.jl @@ -80,6 +80,8 @@ unbroadcast(x::AbstractArray, x̄::Nothing) = nothing @adjoint broadcasted(::typeof(-), x::Numeric, y::Numeric) = x .- y, Δ -> (nothing, unbroadcast(x, Δ), _minus(unbroadcast(y, Δ))) +@adjoint broadcasted(::typeof(-), x::Numeric) = .-x, + Δ -> (nothing, _minus(Δ)) _minus(Δ) = -Δ _minus(::Nothing) = nothing