-
Notifications
You must be signed in to change notification settings - Fork 5
Make JET happy #188
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
Make JET happy #188
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,15 +135,12 @@ function eig_trunc_pullback!( | |
| (n, n) == size(ΔA) || throw(DimensionMismatch()) | ||
| G = V' * V | ||
|
|
||
| VᴴΔV = !iszerotangent(ΔV) ? V' * ΔV : zero(G) | ||
| ΔVperp = ΔV - V * inv(G) * VᴴΔV | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this even work if |
||
| if !iszerotangent(ΔV) | ||
| (n, p) == size(ΔV) || throw(DimensionMismatch()) | ||
| VᴴΔV = V' * ΔV | ||
| check_eig_cotangents(D, VᴴΔV; degeneracy_atol, gauge_atol) | ||
|
|
||
| ΔVperp = ΔV - V * inv(G) * VᴴΔV | ||
| VᴴΔV .*= conj.(inv_safe.(transpose(D) .- D, degeneracy_atol)) | ||
| else | ||
| VᴴΔV = zero(G) | ||
| end | ||
|
|
||
| if !iszerotangent(ΔDmat) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,8 @@ function svd_pullback!( | |
| Ur = view(U, :, 1:r) | ||
| Vᴴr = view(Vᴴ, 1:r, :) | ||
| Sr = view(S, 1:r) | ||
| indU = axes(U, 2) | ||
| indV = axes(Vᴴ, 1) | ||
|
Comment on lines
+50
to
+51
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These can probably immediately get their final value, since |
||
|
|
||
| # Extract and check the cotangents | ||
| ΔU, ΔSmat, ΔVᴴ = ΔUSVᴴ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2033,14 +2033,15 @@ for (gesvd, gesdd, gesvdx, gejsv, gesvj, elty, relty) in | |
| for i in 1:2 # first call returns lwork as work[1] | ||
| #! format: off | ||
| if eltype(A) <: Complex | ||
| rwork_ = isnothing(rwork) ? Vector{$relty}(undef, 0) : rwork | ||
| ccall((@blasfunc($gesvd), libblastrampoline), Cvoid, | ||
| (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, | ||
| Ptr{$relty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, | ||
| Ptr{$elty}, Ref{BlasInt}, Ptr{$relty}, | ||
| Ptr{BlasInt}, Clong, Clong), | ||
| jobu, jobvt, m, n, A, lda, | ||
| S, U, ldu, Vᴴ, ldv, | ||
| work, lwork, rwork, | ||
| work, lwork, rwork_, | ||
| info, 1, 1) | ||
| else | ||
| ccall((@blasfunc($gesvd), libblastrampoline), Cvoid, | ||
|
|
@@ -2135,14 +2136,15 @@ for (gesvd, gesdd, gesvdx, gejsv, gesvj, elty, relty) in | |
| for i in 1:2 # first call returns lwork as work[1] | ||
| #! format: off | ||
| if eltype(A) <: Complex | ||
| rwork_ = isnothing(rwork) ? Vector{$relty}(undef, 0) : rwork | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see how this one helps? if rwork_::Vector{$relty} = rwork?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
JET seems unable to deduce this fact :( Let's try the suggestion and see how it reacts!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, no dice, because from JET's PoV this could still involve a conversion from |
||
| ccall((@blasfunc($gesdd), libblastrampoline), Cvoid, | ||
| (Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, | ||
| Ptr{$relty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, | ||
| Ptr{$elty}, Ref{BlasInt}, Ptr{$relty}, Ptr{BlasInt}, | ||
| Ptr{BlasInt}, Clong), | ||
| job, m, n, A, lda, | ||
| S, U, ldu, Vᴴ, ldv, | ||
| work, lwork, rwork, iwork, | ||
| work, lwork, rwork_, iwork, | ||
| info, 1) | ||
| else | ||
| ccall((@blasfunc($gesdd), libblastrampoline), Cvoid, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the least impactful: making these nothing and having a small type union, or the current approach, which I think does require a small allocation?