Python wrappers
Public Python APIs implemented by this engine symbol.Compute the reduced singular value decomposition of a rectangular matrix.
Shape
- Input
a:(..., m, n). U:(..., m, k)— left singular vectors as columns.S:(..., k)— singular values in descending order.Vh:(..., k, n)— right singular vectors as rows (note:Vhis , not , matching NumPy/reference-framework convention).
Parameters
aTensorImplPtrInput matrix of shape
(..., m, n) with leading batch dims. Must be at least 2-D and have a floating-point dtype.compute_uvbool= NoneWhen
true (default) returns the full reduced factorisation . When false returns only, which lets the backend skip assembly of the singular vectors — roughly 2x faster and used by svdvals / matrix_rank / cond.Returns
std::vector<TensorImplPtr>If compute_uv=true: {U, S, Vh} with shape (..., m, k), shape (..., k), shape (..., k, n), . If compute_uv=false: {S} only.
Raises
:runtime_errorIf
a is null, has dtype that is not floating point, or has fewer than two dimensions.Notes
Singular values are guaranteed non-negative and sorted in descending order on output. Outputs are leaf nodes in the autograd graph at the C++ level — the Python wrapper attaches the gradient functions.
Examples
>>> // CPU equivalent of: U, S, Vh = svd(A, full_matrices=False)
>>> auto out = svd_op(a_impl, /*compute_uv=*/true);
>>> auto& U = out[0]; auto& S = out[1]; auto& Vh = out[2];