Skip to content

Tensor

Ndonnx-backed tensor that ducktypes as torch.Tensor.

Tensor objects may also be used in the torch functions listed here.

Methods:

Attributes:

  • device (None) –

    The device on which the data is allocated.

  • dtype (dtype) –

    See `torch.Tensor.dtype for details.

  • shape (int | Tensor | tuple[int | Tensor, ...]) –

    The shape of the tensor.

device property

device: None

The device on which the data is allocated.

This is always None since the concept does not apply to ONNX export

dtype property

dtype: dtype

See `torch.Tensor.dtype for details.

shape property

shape: int | Tensor | tuple[int | Tensor, ...]

The shape of the tensor.

Contrary to pytorch.Tensor.shape, this function may return Tensor objects for dimensions with a dynamic length.

argmax

argmax(
    dim: None | int = None,
    keepdim: bool = False,
    *,
    out: None | Tensor = None,
) -> Tensor

See torch.Tensor.argmax for details.

argmin

argmin(
    dim: None | int = None,
    keepdim: bool = False,
    *,
    out: None | Tensor = None,
) -> Tensor

See torch.Tensor.argmin for details.

chunk

chunk(chunks: int, dim: int = 0) -> tuple[Tensor, ...]

See torch.Tensor.chunk for details.

contiguous

contiguous(memory_format=contiguous_format) -> Tensor

See torch.Tensor.contiguous for details.

dim

dim() -> int

See torch.Tensor.dim for details.

expand

expand(*sizes: int | Size | Tensor) -> Tensor

See torch.Tensor.expand for details.

masked_fill

masked_fill(mask: Tensor, value: float)

See torch.Tensor.masked_fill for details.

mean

mean(
    dim: int | tuple[int, ...] | None = None,
    keepdim: bool = False,
    *,
    dtype: dtype | None = None,
) -> Tensor

See torch.Tensor.mean for details.

ndim

ndim() -> int

Return the rank of this tensor.

size

size(
    dim: int | None = None,
) -> int | Tensor | tuple[int | Tensor, ...]

The size of the tensor.

Contrary to pytorch.Tensor.size, this function may return Tensor objects for dimensions with a dynamic length.

to

to(dtype: dtype) -> Tensor

See torch.Tensor.to for details.

to_ndonnx

to_ndonnx() -> Array

Return the inner ndonnx array.

transpose

transpose(dim0: int, dim1: int) -> Tensor

See torch.Tensor.transpose for details.

unwrap_numpy

unwrap_numpy() -> ndarray

Return the result of constant value propagation or raise a ValueError.

This function is primarily useful for debugging and testing. It only returns a value if the value does not depend on any graph inputs. However, if that is the case in production code, such a value should be stored as a NumPy array or pytorch Tensor in the first place.

view

view(*shape: int | Size) -> Self

See torch.Tensor.view for details.