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).

Mojo function

padded_copy_kernel

def padded_copy_kernel[InputLayoutType: TensorLayout, input_origin: ImmOrigin, OutputLayoutType: TensorLayout, output_origin: MutOrigin, dtype: DType, simd_width: Int](input_tensor: TileTensor[dtype, InputLayoutType, input_origin], output_tensor: TileTensor[dtype, OutputLayoutType, output_origin], rows_per_sm: Int, total_rows: Int, row_length: Int)

Copies rows from input_tensor into the unpadded region of output_tensor using a cooperatively vectorized, coalesced row copy.

Each block processes rows_per_sm rows (clamped to total_rows), and threads along the x-dimension cooperate on a single row via _vectorized_copy_row, advancing through rows in steps of block_dim.y. The input is treated as a flat row-major buffer of total_rows rows each of length row_length, while the output offset for each row is derived from output_tensor's layout so the copy lands in the correct position within the padded output.

Parameters:

  • ​InputLayoutType (TensorLayout): Layout type of the input TileTensor.
  • ​input_origin (ImmOrigin): Origin (mutability) of the input TileTensor.
  • ​OutputLayoutType (TensorLayout): Layout type of the output TileTensor.
  • ​output_origin (MutOrigin): Origin (mutability) of the output TileTensor.
  • ​dtype (DType): Element type of the tensors.
  • ​simd_width (Int): SIMD vector width used for the coalesced row copy.

Args:

Was this page helpful?