block_major_position_ids

Function block_major_position_ids 

Source
pub fn block_major_position_ids(
    grid_h: usize,
    grid_w: usize,
    merge: usize,
) -> Vec<(u32, u32)>
Expand description

Per-token (h_id, w_id) in the reference’s block-major order.

get_vision_position_ids builds meshgrid(arange(h), arange(w)), reshapes to (h/m, m, w/m, m), transpose(1, 2) and flattens — i.e. the outer loop walks 2×2 merge blocks in raster order and the inner loop walks the four positions inside each block. The image processor’s patchify() uses the identical nesting (permute(0, 2, 5, 3, 6, 1, 4, 7)), which is what lets the tower’s view(-1, 2, 2, C) be a free reshape.