Skip to content

Conversation

@ErikQQY
Copy link
Contributor

@ErikQQY ErikQQY commented May 23, 2025

Fix: #2785

@github-actions
Copy link
Contributor

github-actions bot commented May 23, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/lib/cublas/linalg.jl b/lib/cublas/linalg.jl
index 193b7c92d..7c01ef730 100644
--- a/lib/cublas/linalg.jl
+++ b/lib/cublas/linalg.jl
@@ -387,12 +387,12 @@ end
 
 # diagm
 
-LinearAlgebra.diagm(kv::Pair{<:Integer,<:CuVector}...) = _cuda_diagm(nothing, kv...)
-LinearAlgebra.diagm(m::Integer, n::Integer, kv::Pair{<:Integer,<:CuVector}...) = _cuda_diagm((Int(m),Int(n)), kv...)
+LinearAlgebra.diagm(kv::Pair{<:Integer, <:CuVector}...) = _cuda_diagm(nothing, kv...)
+LinearAlgebra.diagm(m::Integer, n::Integer, kv::Pair{<:Integer, <:CuVector}...) = _cuda_diagm((Int(m), Int(n)), kv...)
 LinearAlgebra.diagm(v::CuVector) = LinearAlgebra.diagm(0 => v)
 LinearAlgebra.diagm(m::Integer, n::Integer, v::CuVector) = LinearAlgebra.diagm(m, n, 0 => v)
 
-function _cuda_diagm(size, kv::Pair{<:Integer,<:CuVector}...)
+function _cuda_diagm(size, kv::Pair{<:Integer, <:CuVector}...)
     A = LinearAlgebra.diagm_container(size, kv...)
     for p in kv
         inds = LinearAlgebra.diagind(A, p.first)
@@ -401,19 +401,19 @@ function _cuda_diagm(size, kv::Pair{<:Integer,<:CuVector}...)
     return A
 end
 
-function LinearAlgebra.diagm_container(size, kv::Pair{<:Integer,<:CuVector}...)
+function LinearAlgebra.diagm_container(size, kv::Pair{<:Integer, <:CuVector}...)
     T = promote_type(map(x -> eltype(x.second), kv)...)
     U = promote_type(T, typeof(zero(T)))
     return cu(zeros(U, LinearAlgebra.diagm_size(size, kv...)...))
 end
 
-function LinearAlgebra.diagm_size(size::Nothing, kv::Pair{<:Integer,<:CuVector}...)
-    mnmax = mapreduce(x -> length(x.second) + abs(Int(x.first)), max, kv; init=0)
+function LinearAlgebra.diagm_size(size::Nothing, kv::Pair{<:Integer, <:CuVector}...)
+    mnmax = mapreduce(x -> length(x.second) + abs(Int(x.first)), max, kv; init = 0)
     return mnmax, mnmax
 end
-function LinearAlgebra.diagm_size(size::Tuple{Int,Int}, kv::Pair{<:Integer,<:CuVector}...)
-    mmax = mapreduce(x -> length(x.second) - min(0,Int(x.first)), max, kv; init=0)
-    nmax = mapreduce(x -> length(x.second) + max(0,Int(x.first)), max, kv; init=0)
+function LinearAlgebra.diagm_size(size::Tuple{Int, Int}, kv::Pair{<:Integer, <:CuVector}...)
+    mmax = mapreduce(x -> length(x.second) - min(0, Int(x.first)), max, kv; init = 0)
+    nmax = mapreduce(x -> length(x.second) + max(0, Int(x.first)), max, kv; init = 0)
     m, n = size
     (m ≥ mmax && n ≥ nmax) || throw(DimensionMismatch(lazy"invalid size=$size"))
     return m, n

@codecov
Copy link

codecov bot commented May 24, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 8 lines in your changes missing coverage. Please review.

Project coverage is 89.59%. Comparing base (22a875b) to head (d380e45).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
lib/cublas/linalg.jl 66.66% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2786      +/-   ##
==========================================
+ Coverage   89.45%   89.59%   +0.13%     
==========================================
  Files         153      153              
  Lines       13274    13298      +24     
==========================================
+ Hits        11874    11914      +40     
+ Misses       1400     1384      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt maleadt added enhancement New feature or request cuda array Stuff about CuArray. labels May 26, 2025
@maleadt
Copy link
Member

maleadt commented May 26, 2025

Thanks!

@maleadt maleadt merged commit 1004fd9 into JuliaGPU:master May 26, 2025
3 checks passed
@ErikQQY ErikQQY deleted the qqy/diagm branch May 26, 2025 07:26
@ErikQQY
Copy link
Contributor Author

ErikQQY commented May 26, 2025

Great! Can we cut a release with recent changes? I need them in my package testing.@maleadt

@maleadt
Copy link
Member

maleadt commented May 26, 2025

These are technically features, and we've only just cut a release... I'll add these to a patch version then.

@ErikQQY
Copy link
Contributor Author

ErikQQY commented May 27, 2025

It seems there are some failures with JuliaRegister 8b6a2a0#commitcomment-157997774, the latest version is not registered. @maleadt

@maleadt
Copy link
Member

maleadt commented May 28, 2025

Seems like it worked now: JuliaRegistries/General#131869

@kshyatt kshyatt mentioned this pull request Jun 6, 2025
christiangnrd pushed a commit to christiangnrd/CUDA.jl that referenced this pull request Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda array Stuff about CuArray. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUDA failed to create a diagonal matrix of CuArray(u)

3 participants