Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change eigen and svd pullbacks to accept Composite{Any} #340

Merged
merged 2 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRules"
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
version = "0.7.44"
version = "0.7.45"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
2 changes: 1 addition & 1 deletion src/rulesets/LinearAlgebra/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end

function rrule(::typeof(eigen), A::StridedMatrix{T}; kwargs...) where {T<:Union{Real,Complex}}
F = eigen(A; kwargs...)
function eigen_pullback(ΔF::Composite{<:Eigen})
function eigen_pullback(ΔF::Composite)
λ, V = F.values, F.vectors
Δλ, ΔV = ΔF.values, ΔF.vectors
ΔV isa AbstractZero && Δλ isa AbstractZero && return (NO_FIELDS, Δλ + ΔV)
Expand Down
4 changes: 2 additions & 2 deletions src/rulesets/LinearAlgebra/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function rrule(
kwargs...,
)
F = eigen(A; kwargs...)
function eigen_pullback(ΔF::Composite{<:Eigen})
function eigen_pullback(ΔF::Composite)
λ, U = F.values, F.vectors
Δλ, ΔU = ΔF.values, ΔF.vectors
ΔU = ΔU isa AbstractZero ? ΔU : copy(ΔU)
Expand Down Expand Up @@ -227,7 +227,7 @@ end
# is supported by reverse-mode AD packages
function rrule(::typeof(svd), A::LinearAlgebra.RealHermSymComplexHerm{<:BLAS.BlasReal,<:StridedMatrix})
F = svd(A)
function svd_pullback(ΔF::Composite{<:SVD})
function svd_pullback(ΔF::Composite)
U, V = F.U, F.V
c = _svd_eigvals_sign!(similar(F.S), U, V)
λ = F.S .* c
Expand Down