-
Notifications
You must be signed in to change notification settings - Fork 46
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
Linear Algebra design overview #147
Comments
Is there a reason for omitting eigenvalue solvers? Those are a quite fundamental operation for linear algebra. More generally, I would be curious about any general reasoning behind what should and should not be included here. For example, |
As a reference point, I tried searching for usage of these functions from NumPy in Google's internal codebase. Most are used hundreds of times. The notable exceptions are |
@shoyer As for |
Re: |
For real matrices, svd's u and v are real, which can be thought as m- and n- dimensional rotational matrices. |
I should also mention that the above overview is reflective of the current list of both specified APIs and APIs which are currently up for review. Meaning, it reflects the current state of linear algebra APIs as included in the standard, so no curation, per se--more just trying to unify how we currently design APIs now and moving forward. |
To push back here a little bit -- I think the numbers from downstream libraries reported in https://github.com/data-apis/python-record-api/blob/master/data/typing/numpy.linalg.py are not necessarily indicative of usage for linear algebra functions, which tend to be rather specialized. Google's internal usage is certainly not representative of all usecases, but it's probably a bit more reflective of what numerical programmers use on average, across hundreds of different projects in different application domains. In particular:
All that said, I'm not really strongly opposed here. These functions are quite easy to implement in terms of other primitives already in the standard. I just don't think they're particularly worthy of inclusion. |
I tend to agree that they're not the most important functions. We had a discussion some months ago about where to draw the line, and the conclusion was that several people had a preference of including everything that's in |
I would suggest that |
From the Dask perspective, things like BLAS operations ( |
Regarding the SVD discussion, Sometimes only LAPACK does allow to compute only one of the U/Vt matrices, ?GESVD does not require that both |
@shoyer Updated |
@oleksandr-pavlyk I think for design consistency it makes sense to mirror So, I think the order here would be to first standardize |
A note on the importance of These are functions that are always well-defined, as opposed to the full factorisations for which some choices have to be made (if Edit The following paragraph is wrong as stated. The (ordered) eigenvalues are not differentiable at points with repeated eigenvalues, but simply continuous (and also 1-Lipschitz continuous wrt. the operator 2-norm) see this MO answer. This is still a large improvement over the eigenvectors, which are not even locally uniquely defined in the presence of repeated eigenvalues.
|
Closing this issue, as this overview is now outdated, given subsequent modifications to the specification. Further discussion and refinement can be done in separate issues/PRs. |
The intent of this issue is to provide a bird's eye view of linear algebra APIs in order to extract a consistent set of design principles for current and future spec evolution.
Unary APIs
Binary APIs:
Support stacks (batching)
Unary:
axis
is 2-tuple containing last two dimensions)axis1
andaxis2
)axis1
andaxis2
)Binary:
No stack (batching) support
Binary:
Support tolerances
rtol*largest_singular_value
)rtol*largest_singular_value
)rtol*largest_singular_value
)Supported dtypes
Numeric:
Floating:
Any:
Output values
Array:
Tuple:
svd
andsvdvals
(similar toeig/eigvals
)Note: only SVD is polymorphic in output (
compute_uv
keyword)Reduced output dims
keepdims
argkeepdims
keepdims
keepdims
keepdims
keepdims
keepdims
Conclusion: only
norm
is unique here in allowing the output array rank to remain the same as that of the input array.Broadcasting
ndims-1
dimensions)ndims-1
dimensions)rtol
)rtol
)Specialized behavior
upper
compute_uv
andfull_matrices
ord
andkeepdims
mode
axes
The text was updated successfully, but these errors were encountered: