Support mul!(Diagonal, A, B)#2977
Merged
Merged
Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/lib/cublas/linalg.jl b/lib/cublas/linalg.jl
index ea027edab..613d3329b 100644
--- a/lib/cublas/linalg.jl
+++ b/lib/cublas/linalg.jl
@@ -537,8 +537,8 @@ function LinearAlgebra.mul!(C::CuMatrix{T}, A::Diagonal{T,<:CuVector}, B::Adjoin
return C
end
-function LinearAlgebra.mul!(C::Diagonal{T, <:CuVector}, A::Union{<:CuMatrix{T}, Adjoint{T, <:CuMatrix}, Transpose{T, <:CuMatrix}}, B::Union{<:CuMatrix{T}, Adjoint{T, <:CuMatrix}, Transpose{T, <:CuMatrix}}) where {T<:CublasFloat}
- Cfull = A*B
+function LinearAlgebra.mul!(C::Diagonal{T, <:CuVector}, A::Union{<:CuMatrix{T}, Adjoint{T, <:CuMatrix}, Transpose{T, <:CuMatrix}}, B::Union{<:CuMatrix{T}, Adjoint{T, <:CuMatrix}, Transpose{T, <:CuMatrix}}) where {T <: CublasFloat}
+ Cfull = A * B
C.diag .= diag(Cfull)
return C
end
diff --git a/test/libraries/cublas/extensions.jl b/test/libraries/cublas/extensions.jl
index f181b7f29..9e08ba7e0 100644
--- a/test/libraries/cublas/extensions.jl
+++ b/test/libraries/cublas/extensions.jl
@@ -585,13 +585,13 @@ k = 13
@test Array(d_AX) ≈ A' * Diagonal(x)
@test Array(d_X) == Diagonal(Array(d_x))
-
+
d_X = Diagonal(copy(d_x))
diagA = diagm(rand(elty, m))
d_diagA = CuArray(diagA)
diagB = diagm(rand(elty, m))
d_diagB = CuArray(diagB)
- diagAdiagB = diagA * diagB'
+ diagAdiagB = diagA * diagB'
mul!(d_X, d_diagA, d_diagB')
@test Diagonal(collect(d_X.diag)) ≈ Diagonal(diagAdiagB)
end |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2977 +/- ##
==========================================
- Coverage 89.36% 89.34% -0.02%
==========================================
Files 150 150
Lines 13115 13119 +4
==========================================
+ Hits 11720 11721 +1
- Misses 1395 1398 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
maleadt
approved these changes
Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.