Skip to content

Commit

Permalink
broadcast adjoint for unary minus (#1287)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Aug 15, 2022
1 parent e4fc02c commit 17a5673
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 17a5673

Please sign in to comment.