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-scatter
Commits
481e81fe
Commit
481e81fe
authored
Aug 24, 2019
by
rusty1s
Browse files
fix view on zero-element tensors
parent
b98d1f3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
torch_scatter/utils/gen.py
torch_scatter/utils/gen.py
+6
-1
No files found.
torch_scatter/utils/gen.py
View file @
481e81fe
from
itertools
import
repeat
from
itertools
import
repeat
import
torch
def
maybe_dim_size
(
index
,
dim_size
=
None
):
def
maybe_dim_size
(
index
,
dim_size
=
None
):
if
dim_size
is
not
None
:
if
dim_size
is
not
None
:
...
@@ -14,7 +16,10 @@ def gen(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
...
@@ -14,7 +16,10 @@ def gen(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
if
index
.
dim
()
==
1
:
if
index
.
dim
()
==
1
:
index_size
=
list
(
repeat
(
1
,
src
.
dim
()))
index_size
=
list
(
repeat
(
1
,
src
.
dim
()))
index_size
[
dim
]
=
src
.
size
(
dim
)
index_size
[
dim
]
=
src
.
size
(
dim
)
index
=
index
.
view
(
index_size
).
expand_as
(
src
)
if
index
.
numel
()
>
0
:
index
=
index
.
view
(
index_size
).
expand_as
(
src
)
else
:
# PyTorch has a bug when view is used on zero-element tensors.
index
=
src
.
new_empty
(
index_size
,
dtype
=
torch
.
long
)
# Generate output tensor if not given.
# Generate output tensor if not given.
if
out
is
None
:
if
out
is
None
:
...
...
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