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
4bc050b1
Commit
4bc050b1
authored
Jun 22, 2021
by
rusty1s
Browse files
add torch.jit.script support to spmm
parent
0adb9cab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
torch_sparse/spmm.py
torch_sparse/spmm.py
+4
-3
No files found.
torch_sparse/spmm.py
View file @
4bc050b1
#
import
torch
from
torch
import
Tensor
from
torch_scatter
import
scatter_add
from
torch_scatter
import
scatter_add
def
spmm
(
index
,
value
,
m
,
n
,
matrix
):
def
spmm
(
index
:
Tensor
,
value
:
Tensor
,
m
:
int
,
n
:
int
,
matrix
:
Tensor
)
->
Tensor
:
"""Matrix product of sparse matrix with dense matrix.
"""Matrix product of sparse matrix with dense matrix.
Args:
Args:
...
@@ -17,7 +18,7 @@ def spmm(index, value, m, n, matrix):
...
@@ -17,7 +18,7 @@ def spmm(index, value, m, n, matrix):
assert
n
==
matrix
.
size
(
-
2
)
assert
n
==
matrix
.
size
(
-
2
)
row
,
col
=
index
row
,
col
=
index
[
0
],
index
[
1
]
matrix
=
matrix
if
matrix
.
dim
()
>
1
else
matrix
.
unsqueeze
(
-
1
)
matrix
=
matrix
if
matrix
.
dim
()
>
1
else
matrix
.
unsqueeze
(
-
1
)
out
=
matrix
.
index_select
(
-
2
,
col
)
out
=
matrix
.
index_select
(
-
2
,
col
)
...
...
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