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
b8fb93bd
Commit
b8fb93bd
authored
Aug 04, 2018
by
rusty1s
Browse files
clean up
parent
c3155ab6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
torch_sparse/coalesce.py
torch_sparse/coalesce.py
+5
-7
No files found.
torch_sparse/coalesce.py
View file @
b8fb93bd
...
@@ -6,16 +6,14 @@ def coalesce(index, value, size, op='add', fill_value=0):
...
@@ -6,16 +6,14 @@ def coalesce(index, value, size, op='add', fill_value=0):
m
,
n
=
size
m
,
n
=
size
row
,
col
=
index
row
,
col
=
index
index
=
row
*
n
+
col
unique
,
inv
=
torch
.
unique
(
row
*
n
+
col
,
sorted
=
True
,
return_inverse
=
True
)
unique
,
inv
=
torch
.
unique
(
index
,
sorted
=
True
,
return_inverse
=
True
)
perm
=
torch
.
arange
(
in
dex
.
size
(
0
),
dtype
=
in
dex
.
dtype
,
device
=
in
dex
.
device
)
perm
=
torch
.
arange
(
in
v
.
size
(
0
),
dtype
=
in
v
.
dtype
,
device
=
in
v
.
device
)
perm
=
in
dex
.
new_empty
(
inv
.
max
().
item
()
+
1
).
scatter_
(
0
,
inv
,
perm
)
perm
=
in
v
.
new_empty
(
inv
.
max
().
item
()
+
1
).
scatter_
(
0
,
inv
,
perm
)
index
=
torch
.
stack
([
row
[
perm
],
col
[
perm
]],
dim
=
0
)
index
=
torch
.
stack
([
row
[
perm
],
col
[
perm
]],
dim
=
0
)
if
value
is
not
None
:
if
value
is
not
None
:
scatter
=
getattr
(
torch_scatter
,
'scatter_{}'
.
format
(
op
))
op
=
getattr
(
torch_scatter
,
'scatter_{}'
.
format
(
op
))
value
=
scatter
(
value
=
op
(
value
,
inv
,
0
,
None
,
perm
.
size
(
0
),
fill_value
)
value
,
inv
,
dim
=
0
,
dim_size
=
perm
.
size
(
0
),
fill_value
=
fill_value
)
return
index
,
value
return
index
,
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