Kron error when dealing with sparse gpuarrays

조회 수: 3 (최근 30일)
Henry Abrahamson
Henry Abrahamson 2019년 10월 17일
편집: Matt J 2019년 10월 17일
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
Matt J
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
Henry Abrahamson 2019년 10월 17일
편집: Henry Abrahamson 2019년 10월 17일
I know that b isn't sparse, there's a line in the kron function (like 37 or something) that's supposed to make b sparse and then pass it to that internal function, but the fact that it doesn't work for me is my whole issue.
The Kronecker is just being used to simplify a bit of matrix multiplication I'd have to do. But now that you mention it, I think I see a way to do it the long way (in terms of some extra lines of code) that should get the same results without a terrible performance hit. Thanks for the tip!

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2019년 10월 17일
편집: Matt J 2019년 10월 17일
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.

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by