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
dgl
Commits
ee5f0967
Unverified
Commit
ee5f0967
authored
Nov 18, 2022
by
Mufei Li
Committed by
GitHub
Nov 18, 2022
Browse files
Update (#4920)
Co-authored-by:
Ubuntu
<
ubuntu@ip-172-31-36-188.ap-northeast-1.compute.internal
>
parent
4ecd2c85
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
python/dgl/mock_sparse/elementwise_op_sp.py
python/dgl/mock_sparse/elementwise_op_sp.py
+1
-1
python/dgl/mock_sparse/sp_matrix.py
python/dgl/mock_sparse/sp_matrix.py
+1
-1
No files found.
python/dgl/mock_sparse/elementwise_op_sp.py
View file @
ee5f0967
...
@@ -73,7 +73,7 @@ def sp_add(
...
@@ -73,7 +73,7 @@ def sp_add(
"The shape of sparse matrix A {} and"
"The shape of sparse matrix A {} and"
" B {} are expected to match"
.
format
(
A
.
shape
,
B
.
shape
)
" B {} are expected to match"
.
format
(
A
.
shape
,
B
.
shape
)
)
)
C
=
A
.
adj
+
B
.
adj
C
=
(
A
.
adj
+
B
.
adj
).
coalesce
()
return
SparseMatrix
(
C
.
indices
()[
0
],
C
.
indices
()[
1
],
C
.
values
(),
C
.
shape
)
return
SparseMatrix
(
C
.
indices
()[
0
],
C
.
indices
()[
1
],
C
.
values
(),
C
.
shape
)
raise
RuntimeError
(
raise
RuntimeError
(
"Elementwise addition between {} and {} is not "
"Elementwise addition between {} and {} is not "
...
...
python/dgl/mock_sparse/sp_matrix.py
View file @
ee5f0967
...
@@ -62,7 +62,7 @@ class SparseMatrix:
...
@@ -62,7 +62,7 @@ class SparseMatrix:
shape
:
Optional
[
Tuple
[
int
,
int
]]
=
None
,
shape
:
Optional
[
Tuple
[
int
,
int
]]
=
None
,
):
):
if
val
is
None
:
if
val
is
None
:
val
=
torch
.
ones
(
row
.
shape
[
0
])
val
=
torch
.
ones
(
row
.
shape
[
0
])
.
to
(
row
.
device
)
i
=
torch
.
cat
((
row
.
unsqueeze
(
0
),
col
.
unsqueeze
(
0
)),
0
)
i
=
torch
.
cat
((
row
.
unsqueeze
(
0
),
col
.
unsqueeze
(
0
)),
0
)
if
shape
is
None
:
if
shape
is
None
:
self
.
adj
=
torch
.
sparse_coo_tensor
(
i
,
val
).
coalesce
()
self
.
adj
=
torch
.
sparse_coo_tensor
(
i
,
val
).
coalesce
()
...
...
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