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

Symmetric/Hermitian matrix function rules #193

Merged
merged 95 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
6d66438
Add symmetric/hermitian eigendecomposition rules
sethaxen May 17, 2020
cac5290
Add utility functions
sethaxen May 17, 2020
bd16f24
Add frules and rrules for sym/herm power series
sethaxen May 17, 2020
bbbabf5
Add int pow rules
sethaxen May 17, 2020
b776223
Add sincos rules
sethaxen May 17, 2020
8d1fdd0
Remove unused function argument
sethaxen May 17, 2020
d50ba1e
Fix and comment _nonzero
sethaxen May 17, 2020
ee3a6fb
Make methods and signatures less ambiguous
sethaxen May 17, 2020
622b5b4
Handle Zero() better
sethaxen May 17, 2020
14b7266
Standardize notation
sethaxen May 17, 2020
57df366
Remove parens
sethaxen May 17, 2020
8c8790a
Update src/rulesets/LinearAlgebra/structured.jl
sethaxen May 17, 2020
0fdd8a5
Merge branch 'symhermpowseries' of https://github.com/sethaxen/ChainR…
sethaxen May 17, 2020
ef15c71
Fix for Julia 1.0
sethaxen May 17, 2020
ad9d36f
Use correct variable and method name
sethaxen May 17, 2020
0078a58
Accumulate in the triangle in the pullback
sethaxen May 17, 2020
5d1685f
Remove comment
sethaxen May 17, 2020
4366b26
Add eigen and eigvals tests
sethaxen May 17, 2020
f6075a5
Remove outdated comment
sethaxen May 18, 2020
90e3225
Clean up and make constraint functions faster
sethaxen May 18, 2020
e35ffef
Make outputs of int pow of Hermitian are Hermitian
sethaxen May 18, 2020
a604e45
Fix typo in comment
sethaxen May 18, 2020
c28304c
Test most power series functions
sethaxen May 18, 2020
e211034
Don't thunk tangents
sethaxen May 21, 2020
3ccfa91
Merge branch 'master' into symhermpowseries
sethaxen May 25, 2020
e4ec19d
Merge branch 'master' into symhermpowseries
sethaxen Jul 1, 2020
6d7c00c
Make type-stable and use optimal threshold
sethaxen Jul 20, 2020
115c201
Merge branch 'master' into symhermpowseries
sethaxen Jul 20, 2020
c877818
Merge branch 'master' into symhermpowseries
sethaxen Nov 20, 2020
f41bfe0
Split out symmetric/hermitian methods/tests
sethaxen Nov 24, 2020
52eef4d
Use correct pullback of hermitrization
sethaxen Nov 24, 2020
af12bed
Stabilize eigenvector computation
sethaxen Nov 25, 2020
46a4ec4
Test composed pullback
sethaxen Nov 25, 2020
e257b11
Remove all eigendecomposition rules
sethaxen Jan 5, 2021
6010c2f
Merge branch 'master' into symhermpowseries
sethaxen Jan 5, 2021
9571d19
Move to utilities section
sethaxen Jan 5, 2021
d7e3762
Move to utilities section
sethaxen Jan 5, 2021
64f96ee
Separate shared code into its own function
sethaxen Jan 5, 2021
109ce2c
Don't thunk
sethaxen Jan 5, 2021
00cccbc
Use correct function name
sethaxen Jan 5, 2021
eb0a7e2
Correctly broadcast
sethaxen Jan 5, 2021
c5a37da
Remove power rules
sethaxen Jan 6, 2021
648e13e
Merge branch 'master' into symhermpowseries
sethaxen Jan 7, 2021
d8b22f1
Rename to matrix functions
sethaxen Jan 8, 2021
0b0cd85
Remove pow tests
sethaxen Jan 8, 2021
f945b13
Expand test suite
sethaxen Jan 8, 2021
2087dac
Remove sincos rules for now
sethaxen Jan 8, 2021
97ec070
Add references and comments
sethaxen Jan 8, 2021
5f1529d
Add _isindomain
sethaxen Jan 8, 2021
537c1f8
Refactor _matfun
sethaxen Jan 8, 2021
65be168
Add _matfun_frechet
sethaxen Jan 8, 2021
2b3e11a
Broadcast instead of indexing
sethaxen Jan 8, 2021
ac0253c
Add comments and use indexing from paper
sethaxen Jan 8, 2021
b7b83f5
Handle Zeros
sethaxen Jan 8, 2021
1c6a889
Contrain differentials according to primals
sethaxen Jan 8, 2021
21340c9
Support all matrix functions
sethaxen Jan 8, 2021
7bf9b7c
Remove unused methods
sethaxen Jan 8, 2021
7d78762
Support Symmetric{Complex}
sethaxen Jan 8, 2021
d1e9947
Add rules for sincos
sethaxen Jan 8, 2021
444a49b
Make atanh rule type-stable
sethaxen Jan 8, 2021
7dcc8a2
Correctly test type-unstable functions
sethaxen Jan 8, 2021
eb52188
Use correct denominator
sethaxen Jan 8, 2021
f78945a
Add tests for almost-singular and low-rank matrices
sethaxen Jan 8, 2021
c8885cd
Remove out-dated comments
sethaxen Jan 8, 2021
b65f552
Test alternate differentials
sethaxen Jan 8, 2021
e6106f3
Don't use only
sethaxen Jan 8, 2021
68b9597
Remove _hermitrizeback!
sethaxen Jan 8, 2021
0778d7a
Don't use hasproperty, not in old Julia versions
sethaxen Jan 8, 2021
77cba6d
Reduce allocations
sethaxen Jan 8, 2021
fc34770
simplify section name
sethaxen Jan 8, 2021
62afe5e
Simplify line
sethaxen Jan 8, 2021
69bcbe8
Handle mixture of non-Zero and Zero
sethaxen Jan 8, 2021
6f6d38b
Don't loop over unused functions
sethaxen Jan 8, 2021
2f6cbeb
Test against component frules instead of fd
sethaxen Jan 8, 2021
673a258
Test that rules produce same uplo as primal
sethaxen Jan 8, 2021
357ecb8
Apply suggestions from code review
sethaxen Jan 12, 2021
bf2191c
Reuse variable name
sethaxen Jan 12, 2021
f1cba00
Use bang bang convention for maybe-in-place
sethaxen Jan 12, 2021
05e8363
Don't assume the wrapped matrix is mutable
sethaxen Jan 12, 2021
8a60771
Replace hermitrize!
sethaxen Jan 12, 2021
8c77687
Use diagind
sethaxen Jan 12, 2021
3ce3d8a
Remove handling of Zero differential
sethaxen Jan 12, 2021
9b40c09
Unify symbols
sethaxen Jan 12, 2021
e9aef74
Use hasproperty
sethaxen Jan 12, 2021
e338822
Load hasproperty from Compat
sethaxen Jan 12, 2021
17686f2
Replace refs with one to Higham
sethaxen Jan 12, 2021
359a1dc
Add docstrings
sethaxen Jan 12, 2021
32a9cca
Update src/rulesets/LinearAlgebra/symmetric.jl
sethaxen Jan 12, 2021
d81ee72
Merge branch 'master' into symhermpowseries
sethaxen Jan 13, 2021
73d5d01
Merge branch 'master' into symhermpowseries
sethaxen Jan 13, 2021
fd60d44
Increment version number
sethaxen Jan 13, 2021
867ea12
Use utility function
sethaxen Jan 13, 2021
b7f6c40
Stabilize jvp Jacobian dimensions
sethaxen Jan 14, 2021
f956f62
Don't use non-exported function
sethaxen Jan 14, 2021
d3ff01a
Bump required ChainRulesCore
sethaxen Jan 14, 2021
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.46"
version = "0.7.47"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
16 changes: 2 additions & 14 deletions test/rulesets/LinearAlgebra/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,7 @@
@testset for uplo in (:L, :U), hermout in (true, false)
A, ΔA = rand_matfun_input(f, TA, T, uplo, n, hermout), TA(randn(T, n, n), uplo)
Y = f(A)
istypestable = try
@inferred f(A)
true
catch ErrorException
false
end
if istypestable
if ChainRulesTestUtils._is_inferrable(f, A)
Copy link
Member

Choose a reason for hiding this comment

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

I don't love that we are using an explictly nonexported function.
Do we even need to be testing @inferred here, or can we rely on frule_test to do that for us later

Copy link
Member Author

@sethaxen sethaxen Jan 14, 2021

Choose a reason for hiding this comment

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

Unfortunately we cannot use frule_test or rrule_test here because we need to work around the outputs of some functions being type-unstable. (and rrule's won't agree with FiniteDifferences for Symmetric/Hermitian, only with them composed with the constructor). I copied over a simplified is_inferrable.

Y_ad, ∂Y_ad = @inferred frule((Zero(), ΔA), f, A)
else
TY = T∂Y = if T <: Real
Expand Down Expand Up @@ -383,18 +377,12 @@
@testset for uplo in (:L, :U), hermout in (true, false)
A = rand_matfun_input(f, TA, T, uplo, n, hermout)
Y = f(A)
istypestable = try
@inferred f(A)
true
catch ErrorException
false
end
ΔY = if Y isa Matrix
randn(eltype(Y), n, n)
else
typeof(Y)(randn(eltype(Y), n, n), Y.uplo)
end
if istypestable
if ChainRulesTestUtils._is_inferrable(f, A)
Y_ad, back = @inferred rrule(f, A)
else
TY = if T <: Real
Expand Down