block_major_patch_index

Function block_major_patch_index 

Source
pub fn block_major_patch_index(
    patch_row: usize,
    patch_col: usize,
    grid_w: usize,
    merge: usize,
) -> usize
Expand description

Index of the patch at (patch_row, patch_col) in the 2×2-block-major stream the GLM tower expects.

((h_block * w_blocks + w_block) * merge + row_in_block) * merge + col_in_block — the flattening of reshape(h/m, m, w/m, m).transpose(1, 2). The 2×2 conv downsample later folds four CONSECUTIVE tokens into one output row, which is correct only under exactly this order.