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
8741b4f7
Commit
8741b4f7
authored
Oct 27, 2020
by
rusty1s
Browse files
nonzero warnings
parent
a1021ebd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
torch_sparse/masked_select.py
torch_sparse/masked_select.py
+1
-1
torch_sparse/storage.py
torch_sparse/storage.py
+1
-1
torch_sparse/tensor.py
torch_sparse/tensor.py
+3
-2
No files found.
torch_sparse/masked_select.py
View file @
8741b4f7
...
...
@@ -65,7 +65,7 @@ def masked_select(src: SparseTensor, dim: int,
else
:
value
=
src
.
storage
.
value
()
if
value
is
not
None
:
idx
=
mask
.
nonzero
().
flatten
()
idx
=
mask
.
nonzero
(
as_tuple
=
False
).
flatten
()
return
src
.
set_value
(
value
.
index_select
(
dim
-
1
,
idx
),
layout
=
'coo'
)
else
:
...
...
torch_sparse/storage.py
View file @
8741b4f7
...
...
@@ -379,7 +379,7 @@ class SparseStorage(object):
value
=
self
.
_value
if
value
is
not
None
:
ptr
=
mask
.
nonzero
().
flatten
()
ptr
=
mask
.
nonzero
(
as_tuple
=
False
).
flatten
()
ptr
=
torch
.
cat
([
ptr
,
ptr
.
new_full
((
1
,
),
value
.
size
(
0
))])
value
=
segment_csr
(
value
,
ptr
,
reduce
=
reduce
)
value
=
value
[
0
]
if
isinstance
(
value
,
tuple
)
else
value
...
...
torch_sparse/tensor.py
View file @
8741b4f7
...
...
@@ -41,9 +41,10 @@ class SparseTensor(object):
@
classmethod
def
from_dense
(
self
,
mat
:
torch
.
Tensor
,
has_value
:
bool
=
True
):
if
mat
.
dim
()
>
2
:
index
=
mat
.
abs
().
sum
([
i
for
i
in
range
(
2
,
mat
.
dim
())]).
nonzero
()
index
=
mat
.
abs
().
sum
([
i
for
i
in
range
(
2
,
mat
.
dim
())
]).
nonzero
(
as_tuple
=
False
)
else
:
index
=
mat
.
nonzero
()
index
=
mat
.
nonzero
(
as_tuple
=
False
)
index
=
index
.
t
()
row
=
index
[
0
]
...
...
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