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 inputTileTensor. - βinput_origin (
ImmOrigin): Origin (mutability) of the inputTileTensor. - βOutputLayoutType (
TensorLayout): Layout type of the outputTileTensor. - βoutput_origin (
MutOrigin): Origin (mutability) of the outputTileTensor. - βdtype (
DType): Element type of the tensors. - βsimd_width (
Int): SIMD vector width used for the coalesced row copy.
Args:
- βinput_tensor (
TileTensor[dtype, InputLayoutType, input_origin]): SourceTileTensorof contiguous row-major data. - βoutput_tensor (
TileTensor[dtype, OutputLayoutType, output_origin]): DestinationTileTensorwhose layout maps each row to its padded output position. - βrows_per_sm (
Int): Maximum rows assigned to a single thread block. - βtotal_rows (
Int): Total number of rows to copy. - βrow_length (
Int): Number of elements in each row.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!