For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
resize_nearest_neighbor
def resize_nearest_neighbor[coordinate_transformation_mode: CoordinateTransformationMode, round_mode: RoundMode, dtype: DType, target: StringSpan[ImmStaticOrigin] = StringSpan("cpu")](input: TileTensor[dtype, Engine=input.Engine, address_space=input.address_space, linear_idx_type=input.linear_idx_type], output: TileTensor[dtype, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type], ctx: DeviceContextBase)
Resizes input to output shape using nearest-neighbor interpolation.
When every axis scales by an exact integer factor and the transform
and round modes collapse to floor division at whole factors
(asymmetric + floor, half_pixel + half_down, half_pixel + half_up),
the kernel skips the coordinate arithmetic entirely and gathers from
out_coord // scale. Models used to hand-roll this case with
reshape + broadcast to avoid the coordinate math; the fast path makes
the standard op just as cheap.
Parameters:
- coordinate_transformation_mode (
CoordinateTransformationMode): How to map a coordinate in output to a coordinate in input. - round_mode (
RoundMode): How to round fractional input coordinates to integer indices. - dtype (
DType): Type of input and output. - target (
StringSpan[ImmStaticOrigin]): The target backend to execute on, such as "cpu" or "gpu".
Args:
- input (
TileTensor[dtype, Engine=input.Engine, address_space=input.address_space, linear_idx_type=input.linear_idx_type]): The input to be resized. - output (
TileTensor[dtype, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type]): The output containing the resized input. - ctx (
DeviceContextBase): The device context used to launch the kernel.