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
21478411
"setup.cfg" did not exist on "d1aac35d68a203955a32bca4635429f620fc08dd"
Commit
21478411
authored
Apr 13, 2019
by
rusty1s
Browse files
dim size fix for index.numel() == 0
parent
50e4214b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
torch_scatter/utils/gen.py
torch_scatter/utils/gen.py
+7
-1
No files found.
torch_scatter/utils/gen.py
View file @
21478411
from
itertools
import
repeat
def
maybe_dim_size
(
index
,
dim_size
=
None
):
if
dim_size
is
not
None
:
return
dim_size
return
index
.
max
().
item
()
+
1
if
index
.
numel
()
>
0
else
0
def
gen
(
src
,
index
,
dim
=-
1
,
out
=
None
,
dim_size
=
None
,
fill_value
=
0
):
dim
=
range
(
src
.
dim
())[
dim
]
# Get real dim value.
...
...
@@ -12,8 +18,8 @@ def gen(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
# Generate output tensor if not given.
if
out
is
None
:
dim_size
=
index
.
max
().
item
()
+
1
if
dim_size
is
None
else
dim_size
out_size
=
list
(
src
.
size
())
dim_size
=
maybe_dim_size
(
index
,
dim_size
)
out_size
[
dim
]
=
dim_size
out
=
src
.
new_full
(
out_size
,
fill_value
)
...
...
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