#[non_exhaustive]#[repr(u32)]pub enum NormalizationPreset {
Unsigned = 0,
Signed = 1,
Raw = 2,
Imagenet = 3,
}Expand description
A named Normalization. The code is the one the C
EF_NORMALIZATION_* enumerators and the Python NormalizationPreset
enum use; the names match the edgefirst.json presets.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unsigned = 0
x / 255, giving [0, 1] (the default).
Signed = 1
x / 127.5 - 1, giving [-1, 1].
Raw = 2
x, giving [0, 255].
Imagenet = 3
ImageNet mean and standard deviation.
Implementations§
Source§impl NormalizationPreset
impl NormalizationPreset
Sourcepub const fn code(self) -> u32
pub const fn code(self) -> u32
The shared code for this variant. Identical on every surface.
const, deliberately: a downstream binding that cannot
write Variant = OtherEnum::Variant.code() in a #[pyclass]
discriminant position (PyO3 requires a literal there) can
still pin that literal to this value with a
const _: () = assert!(...) – a build-time check instead
of a hand-synced comment. See PyTensorMemory/PyPixelFormat
in crates/python-common/src/tensor.rs for the consumer.
Sourcepub fn from_code(code: u32) -> Option<NormalizationPreset>
pub fn from_code(code: u32) -> Option<NormalizationPreset>
Reject an unknown code rather than guessing at one.
Sourcepub fn from_str_code(s: &str) -> Option<NormalizationPreset>
pub fn from_str_code(s: &str) -> Option<NormalizationPreset>
Reject an unknown string rather than guessing at one.
Sourcepub fn all() -> &'static [NormalizationPreset]
pub fn all() -> &'static [NormalizationPreset]
Every variant, for exhaustive cross-surface tests.
Trait Implementations§
Source§impl Clone for NormalizationPreset
impl Clone for NormalizationPreset
Source§fn clone(&self) -> NormalizationPreset
fn clone(&self) -> NormalizationPreset
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for NormalizationPreset
Source§impl Debug for NormalizationPreset
impl Debug for NormalizationPreset
Source§impl Default for NormalizationPreset
impl Default for NormalizationPreset
Source§fn default() -> NormalizationPreset
fn default() -> NormalizationPreset
Source§impl<'de> Deserialize<'de> for NormalizationPreset
impl<'de> Deserialize<'de> for NormalizationPreset
Source§fn deserialize<D>(
d: D,
) -> Result<NormalizationPreset, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
d: D,
) -> Result<NormalizationPreset, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for NormalizationPreset
Source§impl From<NormalizationPreset> for Normalization
impl From<NormalizationPreset> for Normalization
Source§fn from(p: NormalizationPreset) -> Normalization
fn from(p: NormalizationPreset) -> Normalization
Source§impl Hash for NormalizationPreset
impl Hash for NormalizationPreset
Source§impl PartialEq for NormalizationPreset
impl PartialEq for NormalizationPreset
Source§impl Serialize for NormalizationPreset
impl Serialize for NormalizationPreset
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for NormalizationPreset
Auto Trait Implementations§
impl Freeze for NormalizationPreset
impl RefUnwindSafe for NormalizationPreset
impl Send for NormalizationPreset
impl Sync for NormalizationPreset
impl Unpin for NormalizationPreset
impl UnsafeUnpin for NormalizationPreset
impl UnwindSafe for NormalizationPreset
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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