ensured row major ordering

This commit is contained in:
Chintan Shah 2019-10-06 15:53:14 -04:00
parent 6331173f44
commit d46b605a65
1 changed files with 2 additions and 1 deletions

View File

@ -74,9 +74,10 @@ class DCGRUCell(torch.nn.Module):
def _build_sparse_matrix(L): def _build_sparse_matrix(L):
L = L.tocoo() L = L.tocoo()
indices = np.column_stack((L.row, L.col)) indices = np.column_stack((L.row, L.col))
# this is to ensure row-major ordering to equal torch.sparse.sparse_reorder(L)
indices = indices[np.lexsort((indices[:, 0], indices[:, 1]))]
L = torch.sparse_coo_tensor(indices.T, L.data, L.shape, device=device) L = torch.sparse_coo_tensor(indices.T, L.data, L.shape, device=device)
return L return L
# return torch.sparse.sparse_reorder(L)
def forward(self, inputs, hx): def forward(self, inputs, hx):
"""Gated recurrent unit (GRU) with Graph Convolution. """Gated recurrent unit (GRU) with Graph Convolution.