MCPcopy
hub / github.com/dmlc/dgl / cuda

Method cuda

python/dgl/sparse/sparse_matrix.py:297–318  ·  view source on GitHub ↗

Moves the matrix to GPU. If the matrix is already on GPU, the original matrix will be returned. If multiple GPU devices exist, ``cuda:0`` will be selected. Returns ------- SparseMatrix The matrix on GPU Examples --------

(self)

Source from the content-addressed store, hash-verified

295 return from_coo(row, col, val, self.shape)
296
297 def cuda(self):
298 """Moves the matrix to GPU. If the matrix is already on GPU, the
299 original matrix will be returned. If multiple GPU devices exist,
300 ``cuda:0`` will be selected.
301
302 Returns
303 -------
304 SparseMatrix
305 The matrix on GPU
306
307 Examples
308 --------
309
310 >>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]])
311 >>> A = dglsp.spmatrix(indices, shape=(3, 4))
312 >>> A.cuda()
313 SparseMatrix(indices=tensor([[1, 1, 2],
314 [1, 2, 0]], device='cuda:0'),
315 values=tensor([1., 1., 1.], device='cuda:0'),
316 shape=(3, 4), nnz=3)
317 """
318 return self.to(device="cuda")
319
320 def cpu(self):
321 """Moves the matrix to CPU. If the matrix is already on CPU, the

Callers 15

copy_toFunction · 0.80
readMethod · 0.80
call_once_and_shareFunction · 0.80
test_pin_memoryFunction · 0.80
test_copy_from_gpuFunction · 0.80
test_subframesFunction · 0.80
test_subgraph.pyFile · 0.80
test_to_deviceFunction · 0.80
test_to_device2Function · 0.80
test_pin_memory_Function · 0.80
test_neighbor_nonuniformFunction · 0.80
_ddp_runnerFunction · 0.80

Calls 1

toMethod · 0.95

Tested by 14

test_pin_memoryFunction · 0.64
test_copy_from_gpuFunction · 0.64
test_subframesFunction · 0.64
test_to_deviceFunction · 0.64
test_to_device2Function · 0.64
test_pin_memory_Function · 0.64
test_neighbor_nonuniformFunction · 0.64
_ddp_runnerFunction · 0.64
test_node_dataloaderFunction · 0.64
test_edge_dataloaderFunction · 0.64
test_knn_cudaFunction · 0.64
test_index_select_cscFunction · 0.64