probly.representation.torch_like.TorchLike

class probly.representation.torch_like.TorchLike(*args, **kwargs)[source]

Bases: ArrayLike, Protocol, Generic

Protocol for array-like objects that implement torch-specific APIs.

property T: Any

Transposed array.

detach() Self[source]

Return a detached version of the array.

property device: Any

Device of the array.

property dtype: Any

Data type of the array.

property mH: Self

The adjoint (conjugate) transposed version of the underlying array.

property mT: Self

The transposed version of the underlying array.

property ndim: int

Number of dimensions.

numpy(*, force: bool = False) NDArray[Any][source]

Convert to a numpy array.

property shape: tuple[int, ...]

Shape of the array.

size(dim: int) int[source]
size(dim: None = None) Size

Return the size of the array along the given dimension.

to(dtype: dtype, non_blocking: bool = False, copy: bool = False, *, memory_format: memory_format = torch.preserve_format) Self[source]
to(device: device | str | None = None, dtype: dtype | None = None, non_blocking: bool = False, copy: bool = False, *, memory_format: memory_format = torch.preserve_format) Self
to(other: Tensor, non_blocking: bool = False, copy: bool = False) Self

Move and/or cast the tensor, mirroring torch.Tensor.to.

to_device(device: Literal['cpu'], /, *, stream: int | Any | None = None) Self[source]

Move the array to a device.