IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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_cubic

def resize_cubic[in_dtype: DType, //](input: TileTensor[in_dtype, Engine=input.Engine, address_space=input.address_space, linear_idx_type=input.linear_idx_type], output: TileTensor[.float32, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type])

Resizes the height and width of an [outer, H, W, inner] tensor with antialiased cubic interpolation.

The filter is the Keys cubic with a = -0.5, stretched by the downscale factor. Taps outside the input are dropped, and the remaining weights are normalized to a sum of one. This is the filter of torch's CPU interpolate(mode="bicubic", antialias=True, align_corners=False), and the result matches it to float32 rounding.

An NHWC batch is [N, H, W, C], and an NCHW batch is [N * C, H, W, 1]. W is resampled before H, and each output adds up its taps in order with FMAs, so every shape gives the same bits for the same pixels. The resize runs on the CPU, on the calling thread, in float32.

Constraints:

Both tensors are rank 4. The input is float32 or an integer type.

Parameters:

  • โ€‹in_dtype (DType): The type of the input: float32, or an integer type such as uint8. The result is the same as when you convert the input to float32 first.

Args:

Was this page helpful?