Sparse tensors and JIT-compiled kernels in Python with a PyTorch-compatible API
// momentum
// why it's here
- Active: last commit today
- Built almost entirely by one person
- Health 65/100 with only 8 stars
// how to help
// readme
Installation Β· Quickstart Β· Formats Β· How it works Β· Performance Β· Documentation Β· Citation
Scorch generates, compiles and caches a C++ kernel for each sparse tensor
operation and each combination of operand storage formats. It works on ordinary
PyTorch tensors: under import scorch as torch, torch.matmul and torch.einsum
run on Scorch, and every other name is PyTorchβs own.
import scorch as torch # torch.matmul and torch.einsum now run on Scorch
dense = torch.rand(4096, 4096)
A = torch.where(dense < 0.01, dense, 0.0).to_sparse_csr() # a PyTorch CSR tensor, 1% nonzero
X = torch.rand(4096, 256)
Y = torch.matmul(A, X) # Scorch's CSR Γ dense kernel; Y is a torch.Tensor
Storage formats are part of the program. Each mode of a tensor is dense, compressed or coordinate, and Scorch compiles a kernel for the combination it is given: