pub struct InterpolateOptions {
pub mode: InterpolateMode,
pub coordinate_transform: CoordinateTransformMode,
pub nearest_mode: NearestRoundingMode,
pub cubic_options: CubicOptions,
pub output_size: Option<[usize; 2]>,
pub scale_factor: Option<[f32; 2]>,
}Expand description
Interpolation options.
Flex supports all coordinate transforms, rounding modes and cubic options.
CubeCL supports the default nearest and nearest-exact combinations, plus bilinear,
bicubic and Lanczos3 with AlignCorners or HalfPixel and default cubic options.
With CubeCL, explicit scales must equal the resolved output/input ratios exactly,
unless the transform is AlignCorners. Unsupported combinations panic.
Fields§
§mode: InterpolateModeAlgorithm used.
coordinate_transform: CoordinateTransformModeCoordinate transformation mode.
nearest_mode: NearestRoundingModeNearest rounding mode.
cubic_options: CubicOptionsCubic interpolation options.
output_size: Option<[usize; 2]>Output spatial size [height, width].
Exactly one of output_size or scale_factor must be set when calling
burn_tensor::module::interpolate.
scale_factor: Option<[f32; 2]>Scale factor [scale_height, scale_width] applied to the input spatial size.
The output size is floor(input_size * scale_factor).
Scale-dependent transforms use these supplied factors for coordinates rather
than recomputing the output/input ratio. AlignCorners and TfCropAndResize
map coordinates from the resolved sizes instead.
Implementations§
Source§impl InterpolateOptions
impl InterpolateOptions
Sourcepub fn new(mode: InterpolateMode) -> Self
pub fn new(mode: InterpolateMode) -> Self
Create new interpolate options with mode-dependent defaults.
Sourcepub fn with_coordinate_transform(self, mode: CoordinateTransformMode) -> Self
pub fn with_coordinate_transform(self, mode: CoordinateTransformMode) -> Self
Set coordinate transformation mode.
Sourcepub fn with_nearest_mode(self, mode: NearestRoundingMode) -> Self
pub fn with_nearest_mode(self, mode: NearestRoundingMode) -> Self
Set nearest rounding mode.
Sourcepub fn with_cubic_options(self, options: CubicOptions) -> Self
pub fn with_cubic_options(self, options: CubicOptions) -> Self
Set cubic options.
Sourcepub fn with_align_corners(self, align_corners: bool) -> Self
pub fn with_align_corners(self, align_corners: bool) -> Self
Set corner alignment for bilinear, bicubic and Lanczos3 interpolation.
true selects AlignCorners; false selects HalfPixel.
Nearest modes are unchanged; use Self::with_coordinate_transform to set their mapping.
Sourcepub fn align_corners(&self) -> bool
pub fn align_corners(&self) -> bool
Returns true if coordinate transform is AlignCorners.
Sourcepub fn with_output_size(self, output_size: [usize; 2]) -> Self
pub fn with_output_size(self, output_size: [usize; 2]) -> Self
Set the output size [height, width], clearing any scale factor.
Sourcepub fn with_scale_factor(self, scale_factor: [f32; 2]) -> Self
pub fn with_scale_factor(self, scale_factor: [f32; 2]) -> Self
Set the scale factor [scale_height, scale_width], clearing any output size.