Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround np.linalg.solve ambiguity #93

Merged
merged 4 commits into from
Feb 28, 2024
Merged

Conversation

asmeurer
Copy link
Member

NumPy's solve() does not handle the ambiguity around x2 being 1-D vector vs. an n-D stack of matrices in the way that the standard specifies. Namely, x2 should be treated as a 1-D vector iff it is 1-dimensional, and a stack of matrices in all other cases. This workaround is borrowed from array-api-strict.

See numpy/numpy#15349 and data-apis/array-api#285.

Note that this workaround only works for NumPy. CuPy currently does not support stacked vectors for solve() (see
https://github.com/cupy/cupy/blob/main/cupy/cublas.py#L43), and the workaround in cupy.array_api.linalg does not seem to actually function.

NumPy's solve() does not handle the ambiguity around x2 being 1-D vector vs.
an n-D stack of matrices in the way that the standard specifies. Namely, x2
should be treated as a 1-D vector iff it is 1-dimensional, and a stack of
matrices in all other cases. This workaround is borrowed from
array-api-strict.

See numpy/numpy#15349 and
data-apis/array-api#285.

Note that this workaround only works for NumPy. CuPy currently does not
support stacked vectors for solve() (see
https://github.com/cupy/cupy/blob/main/cupy/cublas.py#L43), and the workaround
in cupy.array_api.linalg does not seem to actually function.
@asmeurer
Copy link
Member Author

Test failure is an upstream issue data-apis/array-api-tests#238

@asmeurer asmeurer disabled auto-merge February 28, 2024 23:47
@asmeurer asmeurer merged commit 8657396 into data-apis:main Feb 28, 2024
20 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant