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§
Source§impl<'de> Deserialize<'de> for PadMode
impl<'de> Deserialize<'de> for PadMode
Source§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
Source§impl Serialize for PadMode
impl Serialize for PadMode
Source§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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)