IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

TensorLayout

TensorLayout

class max.experimental.sharding.TensorLayout(dtype, shape, mapping)

source

Bases: DeviceMapping

Metadata snapshot of a distributed tensor for rule evaluation.

Bundles the tensor’s dtype, shape, and distribution mapping. The mapping stays abstract (DeviceMapping) so rules work with any concrete mapping type, such as PlacementMapping or NamedMapping.

The shape is a Shape (list[Dim]), supporting both static and symbolic dimensions for graph compilation compatibility.

This class implements DeviceMapping, so sharding rules can return input TensorLayouts directly.

Parameters:

dtype

dtype: DType

source

The element data type of the tensor.

mapping

mapping: DeviceMapping

source

The distribution mapping over the device mesh.

rank

property rank: int

source

The number of dimensions.

shape

shape: Shape

source

The global shape of the tensor.