dgl.sparse.SparseMatrix.cpu
- SparseMatrix.cpu()[source]
将矩阵移动到CPU。如果矩阵已经在CPU上,将返回原始矩阵。
- Returns:
CPU上的矩阵
- Return type:
示例
>>> 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)