dgl.sparse.SparseMatrix.cuda
- SparseMatrix.cuda()[source]
将矩阵移动到GPU。如果矩阵已经在GPU上,将返回原始矩阵。如果存在多个GPU设备,将选择
cuda:0
。- Returns:
GPU上的矩阵
- Return type:
示例
>>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]]) >>> A = dglsp.spmatrix(indices, shape=(3, 4)) >>> A.cuda() SparseMatrix(indices=tensor([[1, 1, 2], [1, 2, 0]], device='cuda:0'), values=tensor([1., 1., 1.], device='cuda:0'), shape=(3, 4), nnz=3)