Expand description
2026-09-25: GLM image geometry: smart_resize to a canvas aligned to
patch_size × spatial_merge_size, an aspect-preserving fit that never
upscales, a black pad to the canvas, and the 2×2-block-major patch order.
vision_preprocess uses it when VisionConfig::block_major_patches is set.
Owner: model-layers (vision input). Invariants: none beyond the types.
Functions§
- block_
major_ patch_ index - 2026-09-25: Index of the patch at
(patch_row, patch_col)in the 2×2-block-major stream the GLM tower expects. - pixel_
bounds - 2026-09-25:
(min_pixels, max_pixels)forsmart_resize, as pixel areas. - resize_
and_ pad - 2026-09-25: Fit
imginside thesmart_resizecanvas preserving aspect, then zero-pad right/bottom to the canvas exactly. Returns the padded canvas. - smart_
resize - 2026-09-25: Snap each side to the nearest multiple of
factor, then rescale by the area bounds if the snapped canvas violates them.