PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations

Overview

PyTorch Sparse

PyPI Version Build Status Code Coverage


This package consists of a small extension library of optimized sparse matrix operations with autograd support. This package currently consists of the following methods:

All included operations work on varying data types and are implemented both for CPU and GPU. To avoid the hazzle of creating torch.sparse_coo_tensor, this package defines operations on sparse tensors by simply passing index and value tensors as arguments (with same shapes as defined in PyTorch). Note that only value comes with autograd support, as index is discrete and therefore not differentiable.

Installation

Binaries

We provide pip wheels for all major OS/PyTorch/CUDA combinations, see here.

PyTorch 1.8.0

To install the binaries for PyTorch 1.8.0, simply run

pip install torch-scatter torch-sparse -f https://pytorch-geometric.com/whl/torch-1.8.0+${CUDA}.html

where ${CUDA} should be replaced by either cpu, cu101, cu102, or cu111 depending on your PyTorch installation.

cpu cu101 cu102 cu111
Linux
Windows
macOS

PyTorch 1.7.0/1.7.1

To install the binaries for PyTorch 1.7.0 and 1.7.1, simply run

pip install torch-scatter torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+${CUDA}.html

where ${CUDA} should be replaced by either cpu, cu92, cu101, cu102, or cu110 depending on your PyTorch installation.

cpu cu92 cu101 cu102 cu110
Linux
Windows
macOS

Note: Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0 and PyTorch 1.6.0 (following the same procedure).

From source

Ensure that at least PyTorch 1.4.0 is installed and verify that cuda/bin and cuda/include are in your $PATH and $CPATH respectively, e.g.:

$ python -c "import torch; print(torch.__version__)"
>>> 1.4.0

$ echo $PATH
>>> /usr/local/cuda/bin:...

$ echo $CPATH
>>> /usr/local/cuda/include:...

If you want to additionally build torch-sparse with METIS support, e.g. for partioning, please download and install the METIS library by following the instructions in the Install.txt file. Note that METIS needs to be installed with 64 bit IDXTYPEWIDTH by changing include/metis.h. Afterwards, set the environment variable WITH_METIS=1.

Then run:

pip install torch-scatter torch-sparse

When running in a docker container without NVIDIA driver, PyTorch needs to evaluate the compute capabilities and may fail. In this case, ensure that the compute capabilities are set via TORCH_CUDA_ARCH_LIST, e.g.:

export TORCH_CUDA_ARCH_LIST="6.0 6.1 7.2+PTX 7.5+PTX"

Functions

Coalesce

torch_sparse.coalesce(index, value, m, n, op="add") -> (torch.LongTensor, torch.Tensor)

Row-wise sorts index and removes duplicate entries. Duplicate entries are removed by scattering them together. For scattering, any operation of torch_scatter can be used.

Parameters

  • index (LongTensor) - The index tensor of sparse matrix.
  • value (Tensor) - The value tensor of sparse matrix.
  • m (int) - The first dimension of corresponding dense matrix.
  • n (int) - The second dimension of corresponding dense matrix.
  • op (string, optional) - The scatter operation to use. (default: "add")

Returns

  • index (LongTensor) - The coalesced index tensor of sparse matrix.
  • value (Tensor) - The coalesced value tensor of sparse matrix.

Example

import torch
from torch_sparse import coalesce

index = torch.tensor([[1, 0, 1, 0, 2, 1],
                      [0, 1, 1, 1, 0, 0]])
value = torch.Tensor([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]])

index, value = coalesce(index, value, m=3, n=2)
print(index)
tensor([[0, 1, 1, 2],
        [1, 0, 1, 0]])
print(value)
tensor([[6.0, 8.0],
        [7.0, 9.0],
        [3.0, 4.0],
        [5.0, 6.0]])

Transpose

torch_sparse.transpose(index, value, m, n) -> (torch.LongTensor, torch.Tensor)

Transposes dimensions 0 and 1 of a sparse matrix.

Parameters

  • index (LongTensor) - The index tensor of sparse matrix.
  • value (Tensor) - The value tensor of sparse matrix.
  • m (int) - The first dimension of corresponding dense matrix.
  • n (int) - The second dimension of corresponding dense matrix.
  • coalesced (bool, optional) - If set to False, will not coalesce the output. (default: True)

Returns

  • index (LongTensor) - The transposed index tensor of sparse matrix.
  • value (Tensor) - The transposed value tensor of sparse matrix.

Example

import torch
from torch_sparse import transpose

index = torch.tensor([[1, 0, 1, 0, 2, 1],
                      [0, 1, 1, 1, 0, 0]])
value = torch.Tensor([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]])

index, value = transpose(index, value, 3, 2)
print(index)
tensor([[0, 0, 1, 1],
        [1, 2, 0, 1]])
print(value)
tensor([[7.0, 9.0],
        [5.0, 6.0],
        [6.0, 8.0],
        [3.0, 4.0]])

Sparse Dense Matrix Multiplication

torch_sparse.spmm(index, value, m, n, matrix) -> torch.Tensor

Matrix product of a sparse matrix with a dense matrix.

Parameters

  • index (LongTensor) - The index tensor of sparse matrix.
  • value (Tensor) - The value tensor of sparse matrix.
  • m (int) - The first dimension of corresponding dense matrix.
  • n (int) - The second dimension of corresponding dense matrix.
  • matrix (Tensor) - The dense matrix.

Returns

  • out (Tensor) - The dense output matrix.

Example

import torch
from torch_sparse import spmm

index = torch.tensor([[0, 0, 1, 2, 2],
                      [0, 2, 1, 0, 1]])
value = torch.Tensor([1, 2, 4, 1, 3])
matrix = torch.Tensor([[1, 4], [2, 5], [3, 6]])

out = spmm(index, value, 3, 3, matrix)
print(out)
tensor([[7.0, 16.0],
        [8.0, 20.0],
        [7.0, 19.0]])

Sparse Sparse Matrix Multiplication

torch_sparse.spspmm(indexA, valueA, indexB, valueB, m, k, n) -> (torch.LongTensor, torch.Tensor)

Matrix product of two sparse tensors. Both input sparse matrices need to be coalesced (use the coalesced attribute to force).

Parameters

  • indexA (LongTensor) - The index tensor of first sparse matrix.
  • valueA (Tensor) - The value tensor of first sparse matrix.
  • indexB (LongTensor) - The index tensor of second sparse matrix.
  • valueB (Tensor) - The value tensor of second sparse matrix.
  • m (int) - The first dimension of first corresponding dense matrix.
  • k (int) - The second dimension of first corresponding dense matrix and first dimension of second corresponding dense matrix.
  • n (int) - The second dimension of second corresponding dense matrix.
  • coalesced (bool, optional): If set to True, will coalesce both input sparse matrices. (default: False)

Returns

  • index (LongTensor) - The output index tensor of sparse matrix.
  • value (Tensor) - The output value tensor of sparse matrix.

Example

import torch
from torch_sparse import spspmm

indexA = torch.tensor([[0, 0, 1, 2, 2], [1, 2, 0, 0, 1]])
valueA = torch.Tensor([1, 2, 3, 4, 5])

indexB = torch.tensor([[0, 2], [1, 0]])
valueB = torch.Tensor([2, 4])

indexC, valueC = spspmm(indexA, valueA, indexB, valueB, 3, 3, 2)
print(indexC)
tensor([[0, 1, 2],
        [0, 1, 1]])
print(valueC)
tensor([8.0, 6.0, 8.0])

C++ API

torch-sparse also offers a C++ API that contains C++ equivalent of python models.

mkdir build
cd build
# Add -DWITH_CUDA=on support for the CUDA if needed
cmake ..
make
make install

Running tests

python setup.py test
Comments
  • undefined symbol: cusparseScsrgemm

    undefined symbol: cusparseScsrgemm

    Hi,

    I'm trying to get the torch-geometry package to work and everything installs just fine.

    But I'm getting following error during import from torch_sparse:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/philipp/.local/share/virtualenvs/pytorch_geometric-4vUoAfdD/lib/python3.6/site-packages/torch_sparse/__init__.py", line 4, in <module>
        from .spspmm import spspmm
      File "/home/philipp/.local/share/virtualenvs/pytorch_geometric-4vUoAfdD/lib/python3.6/site-packages/torch_sparse/spspmm.py", line 7, in <module>
        import spspmm_cuda
    ImportError: /home/philipp/.local/share/virtualenvs/pytorch_geometric-4vUoAfdD/lib/python3.6/site-packages/spspmm_cuda.cpython-36m-x86_64-linux-gnu.so: undefined symbol: cusparseScsrgemm
    

    For me that can be reproduced with:

    #!/bin/bash
    pipenv --python 3.6
    export PATH=/opt/cuda/bin:$PATH
    export CPATH=/opt/cuda/include
    pipenv install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-linux_x86_64.whl
    pipenv install torchvision
    pipenv install cffi
    pipenv install torch-scatter
    pipenv install torch-sparse
    # pipenv install torch-cluster
    # pipenv install torch-spline-conv
    # pipenv install torch-geometric
    pipenv run python -c "from torch_sparse import spmm"
    

    More info:

    $ pipenv run python -c "import torch; print(torch.__version__)"
    0.4.1
    

    I'm not sure if this is a problem on my side or not. Would appreciate your help.

    opened by phi-go 34
  • Different CUDA versions than PyTorch

    Different CUDA versions than PyTorch

    I'm trying to run PyTorch Geometric in google colab, and I installed all needed libraries using:

    !pip install --upgrade torch-scatter
    !pip install --upgrade torch-sparse
    !pip install --upgrade torch-cluster
    !pip install --upgrade torch-spline-conv 
    !pip install torch-geometric
    

    but I got this error:

    RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions. PyTorch has CUDA version 10.1 and torch_sparse has CUDA version 10.0. Please reinstall the torch_sparse that matches your PyTorch install.

    I tried to search and I found this suggested solution, but it didn't work for me:

    !pip install torch-scatter==latest+cu101 torch-sparse==latest+cu101 -f https://s3.eu-central-1.amazonaws.com/pytorch-geometric.com/whl/torch-1.4.0.html

    Any help, please!

    opened by SaraAlthubaiti 23
  • RuntimeError: CUDA error: an illegal memory access was encountered

    RuntimeError: CUDA error: an illegal memory access was encountered

      File "examples/sem_seg_sparse/train.py", line 142, in <module>
        main()
      File "examples/sem_seg_sparse/train.py", line 61, in main
        train(model, train_loader, optimizer, scheduler, criterion, opt)
      File "examples/sem_seg_sparse/train.py", line 79, in train
        out = model(data)
      File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in __call__
        result = self.forward(*input, **kwargs)
      File "/content/drive/My Drive/deep_gcns_torch/examples/sem_seg_sparse/architecture.py", line 69, in forward
        feats.append(self.gunet(feats[-1],edge_index=edge_index ,batch=batch))
      File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in __call__
        result = self.forward(*input, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/torch_geometric/nn/models/graph_unet.py", line 83, in forward
        x.size(0))
      File "/usr/local/lib/python3.6/dist-packages/torch_geometric/nn/models/graph_unet.py", line 120, in augment_adj
        num_nodes)
      File "/usr/local/lib/python3.6/dist-packages/torch_sparse/spspmm.py", line 30, in spspmm
        C = matmul(A, B)
      File "/usr/local/lib/python3.6/dist-packages/torch_sparse/matmul.py", line 107, in matmul
        return spspmm(src, other, reduce)
      File "/usr/local/lib/python3.6/dist-packages/torch_sparse/matmul.py", line 95, in spspmm
        return spspmm_sum(src, other)
      File "/usr/local/lib/python3.6/dist-packages/torch_sparse/matmul.py", line 83, in spspmm_sum
        rowptrA, colA, valueA, rowptrB, colB, valueB, K)
    RuntimeError: CUDA error: an illegal memory access was encountered (launch_kernel at /pytorch/aten/src/ATen/native/cuda/Loops.cuh:103)
    

    hi, i'm intergrating the GraphU-Net and other model on the google colab, but there are some bug , could you help me ? thanks.

    stale 
    opened by quqxui 20
  • type problems reproducing spspmm example from readme

    type problems reproducing spspmm example from readme

    from torch_sparse import spspmm

    indexA = torch.tensor([[0, 0, 1, 2, 2], [1, 2, 0, 0, 1]]) valueA = torch.tensor([1, 2, 3, 4, 5], dtype=torch.float)

    indexB = torch.tensor([[0, 2], [1, 0]]) valueB = torch.tensor([2, 4], dtype=torch.float) indexC, valueC = spspmm(indexA, valueA, indexB, valueB, 3, 3, 2) Traceback (most recent call last): File "", line 1, in File "C:\ProgramData\Anaconda3\lib\site-packages\torch_sparse\spspmm.py", line 26, in spspmm return SpSpMM.apply(indexA, valueA, indexB, valueB, m, k, n) File "C:\ProgramData\Anaconda3\lib\site-packages\torch_sparse\spspmm.py", line 32, in forward indexC, valueC = mm(indexA, valueA, indexB, valueB, m, k, n) File "C:\ProgramData\Anaconda3\lib\site-packages\torch_sparse\spspmm.py", line 68, in mm indexC, valueC = from_scipy(A.tocsr().dot(B.tocsr()).tocoo()) File "C:\ProgramData\Anaconda3\lib\site-packages\torch_sparse\spspmm.py", line 79, in from_scipy row, col, value = from_numpy(A.row), from_numpy(A.col), from_numpy(A.data) TypeError: can't convert np.ndarray of type numpy.int32. The only supported types are: double, float, float16, int64, int32, and uint8.

    (Windows 10 CPU-only PyTorch installation.)

    The other examples from README work ok, except that "coalesce" transposes value:

    from torch_sparse import coalesce

    index = torch.tensor([[1, 0, 1, 0, 2, 1], ... [0, 1, 1, 1, 0, 0]]) value = torch.tensor([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) index, value = coalesce(index, value, m=3, n=2) index tensor([[0, 1, 1, 2], [1, 0, 1, 0]]) value tensor([[6, 8], [7, 9], [3, 4], [5, 6]])

    opened by anhinga 19
  • How to install  torch-sparse  0.4.3 on google colab ?

    How to install torch-sparse 0.4.3 on google colab ?

    Hi, I developed my model with the environment blow: torch==1.4.0 numpy==1.18.1 torch_scatter==1.4.0 torch_sparse==0.4.3 torch_cluster==1.4.5 torch_geometric==1.3.2 but i can't install torch-sparse==0.4.3 I try this commands : !pip install torch-sparse==0.4.3 !pip install /content/pytorch_sparse-0.4.3.tar.gz !pip install --verbose torch-sparse==0.4.3

    error: Processing ./pytorch_sparse-0.4.3.tar.gz Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from torch-sparse==0.4.3) (1.4.1) Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/dist-packages (from scipy->torch-sparse==0.4.3) (1.18.1) Building wheels for collected packages: torch-sparse Building wheel for torch-sparse (setup.py) ... error ERROR: Failed building wheel for torch-sparse Running setup.py clean for torch-sparse Failed to build torch-sparse Installing collected packages: torch-sparse Running setup.py install for torch-sparse ... error ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ihjhbd7q/setup.py'"'"'; file='"'"'/tmp/pip-req-build-ihjhbd7q/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-c1qmqj51/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/torch-sparse Check the logs for full command output. Processing ./pytorch_scatter-1.4.0.tar.gz

    stale 
    opened by Issam-dz1 18
  • Issue importing torch_sparse

    Issue importing torch_sparse

    I'm getting an error when importing torch_sparse. I have done a fresh installation of torch, with version 1.4.0. This is in order to get torch_geometric up to date. But I'm running into an error here:

    >>> import torch_sparse
    Traceback (most recent call last):
      File "/global/homes/d/danieltm/.local/cori/pytorchv1.4.0-gpu/lib/python3.7/site-packages/torch_sparse/__init__.py", line 14, in <module>
        library, [osp.dirname(__file__)]).origin)
      File "/global/homes/d/danieltm/.local/cori/pytorchv1.4.0-gpu/lib/python3.7/site-packages/torch/_ops.py", line 106, in load_library
        ctypes.CDLL(path)
      File "/usr/common/software/pytorch/v1.4.0-gpu/lib/python3.7/ctypes/__init__.py", line 364, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: /global/u2/d/danieltm/.local/cori/pytorchv1.4.0-gpu/lib/python3.7/site-packages/torch_sparse/_version.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/global/homes/d/danieltm/.local/cori/pytorchv1.4.0-gpu/lib/python3.7/site-packages/torch_sparse/__init__.py", line 22, in <module>
        raise OSError(e)
    OSError: /global/u2/d/danieltm/.local/cori/pytorchv1.4.0-gpu/lib/python3.7/site-packages/torch_sparse/_version.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
    

    Do you know what this issue is related to?

    opened by murnanedaniel 17
  • Segmentation fault in GPU sparse matrix by sparse matrix product

    Segmentation fault in GPU sparse matrix by sparse matrix product

    Hello! Thanks a lot for this PyTorch extension! But I faced with the following issue. I tried to run an example of sparse matrix by sparse matrix product from README.md, but on GPU, and get "Segmentation fault" error. Below is the code of my short script to reproduce error.

    import torch
    from torch_sparse import spspmm
    device = torch.device("cuda")
    
    indexA = torch.tensor([[0, 0, 1, 2, 2], [1, 2, 0, 0, 1]], device=device)
    valueA = torch.tensor([1, 2, 3, 4, 5], dtype=torch.float, device=device)
    
    indexB = torch.tensor([[0, 2], [1, 0]], device=device)
    valueB = torch.tensor([2, 4], dtype=torch.float, device=device)
    
    indexC, valueC = spspmm(indexA, valueA, indexB, valueB, 3, 3, 2)
    

    I use PyTorch 1.0, CUDA 8.0 and install both extensions (pytorch_scatter and pytorch_sparse) from source files in repositories.

    stale 
    opened by amkatrutsa 17
  • osx cpu only version fails with missing native library: symbol not found

    osx cpu only version fails with missing native library: symbol not found

    https://stackoverflow.com/questions/67455890/pytorch-cpu-only-on-osx-fails-with-symbol-not-found

    I am trying to get started with PyTorch - on a mac osx computer. However, basic steps fail:

        from torch_sparse import coalesce, SparseTensor
        
        ---------------------------------------------------------------------------
        OSError                                   Traceback (most recent call last)
        <ipython-input-1-dad8246d5249> in <module>
        ----> 1 from torch_sparse import coalesce, SparseTensor
        
        /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/__init__.py in <module>
             10         '_saint', '_padding'
             11 ]:
        ---> 12     torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
             13         library, [osp.dirname(__file__)]).origin)
             14 
        
        /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch/_ops.py in load_library(self, path)
            102             # static (global) initialization code in order to register custom
            103             # operators with the JIT.
        --> 104             ctypes.CDLL(path)
            105         self.loaded_libraries.add(path)
            106 
        
        /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
            371 
            372         if handle is None:
        --> 373             self._handle = _dlopen(self._name, mode)
            374         else:
            375             self._handle = handle
        
        OSError: dlopen(/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so, 6): Symbol not found: __ZN3c105ErrorC1ENS_14SourceLocationERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
          Referenced from: /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so
          Expected in: flat namespace
         in /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so
    
    

    I am using a conda environment of:

        name: my_conda_env
        channels:
          - pytorch
          - conda-forge
          - defaults
        dependencies:
          - python>=3.8
          - pytorch
          - pytorch_geometric
    
    

    and instantiated it using:

    conda env create --force -f environment.yml

    stale 
    opened by geoHeil 16
  • How to use older version of torch-sparse

    How to use older version of torch-sparse

    Hi, Matthias Fey I developed my model with the environment blow: torch==1.2.0 torchvision==0.4.0 torch-scatter==1.3.1 torch-sparse==0.4.0 torch-cluster==1.4.4 torch-spline-conv==1.1.0 torch-geometric==1.3.2

    However, I can not install the torch-sparse==0.4.0 recently. I try to install it with the command below on Google Colab. !pip install torch-sparse==0.4.0

    But I get the error: Collecting torch-sparse==0.4.0 Downloading https://files.pythonhosted.org/packages/b0/0a/2ff678e0d04e524dd2cf990a6202ced8c0ffe3fe6b08e02f25cc9fd27da0/torch_sparse-0.4.0.tar.gz Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from torch-sparse==0.4.0) (1.4.1) Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/dist-packages (from scipy->torch-sparse==0.4.0) (1.19.5) Building wheels for collected packages: torch-sparse Building wheel for torch-sparse (setup.py) ... error ERROR: Failed building wheel for torch-sparse Running setup.py clean for torch-sparse Failed to build torch-sparse Installing collected packages: torch-sparse Running setup.py install for torch-sparse ... error ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b1e5_349/torch-sparse/setup.py'"'"'; file='"'"'/tmp/pip-install-b1e5_349/torch-sparse/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-l1bp7fw3/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

    I really need the older version because my code could not run successfully with the new version.

    Thank you for your kind help.

    Best, Yi Han

    stale 
    opened by HelloYiHan 16
  • Can SpSpMM back propagation be improved?

    Can SpSpMM back propagation be improved?

    Not a bug but I am seeing a decrease in performance in the backpropagation when I changed from dense representation to sparse matrices using pytorch_sparse. After profiling using torch.utils.bottleneck, I see something like the following on a single machine. I wonder if SpSpMM backprop could be improved for performance.

     ncalls  tottime  percall  cumtime  percall filename:lineno(function)
           28   56.723    2.026   56.723    2.026 {method 'run_backward' of 'torch._C._EngineBase' objects}
          576    2.685    0.005    2.685    0.005 {built-in method _unique}
         1408    2.349    0.002    2.349    0.002 {method 'scatter_add_' of 'torch._C._TensorBase' objects}
          832    1.252    0.002    4.078    0.005 /anaconda3/envs/hep/lib/python3.6/site-packages/torch_sparse/spmm.py:4(spmm)
         1280    0.760    0.001    0.760    0.001 {built-in method cat}
          448    0.720    0.002    0.720    0.002 {built-in method tanh}
         1408    0.449    0.000    0.449    0.000 {method 'new_full' of 'torch._C._TensorBase' objects}
          608    0.263    0.000    0.263    0.000 {method 'matmul' of 'torch._C._TensorBase' objects}
          128    0.199    0.002    0.199    0.002 {built-in method tensor}
          576    0.111    0.000    2.900    0.005 /anaconda3/envs/hep/lib/python3.6/site-packages/torch_sparse/coalesce.py:7(coalesce)
         1536    0.069    0.000    0.069    0.000 {built-in method stack}
          608    0.060    0.000    0.330    0.001 /anaconda3/envs/hep/lib/python3.6/site-packages/torch/nn/functional.py:1336(linear)
         1472    0.058    0.000    0.058    0.000 {method 'read' of '_io.BufferedReader' objects}
      1856/32    0.044    0.000    9.348    0.292 /anaconda3/envs/hep/lib/python3.6/site-packages/torch/nn/modules/module.py:483(__call__)
         3458    0.040    0.000    0.040    0.000 {method 'reduce' of 'numpy.ufunc' objects}
    
    

    You can see the majority of the backprop comes from SpSpMM as shown below.

    ------------------  ---------------  ---------------  ---------------  ---------------  ---------------
    Name                       CPU time        CUDA time            Calls        CPU total       CUDA total
    ------------------  ---------------  ---------------  ---------------  ---------------  ---------------
    SpSpMMBackward         359986.000us          0.000us                1     359986.000us          0.000us
    SpSpMMBackward         355614.000us          0.000us                1     355614.000us          0.000us
    SpSpMMBackward         346439.000us          0.000us                1     346439.000us          0.000us
    SpSpMMBackward         330789.000us          0.000us                1     330789.000us          0.000us
    SpSpMMBackward         318372.000us          0.000us                1     318372.000us          0.000us
    SpSpMMBackward         314331.000us          0.000us                1     314331.000us          0.000us
    SpSpMMBackward         304800.000us          0.000us                1     304800.000us          0.000us
    SpSpMMBackward         304651.000us          0.000us                1     304651.000us          0.000us
    SpSpMMBackward         302225.000us          0.000us                1     302225.000us          0.000us
    SpSpMMBackward         299735.000us          0.000us                1     299735.000us          0.000us
    SpSpMMBackward         299507.000us          0.000us                1     299507.000us          0.000us
    SpSpMMBackward         298172.000us          0.000us                1     298172.000us          0.000us
    SpSpMMBackward         298137.000us          0.000us                1     298137.000us          0.000us
    SpSpMMBackward         297997.000us          0.000us                1     297997.000us          0.000us
    SpSpMMBackward         297528.000us          0.000us                1     297528.000us          0.000us
    
    opened by esaliya 15
  • How to add an element to the diagonal

    How to add an element to the diagonal

    Hi,

    I want to add a constant to the diagonal of a sparse matrix. Looking at GCNConv, I assume this is what SparseTensor.fill_diag does (it would be great if methods were documented). With

    import torch
    from torch_sparse import SparseTensor
     
    col = torch.tensor([1,1,5,0]).type(torch.long)
    row = torch.tensor([2,5,3,0]).type(torch.long)
    adj = SparseTensor(col=col, row=row)
    A = adj.to_dense()
    print(A)
    
    

    I got as expected

    tensor([[1., 0., 0., 0., 0., 0.],
            [0., 0., 0., 0., 0., 0.],
            [0., 1., 0., 0., 0., 0.],
            [0., 0., 0., 0., 0., 1.],
            [0., 0., 0., 0., 0., 0.],
            [0., 1., 0., 0., 0., 0.]])
    

    Further

    adj = SparseTensor.fill_diag(adj, 4.)
    print(adj.to_dense())
    

    returns

    tensor([[1., 0., 0., 0., 0., 0.],
            [0., 1., 0., 0., 0., 0.],
            [0., 1., 1., 0., 0., 0.],
            [0., 0., 0., 1., 0., 1.],
            [0., 0., 0., 0., 1., 0.],
            [0., 1., 0., 0., 0., 1.]])
    
    

    So, the diagonal is filled with 1s, instead of 4s. What is wrong with my code? Thanks for any help.

    stale 
    opened by ldv1 14
  • `SparseTensor.to_symmetric()` inplace operation

    `SparseTensor.to_symmetric()` inplace operation

    Hi,

    thanks a lot for your work on torch_sparse! I have encountered the following error when computing gradients on the values of SparseTensor when it has previously been transformed with .to_symmetric(). I do not think this is intended as casting to a symmetric matrix should be a differentiable operation?

    I was able to construct the following minimal example:

    import torch
    import torch_sparse
    
    torch.manual_seed(0)
    test_tensor = (torch.randn(5, 5) < 0.1).float()
    test_tensor_sparse = torch_sparse.SparseTensor.from_dense(test_tensor)
    test_tensor_sparse.requires_grad_()
    test_tensor_sparse = test_tensor_sparse.to_symmetric()
    loss = test_tensor_sparse.mean()
    loss.backward()
    

    Error:

    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    /tmp/ipykernel_3483971/1228083090.py in <module>
          8 test_tensor_sparse = test_tensor_sparse.to_symmetric()
          9 loss = test_tensor_sparse.mean()
    ---> 10 loss.backward()
    
    ~/miniconda3/envs/molgen/lib/python3.7/site-packages/torch/_tensor.py in backward(self, gradient, retain_graph, create_graph, inputs)
        394                 create_graph=create_graph,
        395                 inputs=inputs)
    --> 396         torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
        397 
        398     def register_hook(self, hook):
    
    ~/miniconda3/envs/molgen/lib/python3.7/site-packages/torch/autograd/__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables, inputs)
        173     Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
        174         tensors, grad_tensors_, retain_graph, create_graph, inputs,
    --> 175         allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
        176 
        177 def grad(
    
    RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.LongTensor [30]] is at version 3; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
    

    When setting torch.autograd.set_detect_anomaly(True):

    ...
     File "/nfs/homedirs/sommer/miniconda3/envs/molgen/lib/python3.7/site-packages/torch_sparse/tensor.py", line 373, in to_symmetric
        value = torch.cat([value, value])[perm]
     (Triggered internally at  /opt/conda/conda-bld/pytorch_1659484809535/work/torch/csrc/autograd/python_anomaly_mode.cpp:102.)
      allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
    

    This happens with the following specifications:

    python: 3.7.13
    torch: 1.12.1 
    torch_sparse: 0.6.15
    

    I hope this is helpful, let me know if you need more information or if I can help. Thanks!

    opened by johannaSommer 0
  • Can I use sparsetensor as a nn.Parameter and move it to device?

    Can I use sparsetensor as a nn.Parameter and move it to device?

    Hi there,

    I was looking at this thread and see that we can use sparse matrix as a nn.Parameter. However, I wasnt sure on how to move it to the device since only the values move to cuda when I use .to(device), while the sparsetensor stayed at the cpu. Thanks!

    https://github.com/rusty1s/pytorch_sparse/issues/151

    opened by Chengwei94 1
  • error on MAC M1

    error on MAC M1

    Hi, I am trying to install PyTorch geometric on MAC M1 12.6, but I'm getting error to install pytorch_sparse. I copied some of the errors below. Can someone point me in the right direction?

    @wmeb-4c7 pytorch_sparse % python setup.py install     
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    Compiling without OpenMP...
    running install
    running bdist_egg
    running egg_info
    writing torch_sparse.egg-info/PKG-INFO
    writing dependency_links to torch_sparse.egg-info/dependency_links.txt
    writing requirements to torch_sparse.egg-info/requires.txt
    writing top-level names to torch_sparse.egg-info/top_level.txt
    reading manifest file 'torch_sparse.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: manifest_maker: MANIFEST.in, line 5: unknown action 'recursive'
    
    adding license file 'LICENSE'
    writing manifest file 'torch_sparse.egg-info/SOURCES.txt'
    installing library code to build/bdist.macosx-10.9-universal2/egg
    running install_lib
    running build_py
    running build_ext
    building 'torch_sparse._spspmm_cpu' extension
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -g -DWITH_PYTHON -Icsrc -Ithird_party/parallel-hashmap -I/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include -I/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/TH -I/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/THC -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c csrc/cpu/spspmm_cpu.cpp -o build/temp.macosx-10.9-universal2-3.10/csrc/cpu/spspmm_cpu.o -O2 -Wno-sign-compare -arch arm64 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_clang" -DPYBIND11_STDLIB="_libcpp" -DPYBIND11_BUILD_ABI="_cxxabi1002" -DTORCH_EXTENSION_NAME=_spspmm_cpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    In file included from csrc/cpu/spspmm_cpu.cpp:1:
    In file included from csrc/cpu/spspmm_cpu.h:3:
    In file included from csrc/cpu/../extensions.h:2:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/autograd.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/variable.h:6:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/Tensor.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/Tensor.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/TensorBody.h:18:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:4:
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:535:13: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                C10_IS_TRIVIALLY_COPYABLE(T) &&
                ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    In file included from csrc/cpu/spspmm_cpu.cpp:1:
    In file included from csrc/cpu/spspmm_cpu.h:3:
    In file included from csrc/cpu/../extensions.h:2:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/autograd.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/variable.h:6:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/Tensor.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/Tensor.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/TensorBody.h:18:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:4:
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:535:13: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:553:26: note: in instantiation of template type alias 'OptionalBase' requested here
    class optional : private OptionalBase<T> {
                             ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    In file included from csrc/cpu/spspmm_cpu.cpp:1:
    In file included from csrc/cpu/spspmm_cpu.h:3:
    In file included from csrc/cpu/../extensions.h:2:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/autograd.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/variable.h:6:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/Tensor.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/Tensor.h:3:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/TensorBody.h:18:
    In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:4:
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:587:12: note: in instantiation of template type alias 'OptionalBase' requested here
        return OptionalBase<T>::initialized();
               ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:590:27: note: in instantiation of template type alias 'OptionalBase' requested here
        return std::addressof(OptionalBase<T>::storage_.value_);
                              ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:593:38: note: in instantiation of template type alias 'OptionalBase' requested here
        return detail_::static_addressof(OptionalBase<T>::storage_.value_);
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:597:12: note: in instantiation of template type alias 'OptionalBase' requested here
        return OptionalBase<T>::storage_.value_;
               ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:600:22: note: in instantiation of template type alias 'OptionalBase' requested here
        return std::move(OptionalBase<T>::storage_.value_);
                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:603:12: note: in instantiation of template type alias 'OptionalBase' requested here
        return OptionalBase<T>::storage_.value_;
               ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:609:5: note: in instantiation of template type alias 'OptionalBase' requested here
        OptionalBase<T>::setInitialized(false);
        ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:617:5: note: in instantiation of template type alias 'OptionalBase' requested here
        OptionalBase<T>::setInitialized(true);
        ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:625:5: note: in instantiation of template type alias 'OptionalBase' requested here
        OptionalBase<T>::setInitialized(true);
        ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:632:35: note: in instantiation of template type alias 'OptionalBase' requested here
      constexpr optional() noexcept : OptionalBase<T>(){};
                                      ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:633:44: note: in instantiation of template type alias 'OptionalBase' requested here
      constexpr optional(nullopt_t) noexcept : OptionalBase<T>(){};
                                               ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:651:31: note: in instantiation of template type alias 'OptionalBase' requested here
      constexpr optional(U&& u) : OptionalBase<T>(std::forward<U>(u)) {}
                                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:661:40: note: in instantiation of template type alias 'OptionalBase' requested here
      explicit constexpr optional(U&& u) : OptionalBase<T>(std::forward<U>(u)) {}
                                           ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:665:9: note: in instantiation of template type alias 'OptionalBase' requested here
          : OptionalBase<T>(in_place_t{}, constexpr_forward<Args>(args)...) {}
            ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                  C10_IS_TRIVIALLY_COPYABLE(U) &&
                  ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:675:9: note: in instantiation of template type alias 'OptionalBase' requested here
          : OptionalBase<T>(in_place_t{}, il, constexpr_forward<Args>(args)...) {}
            ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:535:13: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                C10_IS_TRIVIALLY_COPYABLE(T) &&
                ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
    #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                         ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:553:26: note: in instantiation of template type alias 'OptionalBase' requested here
    class optional : private OptionalBase<T> {
                             ^
    /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:30:40: note: in instantiation of template class 'c10::optional<c10::ScalarType>' requested here
    static inline optional<at::ScalarType> optTypeMetaToScalarType(
    
    
    .
    .
    .
    
    
        /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
          #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                               ^
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:617:5: note: in instantiation of template type alias 'OptionalBase' requested here
              OptionalBase<T>::setInitialized(true);
              ^
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:701:7: note: in instantiation of function template specialization 'c10::optional<at::Tensor>::initialize<at::Tensor>' requested here
                initialize(std::forward<U>(v));
                ^
          csrc/cpu/spspmm_cpu.cpp:35:21: note: in instantiation of function template specialization 'c10::optional<at::Tensor>::operator=<at::Tensor>' requested here
              optional_valueA =
                              ^
          In file included from csrc/cpu/spspmm_cpu.cpp:1:
          In file included from csrc/cpu/spspmm_cpu.h:3:
          In file included from csrc/cpu/../extensions.h:2:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/torch.h:3:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/autograd.h:3:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/variable.h:6:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/Tensor.h:3:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/Tensor.h:3:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/ATen/core/TensorBody.h:18:
          In file included from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/core/ScalarTypeToTypeMeta.h:4:
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:560:15: warning: builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead [-Wdeprecated-builtins]
                        C10_IS_TRIVIALLY_COPYABLE(U) &&
                        ^
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/macros/Macros.h:414:38: note: expanded from macro 'C10_IS_TRIVIALLY_COPYABLE'
          #define C10_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)
                                               ^
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:590:27: note: in instantiation of template type alias 'OptionalBase' requested here
              return std::addressof(OptionalBase<T>::storage_.value_);
                                    ^
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:616:31: note: in instantiation of member function 'c10::optional<at::Tensor>::dataptr' requested here
              ::new (static_cast<void*>(dataptr())) T(std::forward<Args>(args)...);
                                        ^
          /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/torch/include/c10/util/Optional.h:701:7: note: in instantiation of function template specialization 'c10::optional<at::Tensor>::initialize<at::Tensor>' requested here
                initialize(std::forward<U>(v));
                ^
          csrc/cpu/spspmm_cpu.cpp:35:21: note: in instantiation of function template specialization 'c10::optional<at::Tensor>::operator=<at::Tensor>' requested here
              optional_valueA =
                              ^
          518 warnings and 1 error generated.
          error: command '/opt/homebrew/opt/llvm/bin/clang' failed with exit code 1
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: legacy-install-failure
    
    × Encountered error while trying to install package.
    ╰─> torch-sparse
    
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for output from the failure.
    
    opened by nkarisan 7
  • Segmentation fault when importing torch-sparse (installing pytorch-geometric)

    Segmentation fault when importing torch-sparse (installing pytorch-geometric)

    I am trying to install pytorch-geometric for a deep-learning project. Torch-sparse is throwing segmentation faults when I attempt to import it (see below). Initially I tried different versions of each required library, as I thought it might be a GPU issue, but I've since tried to simplify by installing cpu-only versions.

    Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
    [GCC 7.5.0] :: Anaconda, Inc. on linux
    >>>import torch
    >>>import torch_scatter
    >>>import torch_cluster
    >>>import torch_sparse
    
    Segmentation fault (core dumped)
    

    And the same issue, presumably due to torch_sparse, when importing pytorch_geometric:

    Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
    [GCC 7.5.0] :: Anaconda, Inc. on linux
    >>>import torch_geometric
    
    Segmentation fault (core dumped)
    

    I'm on an Ubuntu distribution:

    Distributor ID:	Ubuntu
    Description:	Ubuntu 22.04.1 LTS
    Release:	22.04
    Codename:	jammy
    

    Here's my (lightweight for DL) conda installs:

    # Name                    Version                   Build  Channel
    _libgcc_mutex             0.1                        main  
    _openmp_mutex             5.1                       1_gnu  
    blas                      1.0                         mkl  
    brotlipy                  0.7.0           py310h7f8727e_1002  
    bzip2                     1.0.8                h7b6447c_0  
    ca-certificates           2022.07.19           h06a4308_0  
    certifi                   2022.9.24       py310h06a4308_0  
    cffi                      1.15.1          py310h74dc2b5_0  
    charset-normalizer        2.0.4              pyhd3eb1b0_0  
    cpuonly                   2.0                           0    pytorch
    cryptography              37.0.1          py310h9ce1e76_0  
    fftw                      3.3.9                h27cfd23_1  
    idna                      3.4             py310h06a4308_0  
    intel-openmp              2021.4.0          h06a4308_3561  
    jinja2                    3.0.3              pyhd3eb1b0_0  
    joblib                    1.1.1           py310h06a4308_0  
    ld_impl_linux-64          2.38                 h1181459_1  
    libffi                    3.3                  he6710b0_2  
    libgcc-ng                 11.2.0               h1234567_1  
    libgfortran-ng            11.2.0               h00389a5_1  
    libgfortran5              11.2.0               h1234567_1  
    libgomp                   11.2.0               h1234567_1  
    libstdcxx-ng              11.2.0               h1234567_1  
    libuuid                   1.0.3                h7f8727e_2  
    markupsafe                2.1.1           py310h7f8727e_0  
    mkl                       2021.4.0           h06a4308_640  
    mkl-service               2.4.0           py310h7f8727e_0  
    mkl_fft                   1.3.1           py310hd6ae3a3_0  
    mkl_random                1.2.2           py310h00e6091_0  
    ncurses                   6.3                  h5eee18b_3  
    numpy                     1.23.3          py310hd5efca6_0  
    numpy-base                1.23.3          py310h8e6c178_0  
    openssl                   1.1.1q               h7f8727e_0  
    pip                       22.2.2          py310h06a4308_0  
    pycparser                 2.21               pyhd3eb1b0_0  
    pyg                       2.1.0           py310_torch_1.12.0_cpu    pyg
    pyopenssl                 22.0.0             pyhd3eb1b0_0  
    pyparsing                 3.0.9           py310h06a4308_0  
    pysocks                   1.7.1           py310h06a4308_0  
    python                    3.10.6               haa1d7c7_0  
    pytorch                   1.12.1             py3.10_cpu_0    pytorch
    pytorch-cluster           1.6.0           py310_torch_1.12.0_cpu    pyg
    pytorch-mutex             1.0                         cpu    pytorch
    pytorch-scatter           2.0.9           py310_torch_1.12.0_cpu    pyg
    pytorch-sparse            0.6.15          py310_torch_1.12.0_cpu    pyg
    readline                  8.1.2                h7f8727e_1  
    requests                  2.28.1          py310h06a4308_0  
    scikit-learn              1.1.2           py310h6a678d5_0  
    scipy                     1.9.1           py310hd5efca6_0  
    setuptools                63.4.1          py310h06a4308_0  
    six                       1.16.0             pyhd3eb1b0_1  
    sqlite                    3.39.3               h5082296_0  
    threadpoolctl             2.2.0              pyh0d69192_0  
    tk                        8.6.12               h1ccaba5_0  
    tqdm                      4.64.1          py310h06a4308_0  
    typing_extensions         4.3.0           py310h06a4308_0  
    tzdata                    2022e                h04d1e81_0  
    urllib3                   1.26.12         py310h06a4308_0  
    wheel                     0.37.1             pyhd3eb1b0_0  
    xz                        5.2.6                h5eee18b_0  
    zlib                      1.2.13               h5eee18b_0  
    

    Any help would be greatly appreciated!

    opened by neutralpronoun 2
  • [Question] where does `torch.ops.torch_sparse` come from?

    [Question] where does `torch.ops.torch_sparse` come from?

    Trying to dive into how sparse-sparse matrix multiplication is working but I can't figure out where this import comes from, if I try importing it in a notebook with torch and torch_sparse imported I get an import error, but I see it's used in the source code of matmul.py. Where does this come from?

    opened by q-aaronzolnailucas 2
  • OSError: [WinError 127] The specified procedure could not be found.

    OSError: [WinError 127] The specified procedure could not be found.

    While I was trying to pip install the pytorch_sparse by running the following command: pip install torch-sparse -f https://data.pyg.org/whl/torch-1.12.1+$cu113.html

    I got this error:

    error: subprocess-exited-with-error
    
      × python setup.py egg_info did not run successfully.
      │ exit code: 1
      ╰─> [8 lines of output]
          Traceback (most recent call last):
            File "<string>", line 2, in <module>
            File "<pip-setuptools-caller>", line 34, in <module>
            File "C:\Users\yihe\AppData\Local\Temp\pip-install-5rbdjmni\torch-sparse_72b0544df5b746a5a7fcfeb44fba647e\setup.py", line 8, in <module>
              import torch
            File "C:\Users\yihe\anaconda3\envs\PPI_GNN_seqvec_v6\lib\site-packages\torch\__init__.py", line 129, in <module>
              raise err
          OSError: [WinError 127] The specified procedure could not be found. Error loading "C:\Users\yihe\anaconda3\envs\PPI_GNN_seqvec_v6\lib\site-packages\torch\lib\caffe2_detectron_ops.dll" or one of its dependencies.
          [end of output]
    

    Any idea how to solve this problem?

    opened by yangyangdotcom 1
Releases(0.6.16)
  • 0.6.16(Dec 22, 2022)

  • 0.6.15(Aug 17, 2022)

    • Temporal sampling is now correctly performed in disjoint mode (#267)
    • Replace std::unordered_map with phmap::flat_hash_map for faster sampling (#266)
    • Neighborhood sampling on heterogeneous graphs is now fully-deterministic (#265)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.14(Jun 30, 2022)

    • Internal C++ method for sampling neighbors based on temporal constraints (#202, #225, #226)
    • Sampling operators now respect torch.manual_seed (#217)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.13(Mar 11, 2022)

    • SparseTensor: __eq__ functionality
    • SparseTensor: add functionality of two sparse matrices (#177)
    • SparseTensor: to_torch_csr_tensor and from_torch_csr_tensor functionality
    • SparseTensor: Allow indexing via np.array (#194)
    • SparseTensor: Skip unnecessary assertions and enable non-blocking data transfers (#195)
    • Allow loading of CPU wheels in a PyTorch CUDA installation

    PyTorch 1.10 is now required.

    Source code(tar.gz)
    Source code(zip)
  • 0.6.12(Sep 8, 2021)

    • (Internal) heterogeneous neighbor sampling support via torch.ops.torch_sparse.hetero_neighbor_sample
    • (Internal) heterogeneous graph transformer sampling support via torch.ops.torch_sparse.hgt_sample (thanks to @chantat)
    • Fixed a bug in set_diag in case SparseTensor does not hold any non-zero elements
    Source code(tar.gz)
    Source code(zip)
  • 0.6.11(Jul 29, 2021)

  • 0.6.10(Jun 17, 2021)

    This release brings PyTorch 1.9.0 and Python 3.9 support to torch-sparse.

    Additional functionality

    • Added a check for row.max() < sparse_sizes[0] and col.max() < sparse_sizes[1] when creating a SparseTensor in order to avoid unexpected behavior (thanks to @Adam1679)
    • partition now supports the additional optional argument node_weight (thanks to @Spazierganger)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.9(Mar 3, 2021)

    • Reduced the size of shared library files
    • CUDA wheels can now also operate on CPU-only devices
    • spmm now supports torch.half
    • Added parallelization strategies for CPU functionalities
    • Fixed a bug in which sample_adj did not return a sparse matrix with sorted indices
    • Fixed a bug in spmm in case num_edges < num_nodes
    Source code(tar.gz)
    Source code(zip)
  • 0.6.8(Nov 2, 2020)

  • 0.6.7(Aug 5, 2020)

    • PyTorch 1.6.0 wheels
    • Fixed a bug for reductions in dim=0
    • Fixed a bug in which PyTorch warnings were not displayed when importing torch-sparse
    Source code(tar.gz)
    Source code(zip)
  • 0.6.6(Jul 1, 2020)

  • 0.6.5(Jun 17, 2020)

  • 0.6.4(May 23, 2020)

  • 0.6.3(May 11, 2020)

  • 0.6.1(Mar 23, 2020)

    This release introduces random walk and GraphSAINT subgraph functionalities via random_walk and saint_subgraph to the SparseTensor class.

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Feb 24, 2020)

    This release introduces the partition function based on the METIS library which re-orders the entries of a SparseTensor according to a computed partition. Note that the METIS library needs to be installed and WITH_METIS=1 needs to be set in order to make use of this function.

    Source code(tar.gz)
    Source code(zip)
  • 0.5.1(Feb 14, 2020)

    This release includes a major rewriting of torch-sparse by introducing the SparseTensor class, which is fully differentiable and traceable. The SparseTensor class is still undocumented and not well-tested, and should hence be used with caution. All known functions from earlier versions still work as expected.

    Source code(tar.gz)
    Source code(zip)
  • 0.4.4(Feb 4, 2020)

  • 0.4.3(Oct 14, 2019)

  • 0.4.0(May 1, 2019)

  • 0.2.4(Mar 6, 2019)

  • 0.2.2(Nov 14, 2018)

  • 0.2.1(Oct 20, 2018)

  • 0.2.0(Aug 13, 2018)

    • Operations now take index and value tensors instead of torch sparse tensors
    • Added coalesce, transpose and sparse-dense matrix multiplication
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Aug 1, 2018)

Owner
Matthias Fey
PhD student @ TU Dortmund University - Interested in Representation Learning on Graphs and Manifolds; PyTorch, CUDA, Vim and macOS Enthusiast
Matthias Fey
PyTorch to TensorFlow Lite converter

PyTorch to TensorFlow Lite converter

Omer Ferhat Sarioglu 140 Dec 13, 2022
PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations

PyTorch Sparse This package consists of a small extension library of optimized sparse matrix operations with autograd support. This package currently

Matthias Fey 757 Jan 04, 2023
PyGCL: Graph Contrastive Learning Library for PyTorch

PyGCL is an open-source library for graph contrastive learning (GCL), which features modularized GCL components from published papers, standardized evaluation, and experiment management.

GCL: Graph Contrastive Learning Library for PyTorch 592 Jan 07, 2023
Pretrained EfficientNet, EfficientNet-Lite, MixNet, MobileNetV3 / V2, MNASNet A1 and B1, FBNet, Single-Path NAS

(Generic) EfficientNets for PyTorch A 'generic' implementation of EfficientNet, MixNet, MobileNetV3, etc. that covers most of the compute/parameter ef

Ross Wightman 1.5k Jan 01, 2023
An optimizer that trains as fast as Adam and as good as SGD.

AdaBound An optimizer that trains as fast as Adam and as good as SGD, for developing state-of-the-art deep learning models on a wide variety of popula

LoLo 2.9k Dec 27, 2022
PyTorch implementation of Glow, Generative Flow with Invertible 1x1 Convolutions

glow-pytorch PyTorch implementation of Glow, Generative Flow with Invertible 1x1 Convolutions

Kim Seonghyeon 433 Dec 27, 2022
A very simple and small path tracer written in pytorch meant to be run on the GPU

MentisOculi Pytorch Path Tracer A very simple and small path tracer written in pytorch meant to be run on the GPU Why use pytorch and not some other c

Matthew B. Mirman 222 Dec 01, 2022
Official implementations of EigenDamage: Structured Pruning in the Kronecker-Factored Eigenbasis.

EigenDamage: Structured Pruning in the Kronecker-Factored Eigenbasis This repo contains the official implementations of EigenDamage: Structured Prunin

Chaoqi Wang 107 Apr 20, 2022
PyTorch Implementation of [1611.06440] Pruning Convolutional Neural Networks for Resource Efficient Inference

PyTorch implementation of [1611.06440 Pruning Convolutional Neural Networks for Resource Efficient Inference] This demonstrates pruning a VGG16 based

Jacob Gildenblat 836 Dec 26, 2022
A lightweight wrapper for PyTorch that provides a simple declarative API for context switching between devices, distributed modes, mixed-precision, and PyTorch extensions.

A lightweight wrapper for PyTorch that provides a simple declarative API for context switching between devices, distributed modes, mixed-precision, and PyTorch extensions.

Fidelity Investments 56 Sep 13, 2022
Model summary in PyTorch similar to `model.summary()` in Keras

Keras style model.summary() in PyTorch Keras has a neat API to view the visualization of the model which is very helpful while debugging your network.

Shubham Chandel 3.7k Dec 29, 2022
PyTorch toolkit for biomedical imaging

farabio is a minimal PyTorch toolkit for out-of-the-box deep learning support in biomedical imaging. For further information, see Wikis and Docs.

San Askaruly 47 Dec 28, 2022
S3-plugin is a high performance PyTorch dataset library to efficiently access datasets stored in S3 buckets.

S3-plugin is a high performance PyTorch dataset library to efficiently access datasets stored in S3 buckets.

Amazon Web Services 138 Jan 03, 2023
The goal of this library is to generate more helpful exception messages for numpy/pytorch matrix algebra expressions.

Tensor Sensor See article Clarifying exceptions and visualizing tensor operations in deep learning code. One of the biggest challenges when writing co

Terence Parr 704 Dec 14, 2022
TorchSSL: A PyTorch-based Toolbox for Semi-Supervised Learning

TorchSSL: A PyTorch-based Toolbox for Semi-Supervised Learning

1k Dec 28, 2022
Implementation of LambdaNetworks, a new approach to image recognition that reaches SOTA with less compute

Lambda Networks - Pytorch Implementation of λ Networks, a new approach to image recognition that reaches SOTA on ImageNet. The new method utilizes λ l

Phil Wang 1.5k Jan 07, 2023
This is an differentiable pytorch implementation of SIFT patch descriptor.

This is an differentiable pytorch implementation of SIFT patch descriptor. It is very slow for describing one patch, but quite fast for batch. It can

Dmytro Mishkin 150 Dec 24, 2022
On the Variance of the Adaptive Learning Rate and Beyond

RAdam On the Variance of the Adaptive Learning Rate and Beyond We are in an early-release beta. Expect some adventures and rough edges. Table of Conte

Liyuan Liu 2.5k Dec 27, 2022
Code snippets created for the PyTorch discussion board

PyTorch misc Collection of code snippets I've written for the PyTorch discussion board. All scripts were testes using the PyTorch 1.0 preview and torc

461 Dec 26, 2022
A PyTorch repo for data loading and utilities to be shared by the PyTorch domain libraries.

A PyTorch repo for data loading and utilities to be shared by the PyTorch domain libraries.

878 Dec 30, 2022