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
de991ced
Commit
de991ced
authored
Feb 04, 2020
by
rusty1s
Browse files
correctness check
parent
0934609b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
benchmark/main.py
benchmark/main.py
+21
-1
No files found.
benchmark/main.py
View file @
de991ced
...
...
@@ -35,7 +35,27 @@ def bold(text, flag=True):
@
torch
.
no_grad
()
def
correctness
(
dataset
):
pass
group
,
name
=
dataset
mat_scipy
=
loadmat
(
f
'
{
name
}
.mat'
)[
'Problem'
][
0
][
0
][
2
].
tocsr
()
row
=
torch
.
from_numpy
(
mat_scipy
.
tocoo
().
row
).
to
(
args
.
device
,
torch
.
long
)
col
=
torch
.
from_numpy
(
mat_scipy
.
tocoo
().
col
).
to
(
args
.
device
,
torch
.
long
)
mat
=
SparseTensor
(
row
=
row
,
col
=
col
,
sparse_sizes
=
mat_scipy
.
shape
)
mat
.
fill_cache_
()
mat_pytorch
=
mat
.
to_torch_sparse_coo_tensor
().
coalesce
()
for
size
in
sizes
:
try
:
x
=
torch
.
randn
((
mat
.
size
(
1
),
size
),
device
=
args
.
device
)
out1
=
mat
@
x
out2
=
mat_pytorch
@
x
assert
torch
.
allclose
(
out1
,
out2
,
atol
=
1e-4
)
except
RuntimeError
as
e
:
if
'out of memory'
not
in
str
(
e
):
raise
RuntimeError
(
e
)
torch
.
cuda
.
empty_cache
()
def
time_func
(
func
,
x
):
...
...
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