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)
| 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 |
no test coverage detected