module documentation

Infer conventional dimension labels for model tensor shapes.

Function make_default_layout Create a likely tensor layout for a shape.
def make_default_layout(shape: list[int]) -> str: ΒΆ

Create a likely tensor layout for a shape.

The function recognizes common channel-first and channel-last image shapes. Unrecognized dimensions receive unused letters in alphabetical order.

Example

>>> make_default_layout([1, 3, 256, 256])
'NCHW'
>>> make_default_layout([1, 19, 7, 8])
'NABC'
Parameters
shape:list[int]Tensor dimensions.
Returns
strInferred layout with one letter per dimension.