Add empty input guards to numba linalg#2057
Merged
jessegrabowski merged 6 commits intov3from Apr 19, 2026
Merged
Conversation
Member
Author
|
general comment: we could either guard in the overload or in the dispatch. I chose the dispatch to keep the overload as light as possible. We could even optimize further to replace these Ops with a DeepCopy if we know at compile time that the input will be empty. But that seems like an extraordinary corner case. |
ricardoV94
approved these changes
Apr 18, 2026
Member
|
It's #1298 |
ricardoV94
reviewed
Apr 18, 2026
ricardoV94
reviewed
Apr 19, 2026
| if x.size == 0: | ||
| m, n = x.shape | ||
| k = min(m, n) | ||
| # The LAPACK dispatch returns matrices in fortran order. To match this for the empty cases, |
Member
There was a problem hiding this comment.
why does it matter the order? Because numba doesn't want one branch returning F and another returning C?
ricardoV94
approved these changes
Apr 19, 2026
Member
|
squash, rebase, or cleanup first? |
Member
Author
|
SQUASH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was hitting this error in #2032;
tests/tensor/linalg/test_decomposition/test_schur.py::test_schur_emptywas failing because we didn't have any guard in place for an early return on empy inputs. I am a bit at a loss why the CI isnt' currently failing on v3. It might be a mac vs linux lapack thing?Anyway I fixed it, and also did an audit of the other linalg functions against empty inputs and found several decompositions that didn't have an appropriate guard, so I added those as well.
Related to: #1298