Scorch is a Python library for sparse machine learning, built on top of PyTorch. It provides sparse implementations of key PyTorch operations, allowing you to work with sparse tensors seamlessly.
To get started with Scorch, follow these steps:
-
Clone the Scorch repository and change into the project directory:
git clone <repository-url> cd scorch
-
Create a new conda environment and install the required dependencies:
conda create -n scorch python=3.11 conda activate scorch pip install -r requirements.txt
-
Install Scorch and its dependencies:
pip install .
To use Scorch in your PyTorch projects, simply import it as follows:
import scorch as torchWith this import statement, you can use Scorch's sparse implementations of PyTorch operations. For example:
# Create sparse tensors
sparse_tensor1 = torch.sparse_coo_tensor(...)
sparse_tensor2 = torch.sparse_coo_tensor(...)
# Perform sparse matrix multiplication
result = torch.matmul(sparse_tensor1, sparse_tensor2)
# Perform sparse einsum operation
result = torch.einsum('ij,jk->ik', sparse_tensor1, sparse_tensor2)