Kron error when dealing with sparse gpuarrays
显示 更早的评论
When I attempt to use kron with a sparse gpu array as an input on R2019a, I get the following error:
"Error using matlab.internal.sparse.kronSparse
Input must be a sparse matrix."
This indicates to me that MATLAB is having issues either making or recognizing when gpuarrays are made sparse, since I've done the simple test case:
a = gpuarray([1 2]);
b = gpuarray([1 2]);
test1 = kron(a,b)
a = sparse(a)
test2 = kron(a,b)
and only the assignment of test2 gives the error. Does anyone know if there's a workaround for this, or am I stuck with using my cpu for these calculations?
3 个评论
Walter Roberson
2019-10-17
b is not sparse in your test2 call.
Matt J
2019-10-17
Also, what operations will be done subsequently with kron(a,b) once it is computed? Knowing that, one can often find workarounds that avoid computing the Kronecker product altogether.
Henry Abrahamson
2019-10-17
编辑:Henry Abrahamson
2019-10-17
回答(1 个)
You may want to look at,
which allows you to do many kinds of manipulations with Kronecker products without computing them in explicit matrix form. It should work with gpuArray operands.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!