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
2c883ba3
Commit
2c883ba3
authored
Mar 17, 2019
by
rusty1s
Browse files
fixed print statements
parent
ee2d323d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
README.md
README.md
+14
-11
No files found.
README.md
View file @
2c883ba3
...
...
@@ -81,7 +81,7 @@ from torch_sparse import coalesce
index
=
torch
.
tensor
([[
1
,
0
,
1
,
0
,
2
,
1
],
[
0
,
1
,
1
,
1
,
0
,
0
]])
value
=
torch
.
t
ensor
([[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
4
,
5
],
[
5
,
6
],
[
6
,
7
]])
value
=
torch
.
T
ensor
([[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
4
,
5
],
[
5
,
6
],
[
6
,
7
]])
index
,
value
=
coalesce
(
index
,
value
,
m
=
3
,
n
=
2
)
```
...
...
@@ -91,7 +91,10 @@ print(index)
tensor([[0, 1, 1, 2],
[1, 0, 1, 0]])
print(value)
tensor([[6, 8], [7, 9], [3, 4], [5, 6]])
tensor([[6.0, 8.0],
[7.0, 9.0],
[3.0, 4.0],
[5.0, 6.0]])
```
## Transpose
...
...
@@ -121,7 +124,7 @@ from torch_sparse import transpose
index
=
torch
.
tensor
([[
1
,
0
,
1
,
0
,
2
,
1
],
[
0
,
1
,
1
,
1
,
0
,
0
]])
value
=
torch
.
t
ensor
([[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
4
,
5
],
[
5
,
6
],
[
6
,
7
]])
value
=
torch
.
T
ensor
([[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
4
,
5
],
[
5
,
6
],
[
6
,
7
]])
index
,
value
=
transpose
(
index
,
value
,
3
,
2
)
```
...
...
@@ -131,10 +134,10 @@ print(index)
tensor([[0, 0, 1, 1],
[1, 2, 0, 1]])
print(value)
tensor([[7, 9],
[5, 6],
[6, 8],
[3, 4]])
tensor([[7
.0
, 9
.0
],
[5
.0
, 6
.0
],
[6
.0
, 8
.0
],
[3
.0
, 4
.0
]])
```
## Sparse Dense Matrix Multiplication
...
...
@@ -163,8 +166,8 @@ from torch_sparse import spmm
index
=
torch
.
tensor
([[
0
,
0
,
1
,
2
,
2
],
[
0
,
2
,
1
,
0
,
1
]])
value
=
torch
.
t
ensor
([
1
,
2
,
4
,
1
,
3
]
,
dtype
=
torch
.
float
)
matrix
=
torch
.
t
ensor
([[
1
,
4
],
[
2
,
5
],
[
3
,
6
]]
,
dtype
=
torch
.
float
)
value
=
torch
.
T
ensor
([
1
,
2
,
4
,
1
,
3
])
matrix
=
torch
.
T
ensor
([[
1
,
4
],
[
2
,
5
],
[
3
,
6
]])
out
=
spmm
(
index
,
value
,
3
,
matrix
)
```
...
...
@@ -206,10 +209,10 @@ Both input sparse matrices need to be **coalesced**.
from
torch_sparse
import
spspmm
indexA
=
torch
.
tensor
([[
0
,
0
,
1
,
2
,
2
],
[
1
,
2
,
0
,
0
,
1
]])
valueA
=
torch
.
t
ensor
([
1
,
2
,
3
,
4
,
5
]
,
dtype
=
torch
.
float
)
valueA
=
torch
.
T
ensor
([
1
,
2
,
3
,
4
,
5
])
indexB
=
torch
.
tensor
([[
0
,
2
],
[
1
,
0
]])
valueB
=
torch
.
t
ensor
([
2
,
4
]
,
dtype
=
torch
.
float
)
valueB
=
torch
.
T
ensor
([
2
,
4
])
indexC
,
valueC
=
spspmm
(
indexA
,
valueA
,
indexB
,
valueB
,
3
,
3
,
2
)
```
...
...
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