pub fn smart_resize(
h: u32,
w: u32,
factor: u32,
min_pixels: u64,
max_pixels: u64,
) -> (u32, u32)Expand description
Qwen2-VL-family smart_resize, which GLM inherits: snap each side to the
nearest multiple of factor, then rescale by the area bound if the snapped
canvas violates it.
factor = patch_size * merge_size (28 for GLM), and the bounds are AREAS in
pixels. Returns (h_bar, w_bar), both multiples of factor and at least
one factor each.
Note the asymmetry, which is the reference’s and not a simplification: the initial snap ROUNDS (so a 360-pixel side at factor 28 becomes 364, i.e. the canvas may be slightly larger than the input), while the over-budget branch FLOORS and the under-budget branch CEILS.