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

Add getproperty for Tangent{<:Cholesky} #641

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Add getproperty for Tangent{<:Cholesky}.
  • Loading branch information
rofinn committed Jun 29, 2022
commit 6ae55dd12cbb93eecb94ac60d21a3cfe0f946b4e
8 changes: 8 additions & 0 deletions src/rulesets/LinearAlgebra/factorization.jl
Original file line number Diff line number Diff line change
@@ -578,3 +578,11 @@ function _x_divide_conj_y(x, y)
z = x / conj(y)
return iszero(x) ? zero(z) : z
end

# Support both factors and U / L properties on cholesky tangent types
# TOODO: Maybe we should check the type of U or L first?
function Base.getproperty(tangent::Tangent{P, T}, sym::Symbol) where {P <: Cholesky, T <: NamedTuple}
idx = if hasfield(T, :factors) && sym in (:U, :L) ? :factors : sym
hasfield(T, idx) || return ZeroTangent()
return unthunk(getfield(ChainRulesCore.backing(tangent), idx))
end