Unverified Commit ee5f0967 authored by Mufei Li's avatar Mufei Li Committed by GitHub
Browse files
parent 4ecd2c85
......@@ -73,7 +73,7 @@ def sp_add(
"The shape of sparse matrix A {} and"
" B {} are expected to match".format(A.shape, B.shape)
)
C = A.adj + B.adj
C = (A.adj + B.adj).coalesce()
return SparseMatrix(C.indices()[0], C.indices()[1], C.values(), C.shape)
raise RuntimeError(
"Elementwise addition between {} and {} is not "
......
......@@ -62,7 +62,7 @@ class SparseMatrix:
shape: Optional[Tuple[int, int]] = None,
):
if val is None:
val = torch.ones(row.shape[0])
val = torch.ones(row.shape[0]).to(row.device)
i = torch.cat((row.unsqueeze(0), col.unsqueeze(0)), 0)
if shape is None:
self.adj = torch.sparse_coo_tensor(i, val).coalesce()
......
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