Sparse Linear Algebra#
iskra ✨ provides a fully fledged sparse tensor framework to help you write geometry processing code.
Its functionality primarily covers sparse COO tensors for most operations and should be used, e.g., while you’re assembling sparse linear operators.
Support for CSR tensors is very limited, but they are preferred in cases of matrix multiplication and sparse linear solves.
For example, PyTorch has no (proper) support for sparse COO matrix multiplication, so iskra will conver to CSR under the hood every time you attempt to multiply with a COO matrix.
Therefore, a common pattern would be to do all operations in the COO format, and convert to CSR right before you are about to do matrix multiplies or linear solves.
It was important that the sparse API was written directly in Python instead of as custom kernels. This allows the code to remain hackable, we benefit from low-level kernels and bindings in PyTorch itself, and code distribution becomes significantly simpler. Ideally, PyTorch itself would catch up on the sparse tensor functionality and I would not have to maintain a sparse tensor library :)
iskra.sparse#
|
Sane PyTorch sparse tensor. |
|
Creates an alias (view) of a tensor. |
|
Appends new values to an existing COO tensor. |
|
Concatenates sparse COO matrices along a dimension. |
|
Constructs a COO |
|
Constructs a CSR |
|
Constructs a sparse COO diagonal matrix from vector of diagonal elements. |
|
Constructs a sparse COO identity matrix. |
|
Sets all nonzero entries in a slice of a sparse COO tensor to a chosen value. |
|
Converts SciPy sparse COO/CSR arrays into PyTorch sparse tensors. |
|
Extracts diagonal from sparse COO matrix. |
|
Slices a sparse tensor. |
|
Computes the complement of a set of linear indices. |
|
Inverts elements of a diagonal COO matrix. |
Checks if tensor is either in sparse COO or CSR format. |
|
|
Checks which indices in two tensors apepar in both. |
|
Matrix-matrix product with support for sparse COO tensors. |
|
Elementwise product of two tensors with support for sparse COO tensors. |
|
Elementwise product of two sparse COO tensors. |
|
Converts a COO indices into a linear index corresponding to a strided layout. |
|
Repeats a sparse COO matrix along a diagonal to make a block-diagonal matrix. |
|
Returns a sparse COO tensor with the same data, but with the specified shape. |
|
Elementwise square of sparse tensors. |
|
Converts PyTorch sprase COO/CSR tensors into SciPy sparse arrays. |
|
Converts a linear index into COO indices. |
|
iskra.sparse_linalg#
|
|
|
|
|
|
|
Differentiable linear system. |
|
|
|
Matrix-free Conjugate Gradient solver for (I - J^T) u = b. |
|
|
|
|
|
Estimate spectral radius (max |evals|) of matrix J^T (given as callable f). |
|
|
|
Matrix-free GMRES solver for J^T u = b. |
|
|
|
|
|
|
|
|
|
|
|
|
|