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
24c599ea
Commit
24c599ea
authored
Feb 10, 2020
by
rusty1s
Browse files
has_value
parent
9d4fae0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
torch_sparse/tensor.py
torch_sparse/tensor.py
+8
-2
No files found.
torch_sparse/tensor.py
View file @
24c599ea
...
...
@@ -48,11 +48,17 @@ class SparseTensor(object):
sparse_sizes
=
mat
.
size
()[:
2
],
is_sorted
=
True
)
@
classmethod
def
from_torch_sparse_coo_tensor
(
self
,
mat
:
torch
.
Tensor
):
def
from_torch_sparse_coo_tensor
(
self
,
mat
:
torch
.
Tensor
,
has_value
:
bool
=
True
):
mat
=
mat
.
coalesce
()
index
=
mat
.
_indices
()
row
,
col
=
index
[
0
],
index
[
1
]
return
SparseTensor
(
row
=
row
,
rowptr
=
None
,
col
=
col
,
value
=
mat
.
_values
(),
value
:
Optional
[
torch
.
Tensor
]
=
None
if
has_value
:
value
=
mat
.
_values
()
return
SparseTensor
(
row
=
row
,
rowptr
=
None
,
col
=
col
,
value
=
value
,
sparse_sizes
=
mat
.
size
()[:
2
],
is_sorted
=
True
)
@
classmethod
...
...
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