Skip to main content

Mojo function

cubic_kernel

cubic_kernel(x: SIMD[float32, 1]) -> SIMD[float32, 1]

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[float32, 1]): Distance from the center point.

Returns:

Weight contribution based on the distance.

cubic_kernel(x: SIMD[dtype, size]) -> SIMD[dtype, 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[dtype, size]): Distance from the center point.

Returns:

Weight contribution based on the distance.

Was this page helpful?