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
d6800d66
"docs/vscode:/vscode.git/clone" did not exist on "359137104f445ce7a5d5385432b437b25519898f"
Commit
d6800d66
authored
Jun 22, 2019
by
ekagra-ranjan
Browse files
Add coalesce option to transpose
parent
2ca31691
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
README.md
README.md
+1
-0
torch_sparse/transpose.py
torch_sparse/transpose.py
+4
-3
No files found.
README.md
View file @
d6800d66
...
@@ -111,6 +111,7 @@ Transposes dimensions 0 and 1 of a sparse matrix.
...
@@ -111,6 +111,7 @@ Transposes dimensions 0 and 1 of a sparse matrix.
*
**value**
*(Tensor)*
- The value tensor of sparse matrix.
*
**value**
*(Tensor)*
- The value tensor of sparse matrix.
*
**m**
*(int)*
- The first dimension of corresponding dense matrix.
*
**m**
*(int)*
- The first dimension of corresponding dense matrix.
*
**n**
*(int)*
- The second dimension of corresponding dense matrix.
*
**n**
*(int)*
- The second dimension of corresponding dense matrix.
*
**coalesce**
*(bool, optional)*
- To return coalesced index and value or not (default:
`True`
)
### Returns
### Returns
...
...
torch_sparse/transpose.py
View file @
d6800d66
...
@@ -2,7 +2,7 @@ import torch
...
@@ -2,7 +2,7 @@ import torch
from
torch_sparse
import
to_scipy
,
from_scipy
,
coalesce
from
torch_sparse
import
to_scipy
,
from_scipy
,
coalesce
def
transpose
(
index
,
value
,
m
,
n
):
def
transpose
(
index
,
value
,
m
,
n
m
coalesce
=
True
):
"""Transposes dimensions 0 and 1 of a sparse tensor.
"""Transposes dimensions 0 and 1 of a sparse tensor.
Args:
Args:
...
@@ -10,7 +10,7 @@ def transpose(index, value, m, n):
...
@@ -10,7 +10,7 @@ def transpose(index, value, m, n):
value (:class:`Tensor`): The value tensor of sparse matrix.
value (:class:`Tensor`): The value tensor of sparse matrix.
m (int): The first dimension of corresponding dense matrix.
m (int): The first dimension of corresponding dense matrix.
n (int): The second dimension of corresponding dense matrix.
n (int): The second dimension of corresponding dense matrix.
coalesce (bool, optional): To return coalesced index and value or not (default: :obj:`True`)
:rtype: (:class:`LongTensor`, :class:`Tensor`)
:rtype: (:class:`LongTensor`, :class:`Tensor`)
"""
"""
...
@@ -22,5 +22,6 @@ def transpose(index, value, m, n):
...
@@ -22,5 +22,6 @@ def transpose(index, value, m, n):
row
,
col
=
index
row
,
col
=
index
index
=
torch
.
stack
([
col
,
row
],
dim
=
0
)
index
=
torch
.
stack
([
col
,
row
],
dim
=
0
)
index
,
value
=
coalesce
(
index
,
value
,
n
,
m
)
if
coalesce
:
index
,
value
=
coalesce
(
index
,
value
,
n
,
m
)
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