Skip to main content
CUTLASS supports various memory layouts for tensors. The layout determines how multi-dimensional tensors are stored in linear memory.

LayoutType Enum

The cutlass.LayoutType enum defines available memory layouts:

Basic Layouts

LayoutType.RowMajor

Row-major layout (C/C++ convention). Consecutive elements in a row are stored contiguously in memory.
For a matrix with shape (M, N), element at position (i, j) is at memory offset: i * N + j Use case: Standard for C/C++ applications and most PyTorch operations.

LayoutType.ColumnMajor

Column-major layout (Fortran/BLAS convention). Consecutive elements in a column are stored contiguously in memory.
For a matrix with shape (M, N), element at position (i, j) is at memory offset: j * M + i Use case: Interoperability with BLAS libraries, Fortran code, and column-major frameworks.

Interleaved Layouts

Interleaved layouts pack multiple elements together for improved memory access patterns with certain data types.

LayoutType.ColumnMajorInterleaved2

Column-major with 2-way interleaving.
Use case: Optimized access for 2-byte data types.

LayoutType.RowMajorInterleaved2

Row-major with 2-way interleaving.

LayoutType.ColumnMajorInterleaved32

Column-major with 32-way interleaving.
Use case: INT4/INT8 operations on Tensor Cores.

LayoutType.RowMajorInterleaved32

Row-major with 32-way interleaving.

LayoutType.ColumnMajorInterleaved64

Column-major with 64-way interleaving.

LayoutType.RowMajorInterleaved64

Row-major with 64-way interleaving.

Tensor Layouts

Tensor layouts are used for convolution operations and multi-dimensional tensors.

LayoutType.TensorNHWC

Tensor layout with dimensions ordered as (N, H, W, C) - commonly used in computer vision.
  • N: Batch size
  • H: Height
  • W: Width
  • C: Channels
Use case: Standard for image processing and CNNs in frameworks like TensorFlow.

LayoutType.TensorNCHW

Tensor layout with dimensions ordered as (N, C, H, W).
Use case: Standard for PyTorch CNNs and cuDNN operations.

LayoutType.TensorNDHWC

5D tensor layout for 3D convolutions: (N, D, H, W, C).
Use case: 3D convolutions in video processing and volumetric data.

LayoutType.TensorNWC

3D tensor layout: (N, W, C).
Use case: 1D convolutions and sequence processing.

Layout Selection Guide

Performance Considerations

Rule of Thumb: Use the layout that matches your input data to avoid expensive transpose operations.

Alignment Requirements

Some layouts require specific alignment:
  • Interleaved layouts require dimensions divisible by interleaving factor
  • TensorCore operations may require 8-byte or 16-byte alignment

Layout Conversion

PyTorch Transpose

Convert between row-major and column-major in PyTorch:

NumPy Transpose

Layout in GEMM Operations

Example: Row-Major GEMM

Example: Mixed Layouts

Layout Naming Convention

CUTLASS uses shorthand notation in kernel names:

C++ Mapping

Python layout types map directly to C++ CUTLASS layout types:

Source Code References

See Also