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
04997b00
Unverified
Commit
04997b00
authored
Dec 30, 2020
by
Matthias Fey
Committed by
GitHub
Dec 30, 2020
Browse files
Merge pull request #102 from shi27feng/master
modify spmm to support multi-dimensional tensor
parents
5fc07a56
4f8a6cc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
torch_sparse/spmm.py
torch_sparse/spmm.py
+3
-3
No files found.
torch_sparse/spmm.py
View file @
04997b00
...
...
@@ -15,13 +15,13 @@ def spmm(index, value, m, n, matrix):
:rtype: :class:`Tensor`
"""
assert
n
==
matrix
.
size
(
0
)
assert
n
==
matrix
.
size
(
-
2
)
row
,
col
=
index
matrix
=
matrix
if
matrix
.
dim
()
>
1
else
matrix
.
unsqueeze
(
-
1
)
out
=
matrix
[
col
]
out
=
matrix
.
index_select
(
-
2
,
col
)
out
=
out
*
value
.
unsqueeze
(
-
1
)
out
=
scatter_add
(
out
,
row
,
dim
=
0
,
dim_size
=
m
)
out
=
scatter_add
(
out
,
row
,
dim
=
-
2
,
dim_size
=
m
)
return
out
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