1313
1414--------------------------------------------------------------------------------
1515
16- [ PyTorch] ( http://pytorch.org/ ) completely lacks autograd support and operations such as sparse sparse matrix multiplication, but is heavily working on improvement (* cf.* [ this issue] ( https://github.com/pytorch/pytorch/issues/9674 ) ).
17- In the meantime, this package consists of a small extension library of optimized sparse matrix operations with autograd support.
16+ This package consists of a small extension library of optimized sparse matrix operations with autograd support.
1817This package currently consists of the following methods:
1918
2019* ** [ Coalesce] ( #coalesce ) **
@@ -28,6 +27,26 @@ Note that only `value` comes with autograd support, as `index` is discrete and t
2827
2928## Installation
3029
30+ ### Binaries
31+
32+ We provide pip wheels for all major OS/PyTorch/CUDA combinations, see [ here] ( http://pytorch-sparse.s3-website.eu-central-1.amazonaws.com/whl ) .
33+ To install from binaries, simply run
34+
35+ ```
36+ pip install torch-scatter==latest+${CUDA} -f http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-scatter.s3-website.eu-central-1.amazonaws.com
37+ pip install torch-sparse==latest+${CUDA} -f http://pytorch-sparse.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-sparse.s3-website.eu-central-1.amazonaws.com
38+ ```
39+
40+ where ` ${CUDA} ` should be replaced by either ` cpu ` , ` cu92 ` , ` cu100 ` or ` cu101 ` depending on your PyTorch installation.
41+
42+ | | ` cpu ` | ` cu92 ` | ` cu100 ` | ` cu101 ` |
43+ | -------------| -------| --------| ---------| ---------|
44+ | ** Linux** | ✅ | ✅ | ✅ | ✅ |
45+ | ** Windows** | ✅ | ❌ | ❌ | ✅ |
46+ | ** macOS** | ✅ | ❌ | ❌ | ❌ |
47+
48+ ### From source
49+
3150Ensure 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.* :
3251
3352```
@@ -47,10 +66,16 @@ Then run:
4766pip install torch-scatter torch-sparse
4867```
4968
50- If you are running into any installation problems, please create an [ issue] ( https://github.com/rusty1s/pytorch_sparse/issues ) .
51- Be sure to import ` torch ` first before using this package to resolve symbols the dynamic linker must see.
69+ When running in a docker container without nvidia driver, PyTorch needs to evaluate the compute capabilities and may fail.
70+ In this case, ensure that the compute capabilities are set via ` TORCH_CUDA_ARCH_LIST ` , * e.g.* :
71+
72+ ```
73+ export TORCH_CUDA_ARCH_LIST = "6.0 6.1 7.2+PTX 7.5+PTX"
74+ ```
75+
76+ ## Functions
5277
53- ## Coalesce
78+ ### Coalesce
5479
5580```
5681torch_sparse.coalesce(index, value, m, n, op="add") -> (torch.LongTensor, torch.Tensor)
@@ -60,20 +85,20 @@ Row-wise sorts `index` and removes duplicate entries.
6085Duplicate entries are removed by scattering them together.
6186For scattering, any operation of [ ` torch_scatter ` ] ( https://github.com/rusty1s/pytorch_scatter ) can be used.
6287
63- ### Parameters
88+ #### Parameters
6489
6590* ** index** * (LongTensor)* - The index tensor of sparse matrix.
6691* ** value** * (Tensor)* - The value tensor of sparse matrix.
6792* ** m** * (int)* - The first dimension of corresponding dense matrix.
6893* ** n** * (int)* - The second dimension of corresponding dense matrix.
6994* ** op** * (string, optional)* - The scatter operation to use. (default: ` "add" ` )
7095
71- ### Returns
96+ #### Returns
7297
7398* ** index** * (LongTensor)* - The coalesced index tensor of sparse matrix.
7499* ** value** * (Tensor)* - The coalesced value tensor of sparse matrix.
75100
76- ### Example
101+ #### Example
77102
78103``` python
79104import torch
@@ -97,28 +122,28 @@ tensor([[6.0, 8.0],
97122 [5.0, 6.0]])
98123```
99124
100- ## Transpose
125+ ### Transpose
101126
102127```
103128torch_sparse.transpose(index, value, m, n) -> (torch.LongTensor, torch.Tensor)
104129```
105130
106131Transposes dimensions 0 and 1 of a sparse matrix.
107132
108- ### Parameters
133+ #### Parameters
109134
110135* ** index** * (LongTensor)* - The index tensor of sparse matrix.
111136* ** value** * (Tensor)* - The value tensor of sparse matrix.
112137* ** m** * (int)* - The first dimension of corresponding dense matrix.
113138* ** n** * (int)* - The second dimension of corresponding dense matrix.
114139* ** coalesced** * (bool, optional)* - If set to ` False ` , will not coalesce the output. (default: ` True ` )
115140
116- ### Returns
141+ #### Returns
117142
118143* ** index** * (LongTensor)* - The transposed index tensor of sparse matrix.
119144* ** value** * (Tensor)* - The transposed value tensor of sparse matrix.
120145
121- ### Example
146+ #### Example
122147
123148``` python
124149import torch
@@ -142,27 +167,27 @@ tensor([[7.0, 9.0],
142167 [3.0, 4.0]])
143168```
144169
145- ## Sparse Dense Matrix Multiplication
170+ ### Sparse Dense Matrix Multiplication
146171
147172```
148173torch_sparse.spmm(index, value, m, n, matrix) -> torch.Tensor
149174```
150175
151176Matrix product of a sparse matrix with a dense matrix.
152177
153- ### Parameters
178+ #### Parameters
154179
155180* ** index** * (LongTensor)* - The index tensor of sparse matrix.
156181* ** value** * (Tensor)* - The value tensor of sparse matrix.
157182* ** m** * (int)* - The first dimension of corresponding dense matrix.
158183* ** n** * (int)* - The second dimension of corresponding dense matrix.
159184* ** matrix** * (Tensor)* - The dense matrix.
160185
161- ### Returns
186+ #### Returns
162187
163188* ** out** * (Tensor)* - The dense output matrix.
164189
165- ### Example
190+ #### Example
166191
167192``` python
168193import torch
@@ -183,7 +208,7 @@ tensor([[7.0, 16.0],
183208 [7.0, 19.0]])
184209```
185210
186- ## Sparse Sparse Matrix Multiplication
211+ ### Sparse Sparse Matrix Multiplication
187212
188213```
189214torch_sparse.spspmm(indexA, valueA, indexB, valueB, m, k, n) -> (torch.LongTensor, torch.Tensor)
@@ -192,7 +217,7 @@ torch_sparse.spspmm(indexA, valueA, indexB, valueB, m, k, n) -> (torch.LongTenso
192217Matrix product of two sparse tensors.
193218Both input sparse matrices need to be ** coalesced** (use the ` coalesced ` attribute to force).
194219
195- ### Parameters
220+ #### Parameters
196221
197222* ** indexA** * (LongTensor)* - The index tensor of first sparse matrix.
198223* ** valueA** * (Tensor)* - The value tensor of first sparse matrix.
@@ -203,12 +228,12 @@ Both input sparse matrices need to be **coalesced** (use the `coalesced` attribu
203228* ** n** * (int)* - The second dimension of second corresponding dense matrix.
204229* ** coalesced** * (bool, optional)* : If set to ` True ` , will coalesce both input sparse matrices. (default: ` False ` )
205230
206- ### Returns
231+ #### Returns
207232
208233* ** index** * (LongTensor)* - The output index tensor of sparse matrix.
209234* ** value** * (Tensor)* - The output value tensor of sparse matrix.
210235
211- ### Example
236+ #### Example
212237
213238``` python
214239import torch
0 commit comments