MCPcopy Index your code
hub / github.com/dmlc/dgl / cpu

Method cpu

python/dgl/sparse/sparse_matrix.py:320–341  ·  view source on GitHub ↗

Moves the matrix to CPU. If the matrix is already on CPU, the original matrix will be returned. Returns ------- SparseMatrix The matrix on CPU Examples -------- >>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]]).to("cuda")

(self)

Source from the content-addressed store, hash-verified

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
322 original matrix will be returned.
323
324 Returns
325 -------
326 SparseMatrix
327 The matrix on CPU
328
329 Examples
330 --------
331
332 >>> indices = torch.tensor([[1, 1, 2], [1, 2, 0]]).to("cuda")
333 >>> A = dglsp.spmatrix(indices, shape=(3, 4))
334
335 >>> A.cpu()
336 SparseMatrix(indices=tensor([[1, 1, 2],
337 [1, 2, 0]]),
338 values=tensor([1., 1., 1.]),
339 shape=(3, 4), nnz=3)
340 """
341 return self.to(device="cpu")
342
343 def float(self):
344 """Converts the matrix values to float32 data type. If the matrix

Callers 15

gather_mmFunction · 0.45
__init__Method · 0.45
pack_tracesFunction · 0.45
_sample_laborsFunction · 0.45
node2vec_random_walkFunction · 0.45
_prepare_edge_arraysFunction · 0.45
sample_etype_neighborsFunction · 0.45
select_topkFunction · 0.45
_dispatchMethod · 0.45
tousertensorMethod · 0.45
set_itemsMethod · 0.45
append_zerosMethod · 0.45

Calls 1

toMethod · 0.95

Tested by

no test coverage detected