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
tpool_patch_merger_kernel
def tpool_patch_merger_kernel[dtype: DType, XLayout: TensorLayout, x_origin: ImmOrigin, OutLayout: TensorLayout, out_origin: MutOrigin, GridThwLayout: TensorLayout, grid_thw_origin: ImmOrigin, vec_width: Int, num_threads: Int](x_tile: TileTensor[dtype, XLayout, x_origin], out_tile: TileTensor[dtype, OutLayout, out_origin], grid_thws: TileTensor[DType.int64, GridThwLayout, grid_thw_origin], kH: Int, kW: Int, D: Int, n_vids: Int)
Temporal pooling patch merger kernel.
Averages x across the temporal dimension for each video, rearranging spatially according to the (kH, kW) merge kernel. Each video's output occupies H_i * W_i contiguous rows in the flat output tensor.
Grid mapping: block_idx.z = video index block_idx.y = patch index within the video (max_pat upper bound) block_idx.x = tile index along D thread_idx.x = lane within D tile
Parameters:
- βdtype (
DType): Element type of the input and output tensors. - βXLayout (
TensorLayout): Memory layout of the input tensorx_tile. - βx_origin (
ImmOrigin): Immutable origin of the input tensorx_tile. - βOutLayout (
TensorLayout): Memory layout of the output tensorout_tile. - βout_origin (
MutOrigin): Mutable origin of the output tensorout_tile. - βGridThwLayout (
TensorLayout): Memory layout of the grid dimensions tensorgrid_thws. - βgrid_thw_origin (
ImmOrigin): Immutable origin of the grid dimensions tensorgrid_thws. - βvec_width (
Int): SIMD vector width for loads and stores along the hidden dimension. - βnum_threads (
Int): Number of threads per block.
Args:
- βx_tile (
TileTensor[dtype, XLayout, x_origin]): Input tensor [n_tokens, D]. - βout_tile (
TileTensor[dtype, OutLayout, out_origin]): Contiguous output tensor [total_output_patches, D]. - βgrid_thws (
TileTensor[DType.int64, GridThwLayout, grid_thw_origin]): Grid dimensions tensor [n_vids, 3] with (T, H, W) per video. - βkH (
Int): Merge kernel height. - βkW (
Int): Merge kernel width. - βD (
Int): Hidden dimension. - βn_vids (
Int): Number of videos.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!