Enum PadMode
pub enum PadMode {
Constant(f32),
Reflect,
Edge,
}Expand description
Padding mode for tensor pad operations.
Defines how values are filled when padding a tensor beyond its original boundaries.
Note: Currently, padding is only supported on the last two dimensions of a tensor (typically height and width for image data in NCHW format).
§Modes
Variants§
Constant(f32)
Fill padded regions with a constant value.
§Example
For tensor [1, 2, 3] with padding 2 on the left and value 0:
Result: [0, 0, 1, 2, 3]
Reflect
Reflect values at the boundary, excluding the edge value.
Padding must be less than the dimension size (i.e., padding < dim_size).
§Example
For tensor [1, 2, 3, 4] with padding 2 on the left:
Result: [3, 2, 1, 2, 3, 4] (reflects from index 1, not 0)
Edge
Replicate the edge values.
§Example
For tensor [1, 2, 3, 4] with padding 2 on the left:
Result: [1, 1, 1, 2, 3, 4]
Trait Implementations§
§impl<'de> Deserialize<'de> for PadMode
impl<'de> Deserialize<'de> for PadMode
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PadMode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PadMode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl<E> From<E> for PadModewhere
E: ElementConversion,
impl<E> From<E> for PadModewhere
E: ElementConversion,
§impl Serialize for PadMode
impl Serialize for PadMode
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for PadMode
impl StructuralPartialEq for PadMode
Auto Trait Implementations§
impl Freeze for PadMode
impl RefUnwindSafe for PadMode
impl Send for PadMode
impl Sync for PadMode
impl Unpin for PadMode
impl UnwindSafe for PadMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more