IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo function

cubic_kernel

def cubic_kernel(x: Float32) -> Float32

Cubic interpolation kernel matching PyTorch/torchvision's BICUBIC filter.

This uses the Catmull-Rom variant (Robidoux cubic) with a = -0.75, which is what PyTorch uses in get_cubic_upsample_coefficients. (Source). This also matches OpenCV's interpolateCubic.

Args:

  • x (Float32): Distance from the center point.

Returns:

Float32: Weight contribution based on the distance.

def cubic_kernel(x: SIMD) -> SIMD[x.dtype, x.size]

Cubic interpolation kernel matching PyTorch/torchvision's BICUBIC filter.

This uses the Catmull-Rom variant (Robidoux cubic) with a = -0.75, which is what PyTorch uses in get_cubic_upsample_coefficients. (Source). This also matches OpenCV's interpolateCubic.

Args:

  • x (SIMD): Distance from the center point.

Returns:

SIMD[x.dtype, x.size]: Weight contribution based on the distance.