(tensor: Tensor)
| 391 | |
| 392 | |
| 393 | def _get_tensor_stream(tensor: Tensor) -> ct.c_void_p: |
| 394 | # We use the raw stream for performance reasons. |
| 395 | if tensor.device.type == "cuda": |
| 396 | return ct.c_void_p(torch._C._cuda_getCurrentRawStream(tensor.device.index)) |
| 397 | if tensor.device.type == "xpu": |
| 398 | return ct.c_void_p(torch._C._xpu_getCurrentRawStream(tensor.device.index)) |
| 399 | # For CPU tensors (e.g. paged optimizer states), use current device's stream. |
| 400 | if hasattr(torch, "xpu") and torch.xpu.is_available(): |
| 401 | return ct.c_void_p(torch._C._xpu_getCurrentRawStream(torch.xpu.current_device())) |
| 402 | return ct.c_void_p(torch._C._cuda_getCurrentRawStream(torch.cuda.current_device())) |
| 403 | |
| 404 | |
| 405 | def get_ptr(A: Optional[Tensor]) -> Optional[ct.c_void_p]: |
no outgoing calls
no test coverage detected