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
spatial_merge_kernel
def spatial_merge_kernel[dtype: DType, InputLayoutType: TensorLayout, input_origin: ImmOrigin, OutputLayoutType: TensorLayout, output_origin: MutOrigin, GridThwLayoutType: TensorLayout, grid_thw_origin: ImmOrigin](output: TileTensor[dtype, OutputLayoutType, output_origin], input: TileTensor[dtype, InputLayoutType, input_origin], grid_thw: TileTensor[DType.int64, GridThwLayoutType, grid_thw_origin], batch_size: Int, hidden_size: Int, merge_size: Int)
Spatial merge kernel.
Grid: 1D over all output patches (one block per output patch). Threads: loop over channels (hidden_size x merge_size^2).
Parameters:
- βdtype (
DType): Element type of the input and output tensors. - βInputLayoutType (
TensorLayout): Compile-timeTensorLayoutof the input tensor. - βinput_origin (
ImmOrigin): Immutable origin of the input tensor. - βOutputLayoutType (
TensorLayout): Compile-timeTensorLayoutof the output tensor. - βoutput_origin (
MutOrigin): Mutable origin of the output tensor. - βGridThwLayoutType (
TensorLayout): Compile-timeTensorLayoutof thegrid_thwtensor. - βgrid_thw_origin (
ImmOrigin): Immutable origin of thegrid_thwtensor.
Args:
- βoutput (
TileTensor[dtype, OutputLayoutType, output_origin]): Output tensor. - βinput (
TileTensor[dtype, InputLayoutType, input_origin]): Input tensor. - βgrid_thw (
TileTensor[DType.int64, GridThwLayoutType, grid_thw_origin]): Grid dimensions tensor (B, 3) containing [t, h, w] for each item. - βbatch_size (
Int): Number of items in batch. - βhidden_size (
Int): Hidden dimension size. - βmerge_size (
Int): Size of spatial merge blocks.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!