Skip to content

Automatic Differentiation#82

Merged
lkdvos merged 26 commits intomasterfrom
ad
Sep 29, 2023
Merged

Automatic Differentiation#82
lkdvos merged 26 commits intomasterfrom
ad

Conversation

@lkdvos
Copy link
Copy Markdown
Member

@lkdvos lkdvos commented Sep 25, 2023

This PR adds rrules and tests for most linear algebra methods.

Note that the tests for tsvd are disabled when working with Complex, as I have not been able to figure out how to make the lack of uniqueness of U and V work with finite differences and or the ChainRulesTestUtils interface.

return _repartition(p, N₁)
end

TensorKit.block(t::ZeroTangent, c::Sector) = t
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit suspicious? Why is this needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly to avoid having to manually deal with the ZeroTangent type. For example, a QR decomposition where the final result does not depend on R, would generate a ZeroTangent for dR, which is just an abstract representation that behaves as the zero vector in any (co)vectorspace. As some of the rrules are implemented "blockwise", this would either require manually checking if a tangent is a ZeroTangent, or, which is what I chose to do, rely on the hope that the compiler would recognize that the blockwise operation results in ZeroTangents anyways, and thus automatically takes care of this

Comment thread ext/TensorKitChainRulesCoreExt.jl
Comment thread ext/TensorKitChainRulesCoreExt.jl Outdated
@lkdvos lkdvos merged commit 6a0fa69 into master Sep 29, 2023
@lkdvos lkdvos deleted the ad branch September 29, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants