For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
flatten_leading
def flatten_leading[dtype: DType, layout: TensorLayout, //](tensor: TileTensor[dtype, layout, Engine=tensor.Engine, address_space=tensor.address_space, linear_idx_type=tensor.linear_idx_type]) -> TileTensor[dtype, Layout[TypeList[Int64, layout.__shape_types[SIMDLength((layout.rank - Int(1)))]](), TypeList[#kgen.param_list.concat(Scalar[layout.__shape_types[SIMDLength((layout.rank - Int(1)))].DTYPE if (xor layout.__shape_types[SIMDLength((layout.rank - Int(1)))].is_static_value, True) else DType.int] if (xor layout.__shape_types[SIMDLength((layout.rank - Int(1)))].is_static_value, True) if (xor layout.__shape_types[SIMDLength((layout.rank - Int(1)))].is_static_value, True) else False else ComptimeInt[layout.__shape_types[SIMDLength((layout.rank - Int(1)))].static_value], ComptimeInt[Int(1)])]()], tensor.origin, Engine=tensor.Engine, address_space=tensor.address_space]
Merge the first two dimensions of a rank-3 TileTensor: (A, B, C) -> (A*B, C).
Returns a new TileTensor sharing the same pointer with row-major strides computed from the merged shape. Zero-cost operation.
Common use case: converting 3D batched tensors (num_experts, N, K) to 2D (num_experts*N, K) for TMA descriptor creation in MoE kernels.
Parameters:
- โdtype (
DType): Element type (inferred from tensor). - โlayout (
TensorLayout): Layout type (inferred from tensor).
Args:
- โtensor (
TileTensor[dtype, layout, Engine=tensor.Engine, address_space=tensor.address_space, linear_idx_type=tensor.linear_idx_type]): A rank-3 TileTensor.
Returns: