Unverified Commit 98ecdbed authored by Matthias Fey's avatar Matthias Fey Committed by GitHub
Browse files

Merge pull request #21 from ekagra-ranjan/master

Add coalesce option to transpose
parents 7bb2fac5 d6800d66
......@@ -112,6 +112,7 @@ Transposes dimensions 0 and 1 of a sparse matrix.
* **value** *(Tensor)* - The value tensor of sparse matrix.
* **m** *(int)* - The first 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
......
......@@ -2,7 +2,7 @@ import torch
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.
Args:
......@@ -10,7 +10,7 @@ def transpose(index, value, m, n):
value (:class:`Tensor`): The value tensor of sparse matrix.
m (int): The first 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`)
"""
......@@ -22,5 +22,6 @@ def transpose(index, value, m, n):
row, col = index
index = torch.stack([col, row], dim=0)
if coalesce:
index, value = coalesce(index, value, n, m)
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