Skip to content

Commit 01f5572

Browse files
committed
docs
1 parent 46a9c9a commit 01f5572

File tree

5 files changed

+71
-23
lines changed

5 files changed

+71
-23
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ For scattering, any operation of [`torch_scatter`](https://github.com/rusty1s/py
6363

6464
* **index** *(LongTensor)* - The index tensor of sparse matrix.
6565
* **value** *(Tensor)* - The value tensor of sparse matrix.
66-
* **m** *(int)* - First dimension of sparse matrix.
67-
* **n** *(int)* - Second dimension of sparse matrix.
68-
* **op** *(string, optional)* - Scatter operation to use. (default: `"add"`)
69-
* **fill_value** *(int, optional)* - Initial fill value of scatter operation. (default: `0`)
66+
* **m** *(int)* - The first dimension of sparse matrix.
67+
* **n** *(int)* - The second dimension of sparse matrix.
68+
* **op** *(string, optional)* - The scatter operation to use. (default: `"add"`)
69+
* **fill_value** *(int, optional)* - The initial fill value of scatter operation. (default: `0`)
7070

7171
### Returns
7272

73-
* **index** *(LongTensor)* - Coalesced index tensor of sparse matrix.
74-
* **value** *(Tensor)* - Coalesced value tensor of sparse matrix.
73+
* **index** *(LongTensor)* - The coalesced index tensor of sparse matrix.
74+
* **value** *(Tensor)* - The coalesced value tensor of sparse matrix.
7575

7676
### Example
7777

@@ -105,13 +105,13 @@ Transposes dimensions 0 and 1 of a sparse matrix.
105105

106106
* **index** *(LongTensor)* - The index tensor of sparse matrix.
107107
* **value** *(Tensor)* - The value tensor of sparse matrix.
108-
* **m** *(int)* - First dimension of sparse matrix.
109-
* **n** *(int)* - Second dimension of sparse matrix.
108+
* **m** *(int)* - The first dimension of sparse matrix.
109+
* **n** *(int)* - The second dimension of sparse matrix.
110110

111111
### Returns
112112

113-
* **index** *(LongTensor)* - Transposed index tensor of sparse matrix.
114-
* **value** *(Tensor)* - Transposed value tensor of sparse matrix.
113+
* **index** *(LongTensor)* - The transposed index tensor of sparse matrix.
114+
* **value** *(Tensor)* - The transposed value tensor of sparse matrix.
115115

116116
### Example
117117

@@ -122,7 +122,7 @@ index = torch.tensor([[1, 0, 1, 0, 2, 1],
122122
[0, 1, 1, 1, 0, 0]])
123123
value = torch.tensor([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]])
124124

125-
index, value = transpose(index, value, m=3, n=2)
125+
index, value = transpose(index, value, 3, 2)
126126
```
127127

128128
```
@@ -148,12 +148,12 @@ Matrix product of a sparse matrix with a dense matrix.
148148

149149
* **index** *(LongTensor)* - The index tensor of sparse matrix.
150150
* **value** *(Tensor)* - The value tensor of sparse matrix.
151-
* **m** *(int)* - First dimension of sparse matrix.
152-
* **matrix** *(int)* - Dense matrix.
151+
* **m** *(int)* - The first dimension of sparse matrix.
152+
* **matrix** *(Tensor)* - The dense matrix.
153153

154154
### Returns
155155

156-
* **out** *(Tensor)* - Dense output matrix.
156+
* **out** *(Tensor)* - The dense output matrix.
157157

158158
### Example
159159

@@ -190,14 +190,14 @@ Both input sparse matrices need to be **coalesced**.
190190
* **valueA** *(Tensor)* - The value tensor of first sparse matrix.
191191
* **indexB** *(LongTensor)* - The index tensor of second sparse matrix.
192192
* **valueB** *(Tensor)* - The value tensor of second sparse matrix.
193-
* **m** *(int)* - First dimension of first sparse matrix.
194-
* **k** *(int)* - Second dimension of first sparse matrix and first dimension of second sparse matrix.
195-
* **n** *(int)* - Second dimension of second sparse matrix.
193+
* **m** *(int)* - The first dimension of first sparse matrix.
194+
* **k** *(int)* - The second dimension of first sparse matrix and first dimension of second sparse matrix.
195+
* **n** *(int)* - The second dimension of second sparse matrix.
196196

197197
### Returns
198198

199-
* **index** *(LongTensor)* - Output index tensor of sparse matrix.
200-
* **value** *(Tensor)* - Output value tensor of sparse matrix.
199+
* **index** *(LongTensor)* - The output index tensor of sparse matrix.
200+
* **value** *(Tensor)* - The output value tensor of sparse matrix.
201201

202202
### Example
203203

torch_sparse/coalesce.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@
33

44

55
def coalesce(index, value, m, n, op='add', fill_value=0):
6-
"""Row-wise reorders and removes duplicate entries in sparse matrix."""
6+
"""Row-wise sorts :obj:`value` and removes duplicate entries. Duplicate
7+
entries are removed by scattering them together. For scattering, any
8+
operation of `"torch_scatter"<https://github.com/rusty1s/pytorch_scatter>`_
9+
can be used.
10+
11+
Args:
12+
index (:class:`LongTensor`): The index tensor of sparse matrix.
13+
value (:class:`Tensor`): The value tensor of sparse matrix.
14+
m (int): The first dimension of sparse matrix.
15+
n (int): The second dimension of sparse matrix.
16+
op (string, optional): The scatter operation to use. (default:
17+
:obj:`"add"`)
18+
fill_value (int, optional): The initial fill value of scatter
19+
operation. (default: :obj:`0`)
20+
21+
:rtype: (:class:`LongTensor`, :class:`Tensor`)
22+
"""
723

824
row, col = index
925

torch_sparse/spmm.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33

44
def spmm(index, value, m, matrix):
5-
"""Matrix product of sparse matrix with dense matrix."""
5+
"""Matrix product of sparse matrix with dense matrix.
6+
7+
Args:
8+
index (:class:`LongTensor`): The index tensor of sparse matrix.
9+
value (:class:`Tensor`): The value tensor of sparse matrix.
10+
m (int): The first dimension of sparse matrix.
11+
matrix (:class:`Tensor`): The dense matrix.
12+
13+
:rtype: :class:`Tensor`
14+
"""
615

716
row, col = index
817
matrix = matrix if matrix.dim() > 1 else matrix.unsqueeze(-1)

torch_sparse/spspmm.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,21 @@
88

99

1010
class SpSpMM(torch.autograd.Function):
11-
"""Sparse matrix product of two sparse matrices with autograd support."""
11+
"""Matrix product of two sparse tensors. Both input sparse matrices need to
12+
be coalesced.
13+
14+
Args:
15+
indexA (:class:`LongTensor`): The index tensor of first sparse matrix.
16+
valueA (:class:`Tensor`): The value tensor of first sparse matrix.
17+
indexB (:class:`LongTensor`): The index tensor of second sparse matrix.
18+
valueB (:class:`Tensor`): The value tensor of second sparse matrix.
19+
m (int): The first dimension of first sparse matrix.
20+
k (int): The second dimension of first sparse matrix and first
21+
dimension of second sparse matrix.
22+
n (int): The second dimension of second sparse matrix.
23+
24+
:rtype: (:class:`LongTensor`, :class:`Tensor`)
25+
"""
1226

1327
@staticmethod
1428
def forward(ctx, indexA, valueA, indexB, valueB, m, k, n):

torch_sparse/transpose.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33

44

55
def transpose(index, value, m, n):
6-
"""Transpose of sparse matrix."""
6+
"""Transposes dimensions 0 and 1 of a sparse matrix.
7+
8+
Args:
9+
index (:class:`LongTensor`): The index tensor of sparse matrix.
10+
value (:class:`Tensor`): The value tensor of sparse matrix.
11+
m (int): The first dimension of sparse matrix.
12+
n (int): The second dimension of sparse matrix.
13+
14+
:rtype: (:class:`LongTensor`, :class:`Tensor`)
15+
"""
716

817
row, col = index
918
index = torch.stack([col, row], dim=0)

0 commit comments

Comments
 (0)