Add numba dispatch for SVD#2136
Conversation
What about https://en.wikipedia.org/wiki/CUR_matrix_approximation https://en.wikipedia.org/wiki/Interpolative_decomposition https://en.wikipedia.org/wiki/Polar_decomposition https://en.wikipedia.org/wiki/Category:Matrix_decompositions |
| # np.linalg.svd always returns real-valued singular values, even for complex input. | ||
| # The Op may declare s as complex (matching input dtype), but numba returns the real | ||
| # component dtype, so we must match that to avoid type unification errors. | ||
| # Casting discrete input to float allocates a new buffer, so in-place is moot. |
There was a problem hiding this comment.
hum? if you skip overwrite a in integer inputs you do two copies? the one to float and the one for the output?
you could say that if you cast you can always in place because it's a fresh buffer? opposite of what you did.
(does astype accept order=F). if not we should maybe implement our own version that does.
Actually I've missed this opt in other places?
For another time, should these cast be part of the graph? like expand dims that elemwise adds? then they 1) could be fused or rendered useless or what have you and 2) the numba dispatchers never need to worry about it
| if discrete_input: | ||
| x = x.astype(out_dtype) | ||
| return np.linalg.svd(x, full_matrices) | ||
| return _svd_gesdd_full( |
There was a problem hiding this comment.
worth a (one time) bench we are doing better than the numba dispatch?
| op = svd.SVD( | ||
| full_matrices=full_matrices, | ||
| compute_uv=compute_uv, | ||
| overwrite_a=overwrite_a, |
There was a problem hiding this comment.
I suggest using the actual inplace path with requires starting with a regular Blockwise and just seeing the root input as mutable. Then check the destroy map of the compiled function?
There was a problem hiding this comment.
so not starting with inplace graph
There's also https://en.wikipedia.org/wiki/Cholesky_decomposition#LDL_decomposition You are right though, I have a long and fruitful career of implementing matrix decompositions that nobody asked for still stretching out ahead of me. Bullet dodged! |
Fun fact, there are no decompositions left for me to implement when i'm bored.