k2.array

class k2.Array(data, arcs=False)[source]

This class wraps k2::Array1<T> and k2::Array2<T> from C++.

It has only one method tensor() which returns a torch.Tensor.

__init__(data, arcs=False)[source]

Construct an Array from a torch.Tensor or from one of k2::Array1<T> and k2::Array2<T>.

Parameters
  • data (Union[Tensor, _ArcArray1, _FloatArray1, _FloatArray2, _Int32Array1, _Int32Array2]) – An instance of Array1<T>, Array2<T> or a torch.Tensor.

  • arcs (bool) – True if data represents arcs information; we will check that data has 4 columns and is of type torch.int32.

tensor()[source]

Return a torch.Tensor sharing memory with the underlying Array.

Return type

Tensor