pub struct Fp8Codec {
pub format: Fp8Format,
pub saturate: bool,
}Expand description
FP8 encoder/decoder.
Saturating conversion: values exceeding max_val are clamped; NaN/Inf
inputs return an error.
Fields§
§format: Fp8FormatTarget FP8 format.
saturate: boolWhether to saturate (clamp) out-of-range values instead of erroring.
Implementations§
Source§impl Fp8Codec
impl Fp8Codec
Sourcepub fn encode_f32(&self, v: f32) -> QuantResult<u8>
pub fn encode_f32(&self, v: f32) -> QuantResult<u8>
Encode a single f32 to FP8 u8.
§Errors
QuantError::NonFiniteFp8ifvis NaN or Inf andsaturate = false.
Sourcepub fn decode_f32(&self, b: u8) -> f32
pub fn decode_f32(&self, b: u8) -> f32
Decode a FP8 u8 to f32.
Sourcepub fn encode(&self, data: &[f32]) -> QuantResult<Vec<u8>>
pub fn encode(&self, data: &[f32]) -> QuantResult<Vec<u8>>
Encode a slice of f32 to FP8.
§Errors
Propagates QuantError::NonFiniteFp8 on first NaN/Inf when not saturating.
Sourcepub fn quantization_mse(&self, data: &[f32]) -> QuantResult<f32>
pub fn quantization_mse(&self, data: &[f32]) -> QuantResult<f32>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fp8Codec
impl RefUnwindSafe for Fp8Codec
impl Send for Fp8Codec
impl Sync for Fp8Codec
impl Unpin for Fp8Codec
impl UnsafeUnpin for Fp8Codec
impl UnwindSafe for Fp8Codec
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