Skip to content

Combining

XTensor methods that join several tensors (or contract a tensor against itself/another), reconciling names across the operands: concatenation/stacking, and the matrix-product family.

Bases: ExtendedTensor

A tensor with named dimensions and, optionally, per-dimension coordinate labels -- an xarray-like DataArray over a live torch.Tensor.

  • Dimensions are named through names (self-managed in _axis_names, independent of PyTorch's experimental builtin named-tensor feature, so the class works even where that API has been removed).
  • Coordinates label the positions along a named dimension. They live in coords -- a mapping dim name -> labels -- keyed by dimension name, so they follow their dimension through reshaping/reordering with no positional bookkeeping. A labelled dimension must be named.
  • Axis descriptors may enrich a name with extra fields -- any custom key you like (type is the OME-NGFF convention shown in examples; orientation is the one field with built-in behaviour) -- passed as a dict in place of a bare name ({"name": "x", "type": "space"}). names stays the ergonomic view (bare names); axes returns the full descriptors. The extra fields live in _axis_meta, keyed by dimension name, so they follow the dimension like coordinates do.

Select by label with sel, by integer position with isel, or reach a single label by attribute (x.red).

Methods:

bmm

bmm(*args, **kwargs) -> tx.Any

Name-aware torch.bmm: behaves like torch.bmm, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.bmm for the full numerical behaviour.

cat

cat(*args, **kwargs) -> XTensor

Name-aware torch.cat: behaves like torch.cat, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.cat for the full numerical behaviour.

dstack

dstack(*args, **kwargs) -> tx.Any

Name-aware torch.dstack: behaves like torch.dstack, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.dstack for the full numerical behaviour.

einsum

einsum(*args: typing.Any, **kwargs) -> <class 'torch.Tensor'>

Name-aware torch.einsum: behaves like torch.einsum, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.einsum for the full numerical behaviour.

hstack

hstack(*args, **kwargs) -> tx.Any

Name-aware torch.hstack: behaves like torch.hstack, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.hstack for the full numerical behaviour.

matmul

matmul(*args, **kwargs) -> tx.Any

Name-aware torch.matmul: behaves like torch.matmul, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.matmul for the full numerical behaviour.

mm

mm(*args, **kwargs) -> tx.Any

Name-aware torch.mm: behaves like torch.mm, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.mm for the full numerical behaviour.

stack

stack(*args, **kwargs) -> XTensor

Name-aware torch.stack: behaves like torch.stack, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.stack for the full numerical behaviour.

tensordot

tensordot(*args, **kwargs)

Name-aware torch.tensordot: behaves like torch.tensordot, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.tensordot for the full numerical behaviour.

vstack

vstack(*args, **kwargs) -> tx.Any

Name-aware torch.vstack: behaves like torch.vstack, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.vstack for the full numerical behaviour.