Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-sparse
Commits
fb28fe78
Commit
fb28fe78
authored
Jul 15, 2019
by
rusty1s
Browse files
add coalesced argument to spspmm call
parent
37fb98cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
torch_sparse/spspmm.py
torch_sparse/spspmm.py
+9
-3
No files found.
torch_sparse/spspmm.py
View file @
fb28fe78
import
torch
import
torch
from
torch_sparse
import
transpose
,
to_scipy
,
from_scipy
from
torch_sparse
import
transpose
,
to_scipy
,
from_scipy
,
coalesce
import
torch_sparse.spspmm_cpu
import
torch_sparse.spspmm_cpu
...
@@ -7,9 +7,9 @@ if torch.cuda.is_available():
...
@@ -7,9 +7,9 @@ if torch.cuda.is_available():
import
torch_sparse.spspmm_cuda
import
torch_sparse.spspmm_cuda
def
spspmm
(
indexA
,
valueA
,
indexB
,
valueB
,
m
,
k
,
n
):
def
spspmm
(
indexA
,
valueA
,
indexB
,
valueB
,
m
,
k
,
n
,
coalesced
=
False
):
"""Matrix product of two sparse tensors. Both input sparse matrices need to
"""Matrix product of two sparse tensors. Both input sparse matrices need to
be coalesced.
be coalesced
(use the :obj:`coalesce` attribute to force)
.
Args:
Args:
indexA (:class:`LongTensor`): The index tensor of first sparse matrix.
indexA (:class:`LongTensor`): The index tensor of first sparse matrix.
...
@@ -20,9 +20,15 @@ def spspmm(indexA, valueA, indexB, valueB, m, k, n):
...
@@ -20,9 +20,15 @@ def spspmm(indexA, valueA, indexB, valueB, m, k, n):
k (int): The second dimension of first corresponding dense matrix and
k (int): The second dimension of first corresponding dense matrix and
first dimension of second corresponding dense matrix.
first dimension of second corresponding dense matrix.
n (int): The second dimension of second corresponding dense matrix.
n (int): The second dimension of second corresponding dense matrix.
coalesced (bool, optional): If set to :obj:`False`, will coalesce both
input sparse matrices (default: :obj:`True`).
:rtype: (:class:`LongTensor`, :class:`Tensor`)
:rtype: (:class:`LongTensor`, :class:`Tensor`)
"""
"""
if
indexA
.
is_cuda
and
coalesced
:
indexA
,
valueA
=
coalesce
(
indexA
,
valueA
,
m
,
k
)
indexB
,
valueB
=
coalesce
(
indexB
,
valueB
,
k
,
n
)
index
,
value
=
SpSpMM
.
apply
(
indexA
,
valueA
,
indexB
,
valueB
,
m
,
k
,
n
)
index
,
value
=
SpSpMM
.
apply
(
indexA
,
valueA
,
indexB
,
valueB
,
m
,
k
,
n
)
return
index
.
detach
(),
value
return
index
.
detach
(),
value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment