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
d40ae5a7
Commit
d40ae5a7
authored
Jul 03, 2021
by
rusty1s
Browse files
update benchmark
parent
39e8533e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
benchmark/ptr2ind.py
benchmark/ptr2ind.py
+16
-0
No files found.
benchmark/ptr2ind.py
View file @
d40ae5a7
...
@@ -102,6 +102,18 @@ def op4(matrix):
...
@@ -102,6 +102,18 @@ def op4(matrix):
torch
.
ops
.
torch_sparse
.
ind2ptr
(
row_indices
,
matrix
.
shape
[
0
])
torch
.
ops
.
torch_sparse
.
ind2ptr
(
row_indices
,
matrix
.
shape
[
0
])
def
op5
(
matrix
):
row_indices
=
matrix
.
indices
()[
0
]
arange
=
torch
.
arange
(
matrix
.
size
(
0
)
+
1
)
torch
.
searchsorted
(
row_indices
,
arange
)
def
op6
(
matrix
):
row_indices
=
matrix
.
indices
()[
0
]
arange
=
torch
.
arange
(
matrix
.
size
(
0
)
+
1
)
torch
.
bucketize
(
arange
,
row_indices
)
for
group
,
name
in
matrices
:
for
group
,
name
in
matrices
:
matrix
=
get_torch_sparse_coo_tensor
(
args
.
root
,
group
,
name
)
matrix
=
get_torch_sparse_coo_tensor
(
args
.
root
,
group
,
name
)
...
@@ -113,3 +125,7 @@ for group, name in matrices:
...
@@ -113,3 +125,7 @@ for group, name in matrices:
print
(
'vectorized:'
,
duration
)
print
(
'vectorized:'
,
duration
)
duration
=
time_func
(
matrix
,
op4
,
duration
=
5.0
,
warmup
=
1.0
)
duration
=
time_func
(
matrix
,
op4
,
duration
=
5.0
,
warmup
=
1.0
)
print
(
'torch-sparse:'
,
duration
)
print
(
'torch-sparse:'
,
duration
)
duration
=
time_func
(
matrix
,
op5
,
duration
=
5.0
,
warmup
=
1.0
)
print
(
'searchsorted:'
,
duration
)
duration
=
time_func
(
matrix
,
op6
,
duration
=
5.0
,
warmup
=
1.0
)
print
(
'bucketize:'
,
duration
)
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