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
56ce60b0
"git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "d4d6ea09e35f1b8800d268d97ce29c7453cae3cc"
Unverified
Commit
56ce60b0
authored
Dec 21, 2022
by
czkkkkkk
Committed by
GitHub
Dec 21, 2022
Browse files
[Sparse] Fix SpMM and SDDMM test precision problem (#5060)
parent
1f2fcae3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
tests/pytorch/mock_sparse2/test_matmul.py
tests/pytorch/mock_sparse2/test_matmul.py
+3
-2
tests/pytorch/mock_sparse2/test_sddmm.py
tests/pytorch/mock_sparse2/test_sddmm.py
+4
-4
No files found.
tests/pytorch/mock_sparse2/test_matmul.py
View file @
56ce60b0
...
@@ -44,9 +44,10 @@ def test_spmm(create_func, shape, nnz, out_dim):
...
@@ -44,9 +44,10 @@ def test_spmm(create_func, shape, nnz, out_dim):
if
out_dim
is
None
:
if
out_dim
is
None
:
torch_sparse_result
=
torch_sparse_result
.
view
(
-
1
)
torch_sparse_result
=
torch_sparse_result
.
view
(
-
1
)
torch_sparse_result
.
backward
(
grad
)
torch_sparse_result
.
backward
(
grad
)
assert
torch
.
allclose
(
sparse_result
,
torch_sparse_result
)
assert
torch
.
allclose
(
sparse_result
,
torch_sparse_result
,
atol
=
1e-05
)
assert
torch
.
allclose
(
X
.
grad
,
XX
.
grad
)
assert
torch
.
allclose
(
X
.
grad
,
XX
.
grad
,
atol
=
1e-05
)
assert
torch
.
allclose
(
assert
torch
.
allclose
(
adj
.
grad
.
coalesce
().
to_dense
(),
adj
.
grad
.
coalesce
().
to_dense
(),
sparse_matrix_to_dense
(
val_like
(
A
,
A
.
val
.
grad
)),
sparse_matrix_to_dense
(
val_like
(
A
,
A
.
val
.
grad
)),
atol
=
1e-05
,
)
)
tests/pytorch/mock_sparse2/test_sddmm.py
View file @
56ce60b0
...
@@ -44,7 +44,7 @@ def test_sddmm(create_func, shape, nnz, hidden):
...
@@ -44,7 +44,7 @@ def test_sddmm(create_func, shape, nnz, hidden):
dense_val
=
dense_result
[
row
,
col
]
*
A_val_clone
dense_val
=
dense_result
[
row
,
col
]
*
A_val_clone
dense_val
.
backward
(
grad
)
dense_val
.
backward
(
grad
)
assert
torch
.
allclose
(
dense_val
,
sparse_result
.
val
)
assert
torch
.
allclose
(
dense_val
,
sparse_result
.
val
,
atol
=
1e-05
)
assert
torch
.
allclose
(
dense_C
.
grad
,
C
.
grad
)
assert
torch
.
allclose
(
dense_C
.
grad
,
C
.
grad
,
atol
=
1e-05
)
assert
torch
.
allclose
(
dense_B
.
grad
,
B
.
grad
)
assert
torch
.
allclose
(
dense_B
.
grad
,
B
.
grad
,
atol
=
1e-05
)
assert
torch
.
allclose
(
A_val_clone
.
grad
,
A
.
val
.
grad
)
assert
torch
.
allclose
(
A_val_clone
.
grad
,
A
.
val
.
grad
,
atol
=
1e-05
)
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