Shape¶
- class Shape(*shape: int | None)[source]¶
Bases:
objectTensor shape with support for placeholder dimensions.
- Parameters:
*shape (int | None) – dimensions of the tensor, either positive integers for fixed dimensions or none for unspecified dimensions.
Important
Scalar tensors (i.e. tensors with no dimensions) are unsupported, as are tensors with any dimension of size 0.
- coalesce(tensor: Tensor) tuple[Tensor, dict[str, int]][source]¶
Coalesces a tensor into a matrix, with placeholder dimensions first and fixed dimensions second.
For a tensor with \(V_1, \ldots, V_m\) placeholder dimensions and \(C_1, \ldots, C_n\) fixed dimensions, the output matrix will have a shape of \((V_1 \times \cdots \times V_m) \times (C_1 \times \cdots \times C_n)\), and dimensions of unit length will used if the tensor has no placeholder/fixed dimensions.
- disperse(tensor: Tensor, pragma: dict[str, int]) Tensor[source]¶
Disperses dimensions of a coalesced tensor to their original positions.
- property nconcrete: int¶
Number of fixed dimensions.
- Returns:
number of concrete dimensions.
- Return type:
- property ndim: int¶
Number of dimensions specified by the shape.
- Returns:
dimensionality of a compatible tensor.
- Return type:
- property nvirtual: int¶
Number of placeholder dimensions.
- Returns:
number of virtual dimensions.
- Return type: