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
8abdc5f0
Commit
8abdc5f0
authored
Aug 21, 2018
by
rusty1s
Browse files
test max coalesce
parent
afccb12e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
test/test_coalesce.py
test/test_coalesce.py
+12
-1
No files found.
test/test_coalesce.py
View file @
8abdc5f0
...
...
@@ -2,7 +2,7 @@ import torch
from
torch_sparse
import
coalesce
def
test_coalesce
():
def
test_coalesce
_add
():
row
=
torch
.
tensor
([
1
,
0
,
1
,
0
,
2
,
1
])
col
=
torch
.
tensor
([
0
,
1
,
1
,
1
,
0
,
0
])
index
=
torch
.
stack
([
row
,
col
],
dim
=
0
)
...
...
@@ -11,3 +11,14 @@ def test_coalesce():
index
,
value
=
coalesce
(
index
,
value
,
m
=
3
,
n
=
2
)
assert
index
.
tolist
()
==
[[
0
,
1
,
1
,
2
],
[
1
,
0
,
1
,
0
]]
assert
value
.
tolist
()
==
[[
6
,
8
],
[
7
,
9
],
[
3
,
4
],
[
5
,
6
]]
def
test_coalesce_max
():
row
=
torch
.
tensor
([
1
,
0
,
1
,
0
,
2
,
1
])
col
=
torch
.
tensor
([
0
,
1
,
1
,
1
,
0
,
0
])
index
=
torch
.
stack
([
row
,
col
],
dim
=
0
)
value
=
torch
.
tensor
([[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
4
,
5
],
[
5
,
6
],
[
6
,
7
]])
index
,
value
=
coalesce
(
index
,
value
,
m
=
3
,
n
=
2
,
op
=
'max'
)
assert
index
.
tolist
()
==
[[
0
,
1
,
1
,
2
],
[
1
,
0
,
1
,
0
]]
assert
value
.
tolist
()
==
[[
4
,
5
],
[
6
,
7
],
[
3
,
4
],
[
5
,
6
]]
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