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
50909651
Commit
50909651
authored
Nov 15, 2018
by
rusty1s
Browse files
replaced scatter add
parent
e1180216
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
torch_cluster/sample.py
torch_cluster/sample.py
+3
-1
No files found.
torch_cluster/sample.py
View file @
50909651
...
...
@@ -8,7 +8,9 @@ def batch_slices(batch, sizes=False, include_ends=True):
"""
Calculates size, start and end indices for each element in a batch.
"""
size
=
torch
.
scatter_add_
(
torch
.
ones_like
(
batch
),
batch
)
batch_size
=
batch
.
max
().
item
()
+
1
size
=
batch
.
new_zeros
(
batch_size
).
scatter_add_
(
0
,
batch
,
torch
.
ones_like
(
batch
))
cumsum
=
torch
.
cumsum
(
size
,
dim
=
0
)
starts
=
cumsum
-
size
ends
=
cumsum
-
1
...
...
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