`linalg` routines fail with pathologically edge cases
See original GitHub issueDescription
This is discovered using the array-api-tests
. I am not sure if the same behavior for handling 2D “scalar” matrices is applicable to all numpy.linalg
routines, or just the two I posted here.
To Reproduce
>>> import numpy as np
>>> import cupy as cp
>>>
>>> # cholesky
>>> np.linalg.cholesky(np.empty((0, 0), dtype=np.float32))
array([], shape=(0, 0), dtype=float32)
>>> cp.linalg.cholesky(cp.empty((0, 0), dtype=cp.float32))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/leof/dev/cupy_cuda114/cupy/linalg/_decomposition.py", line 205, in cholesky
potrf(
File "cupy_backends/cuda/libs/cusolver.pyx", line 1205, in cupy_backends.cuda.libs.cusolver.spotrf
cpdef spotrf(intptr_t handle, int uplo, int n, size_t A, int lda,
File "cupy_backends/cuda/libs/cusolver.pyx", line 1212, in cupy_backends.cuda.libs.cusolver.spotrf
check_status(status)
File "cupy_backends/cuda/libs/cusolver.pyx", line 1062, in cupy_backends.cuda.libs.cusolver.check_status
raise CUSOLVERError(status)
cupy_backends.cuda.libs.cusolver.CUSOLVERError: CUSOLVER_STATUS_INVALID_VALUE
>>>
>>> # matrix_power
>>> np.linalg.matrix_power(np.empty((0, 0), dtype=np.float32), n=-1)
array([], shape=(0, 0), dtype=float32)
>>> cp.linalg.matrix_power(cp.empty((0, 0), dtype=cp.float32), n=-1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/leof/dev/cupy_cuda114/cupy/linalg/_product.py", line 374, in matrix_power
M = _solve.inv(M)
File "/home/leof/dev/cupy_cuda114/cupy/linalg/_solve.py", line 323, in inv
cupyx.lapack.gesv(a, b)
File "/home/leof/dev/cupy_cuda114/cupyx/lapack.py", line 68, in gesv
getrf(handle, n, n, a.data.ptr, n, dwork.data.ptr, dipiv.data.ptr,
File "cupy_backends/cuda/libs/cusolver.pyx", line 1402, in cupy_backends.cuda.libs.cusolver.sgetrf
cpdef sgetrf(intptr_t handle, int m, int n, size_t A, int lda,
File "cupy_backends/cuda/libs/cusolver.pyx", line 1409, in cupy_backends.cuda.libs.cusolver.sgetrf
check_status(status)
File "cupy_backends/cuda/libs/cusolver.pyx", line 1062, in cupy_backends.cuda.libs.cusolver.check_status
raise CUSOLVERError(status)
cupy_backends.cuda.libs.cusolver.CUSOLVERError: CUSOLVER_STATUS_INVALID_VALUE
Installation
No response
Environment
No response
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Linear algebra (numpy.linalg) — NumPy v1.24 Manual
Several of the linear algebra routines listed above are able to compute results for several matrices at once, if they are stacked into...
Read more >4 Linear Algebra - Numerical Methods
We first need to understand how Python's numpy library builds and stores vectors and matrices. The following exercises will give you some experience...
Read more >Numerical Linear Algebra - Introduction to Programming in Java
This textbook provides an interdisciplinary approach to the CS 1 curriculum. We teach the classic elements of programming, using an.
Read more >Linear algebra (scipy.linalg) — SciPy v1.9.3 Manual
Solves a standard or generalized eigenvalue problem for a complex Hermitian or real symmetric matrix. Solve real symmetric or complex Hermitian band matrix ......
Read more >Optimizing Matrix Multiply using PHiPAC: a Portable, High ...
on linear algebra kernels but this currently requires ex- ... matrix multiplication, these routines have a large design ... cludes error checking.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed by #6164, #6167, #6210.
I’ll fix
eigh
andeigvalsh
.