"docs/vscode:/vscode.git/clone" did not exist on "359137104f445ce7a5d5385432b437b25519898f"
Commit d6800d66 authored by ekagra-ranjan's avatar ekagra-ranjan
Browse files

Add coalesce option to transpose

parent 2ca31691
...@@ -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
......
...@@ -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, nm 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment