dgl.sparse.SparseMatrix.cpu¶
-
SparseMatrix.
cpu
()[source]¶ Moves the matrix to CPU. If the matrix is already on CPU, the original matrix will be returned.
- Returns
The matrix on CPU
- Return type
Examples
>>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]]).to("cuda") >>> A = dglsp.spmatrix(indices, shape=(3, 4))
>>> A.cpu() SparseMatrix(indices=tensor([[1, 1, 2], [1, 2, 0]]), values=tensor([1., 1., 1.]), shape=(3, 4), nnz=3)