Skip to main content

InterpolateOptions

Struct InterpolateOptions 

Source
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: InterpolateMode

Algorithm used.

§coordinate_transform: CoordinateTransformMode

Coordinate transformation mode.

§nearest_mode: NearestRoundingMode

Nearest rounding mode.

§cubic_options: CubicOptions

Cubic 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

Source

pub fn new(mode: InterpolateMode) -> Self

Create new interpolate options with mode-dependent defaults.

Source

pub fn with_coordinate_transform(self, mode: CoordinateTransformMode) -> Self

Set coordinate transformation mode.

Source

pub fn with_nearest_mode(self, mode: NearestRoundingMode) -> Self

Set nearest rounding mode.

Source

pub fn with_cubic_options(self, options: CubicOptions) -> Self

Set cubic options.

Source

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.

Source

pub fn align_corners(&self) -> bool

Returns true if coordinate transform is AlignCorners.

Source

pub fn with_output_size(self, output_size: [usize; 2]) -> Self

Set the output size [height, width], clearing any scale factor.

Source

pub fn with_scale_factor(self, scale_factor: [f32; 2]) -> Self

Set the scale factor [scale_height, scale_width], clearing any output size.

Trait Implementations§

Source§

impl Clone for InterpolateOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InterpolateOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for InterpolateOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for InterpolateOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for InterpolateOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for InterpolateOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.