MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / _get_tensor_stream

Function _get_tensor_stream

bitsandbytes/functional.py:393–402  ·  view source on GitHub ↗
(tensor: Tensor)

Source from the content-addressed store, hash-verified

391
392
393def _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
405def get_ptr(A: Optional[Tensor]) -> Optional[ct.c_void_p]:

Callers 3

_dequantize_4bit_implFunction · 0.90
_gemv_4bit_implFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected