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
539e2068
Commit
539e2068
authored
May 06, 2020
by
rusty1s
Browse files
bandwidth
parent
172640ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
torch_sparse/tensor.py
torch_sparse/tensor.py
+9
-0
No files found.
torch_sparse/tensor.py
View file @
539e2068
...
...
@@ -243,6 +243,15 @@ class SparseTensor(object):
def
avg_col_length
(
self
)
->
float
:
return
self
.
nnz
()
/
self
.
sparse_size
(
1
)
def
bandwidth
(
self
)
->
int
:
row
,
col
,
_
=
self
.
coo
()
return
int
((
row
-
col
).
abs_
().
max
())
def
bandwidth_proportion
(
self
,
bandwidth
:
int
)
->
float
:
row
,
col
,
_
=
self
.
coo
()
tmp
=
(
row
-
col
).
abs_
()
return
int
((
tmp
<=
bandwidth
).
sum
())
/
self
.
nnz
()
def
is_quadratic
(
self
)
->
bool
:
return
self
.
sparse_size
(
0
)
==
self
.
sparse_size
(
1
)
...
...
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