Skip to content

Commit 90b242c

Browse files
bslinrusty1s
andauthored
Add docs to torch_sparse.matmul (rusty1s#315)
* Add docs to torch_sparse.matmul * Update comment formatting * Update torch_sparse/matmul.py * Update torch_sparse/matmul.py * Update torch_sparse/matmul.py * Update torch_sparse/matmul.py * Update torch_sparse/matmul.py --------- Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
1 parent 99735df commit 90b242c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

torch_sparse/matmul.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ def matmul(src, other, reduce): # noqa: F811
139139

140140

141141
def matmul(src, other, reduce="sum"): # noqa: F811
142+
"""Matrix product of a sparse tensor with either another sparse tensor or a
143+
dense tensor. The sparse tensor represents an adjacency matrix and is
144+
stored as a list of edges. This method multiplies elements along the rows
145+
of the adjacency matrix with the column of the other matrix. In regular
146+
matrix multiplication, the products are then summed together, but this
147+
method allows us to use other aggregation functions as well.
148+
149+
Args:
150+
src (:class:`SparseTensor`): The sparse tensor.
151+
other (:class:`Tensor` or :class:`SparseTensor`): The second matrix.
152+
reduce (string, optional): The function to reduce along the rows of
153+
:obj:`src` and columns of :obj:`other`. Can be :obj:`"sum"`,
154+
:obj:`"mean"`, :obj:`"min"` or :obj:`"max"`.
155+
(default: :obj:`"sum"`)
156+
157+
:rtype: (:class:`Tensor`)
158+
"""
142159
if isinstance(other, torch.Tensor):
143160
return spmm(src, other, reduce)
144161
elif isinstance(other, SparseTensor):

0 commit comments

Comments
 (0)