Skip to content

Commit 8ce96cc

Browse files
committed
Deal with empty sparse matrices
1 parent 4a03bc0 commit 8ce96cc

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lib/mkl/wrappers_sparse.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ for (fname, elty, intty) in ((:onemklSsparse_set_csr_data , :Float32 , :Int3
6060
m, n = dims
6161
nnzA = length(nzVal)
6262
queue = global_queue(context(nzVal), device(nzVal))
63-
$fname(sycl_queue(queue), handle_ptr[], m, n, 'O', rowPtr, colVal, nzVal)
63+
# Don't update handle if matrix is empty
64+
if m != 0 && n != 0
65+
$fname(sycl_queue(queue), handle_ptr[], m, n, 'O', rowPtr, colVal, nzVal)
66+
end
6467
dA = oneSparseMatrixCSR{$elty,$intty}(handle_ptr[], rowPtr, colVal, nzVal, (m,n), nnzA)
6568
finalizer(sparse_release_matrix_handle, dA)
6669
return dA
@@ -75,8 +78,10 @@ for (fname, elty, intty) in ((:onemklSsparse_set_csr_data , :Float32 , :Int3
7578
onemklXsparse_init_matrix_handle(handle_ptr)
7679
m, n = dims
7780
nnzA = length(nzVal)
78-
@show dims
79-
$fname(sycl_queue(queue), handle_ptr[], n, m, 'O', colPtr, rowVal, nzVal) # CSC of A is CSR of Aᵀ
81+
# Don't update handle if matrix is empty
82+
if m != 0 && n != 0
83+
$fname(sycl_queue(queue), handle_ptr[], n, m, 'O', colPtr, rowVal, nzVal) # CSC of A is CSR of Aᵀ
84+
end
8085
dA = oneSparseMatrixCSC{$elty,$intty}(handle_ptr[], colPtr, rowVal, nzVal, dims, nnzA)
8186
finalizer(sparse_release_matrix_handle, dA)
8287
return dA

0 commit comments

Comments
 (0)