DeviceMixin#

class sdm.tensor.mixin.DeviceMixin#

Add torch.Tensor-like device capabilities to an object.

to(device: device | str | None, *, non_blocking: bool = False) → Self#

Perform device conversion.

Parameters:
  • device (device | str | None) – The device.

  • non_blocking (bool) – If True and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect.

Return type:

Self

cpu() → Self#

Copy data in CPU memory.

Return type:

Self

cuda(device: device | str | int | None = None, *, non_blocking: bool = False) → Self#

Copy data in CUDA memory.

Parameters:
  • device (device | str | int | None) – The device.

  • non_blocking (bool) – If True and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect.

Return type:

Self

property device: device#

The torch.device where the data is.

property is_cpu: bool#

Whether the data is stored on the CPU.

property is_cuda: bool#

Whether the data is stored on the GPU.

pin_memory() → Self#

Copy data to pinned memory, if it is not already pinned.

Return type:

Self

is_pinned() → bool#

Returns True if data resides in pinned memory.

Return type:

bool