Skip to content

Comments

Fix for sparse-to-sparse matrix broadcast#686

Merged
kshyatt merged 6 commits intomasterfrom
ksh/bcast_fix
Feb 17, 2026
Merged

Fix for sparse-to-sparse matrix broadcast#686
kshyatt merged 6 commits intomasterfrom
ksh/bcast_fix

Conversation

@kshyatt
Copy link
Member

@kshyatt kshyatt commented Feb 17, 2026

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

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/src/host/sparse.jl b/src/host/sparse.jl
index 349e1f1..2335368 100644
--- a/src/host/sparse.jl
+++ b/src/host/sparse.jl
@@ -902,12 +902,12 @@ function Broadcast.copy(bc::Broadcasted{<:Union{GPUSparseVecStyle,GPUSparseMatSt
         args   = (bc.f, output, offsets, bc.args...)
         kernel = sparse_to_sparse_broadcast_kernel(get_backend(bc.args[first(sparse_args)]))
         ndrange = if sparse_typ <: AbstractGPUSparseVector
-                    output.nnz
-                  elseif sparse_typ <: AbstractGPUSparseMatrixCSC
-                    size(output, 2)
-                  else
-                     size(output, 1)
-                  end
+            output.nnz
+        elseif sparse_typ <: AbstractGPUSparseMatrixCSC
+            size(output, 2)
+        else
+            size(output, 1)
+        end
     else
         args   = sparse_typ <: AbstractGPUSparseVector ? (sparse_typ, bc.f, output, offsets, bc.args...) :
                                                          (sparse_typ, bc.f, output, bc.args...)
diff --git a/test/testsuite/sparse.jl b/test/testsuite/sparse.jl
index 3e0d92f..fd1dbad 100644
--- a/test/testsuite/sparse.jl
+++ b/test/testsuite/sparse.jl
@@ -285,13 +285,13 @@ function broadcasting_matrix(AT, eltypes)
             @test z == SparseMatrixCSC(dz)
 
             # create a matrix with nnz < leading_dim
-            x = spdiagm(m, m, 2=>rand(ET, m - 2))
+            x = spdiagm(m, m, 2 => rand(ET, m - 2))
             dx = AT(x)
             y = ET(3) * x
             dy = ET(3) * dx
             @test y == SparseMatrixCSC(dy)
 
-            x = spdiagm(m, m, -2=>rand(ET, m - 2))
+            x = spdiagm(m, m, -2 => rand(ET, m - 2))
             dx = AT(x)
             y = ET(3) * x
             dy = ET(3) * dx

@kshyatt kshyatt merged commit 1f221e3 into master Feb 17, 2026
21 of 22 checks passed
@kshyatt kshyatt deleted the ksh/bcast_fix branch February 17, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant