Skip to content
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
5 changes: 3 additions & 2 deletions src/pullbacks/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ function svd_trunc_pullback!(
Y₀ᴴ = iszerotangent(ΔV₊ᴴ) ? zero(Vᴴ) : ldiv!(Diagonal(S), ΔV₊ᴴ)
US = mul!(ΔAV, U, Smat) # recycle ΔAV
AP = mul!(copy(A), US, Vᴴ, -1, 1)
AP ./= S[end]
S⁻¹ = S[end] ./ S
minS = minimum(S)

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.

Does last also work? Can we avoid blocking/syncing by using a view of the last element?

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.

I don't think so 😬 let me try and report back

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.

I think the problem is any of these require copying the last element back to the CPU, unless we write a custom kernel/map here which I'm kind of loathe to do...

AP ./= minS
S⁻¹ = minS ./ S
X₁ = rmul!(AP * Y₀ᴴ', Diagonal(S⁻¹))
X₁ .+= X₀
Y₁ᴴ = lmul!(Diagonal(S⁻¹), X₀' * AP)
Expand Down
Loading