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-cluster
Commits
3316bdc7
Commit
3316bdc7
authored
Dec 06, 2022
by
rusty1s
Browse files
treat empty inputs gracefully
parent
5bb8d17b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
torch_cluster/knn.py
torch_cluster/knn.py
+2
-0
torch_cluster/radius.py
torch_cluster/radius.py
+2
-0
No files found.
torch_cluster/knn.py
View file @
3316bdc7
...
...
@@ -45,6 +45,8 @@ def knn(x: torch.Tensor, y: torch.Tensor, k: int,
batch_y = torch.tensor([0, 0])
assign_index = knn(x, y, 2, batch_x, batch_y)
"""
if
x
.
numel
()
==
0
or
y
.
numel
()
==
0
:
return
torch
.
empty
(
2
,
0
,
dtype
=
torch
.
long
,
device
=
x
.
device
)
x
=
x
.
view
(
-
1
,
1
)
if
x
.
dim
()
==
1
else
x
y
=
y
.
view
(
-
1
,
1
)
if
y
.
dim
()
==
1
else
y
...
...
torch_cluster/radius.py
View file @
3316bdc7
...
...
@@ -45,6 +45,8 @@ def radius(x: torch.Tensor, y: torch.Tensor, r: float,
batch_y = torch.tensor([0, 0])
assign_index = radius(x, y, 1.5, batch_x, batch_y)
"""
if
x
.
numel
()
==
0
or
y
.
numel
()
==
0
:
return
torch
.
empty
(
2
,
0
,
dtype
=
torch
.
long
,
device
=
x
.
device
)
x
=
x
.
view
(
-
1
,
1
)
if
x
.
dim
()
==
1
else
x
y
=
y
.
view
(
-
1
,
1
)
if
y
.
dim
()
==
1
else
y
...
...
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