pub struct PrecisionConverter { /* private fields */ }Expand description
Precision converter for array operations
Implementations§
Source§impl PrecisionConverter
impl PrecisionConverter
Sourcepub fn new(config: PrecisionConfig) -> Self
pub fn new(config: PrecisionConfig) -> Self
Create a new precision converter
Sourcepub fn convert_and_compute_1d(
&self,
data: &Array1<f32>,
op: impl Fn(&Array1<f32>) -> Array1<f32>,
) -> InferenceResult<Array1<f32>>
pub fn convert_and_compute_1d( &self, data: &Array1<f32>, op: impl Fn(&Array1<f32>) -> Array1<f32>, ) -> InferenceResult<Array1<f32>>
Convert FP32 array to reduced precision and back (for inference)
Sourcepub fn from_fp16_1d(&self, data: &[f16]) -> Array1<f32>
pub fn from_fp16_1d(&self, data: &[f16]) -> Array1<f32>
Convert FP16 array to FP32
Sourcepub fn from_bf16_1d(&self, data: &[bf16]) -> Array1<f32>
pub fn from_bf16_1d(&self, data: &[bf16]) -> Array1<f32>
Convert BF16 array to FP32
Sourcepub fn from_fp16_2d(
&self,
data: &[f16],
shape: (usize, usize),
) -> InferenceResult<Array2<f32>>
pub fn from_fp16_2d( &self, data: &[f16], shape: (usize, usize), ) -> InferenceResult<Array2<f32>>
Convert FP16 to 2D FP32 array
Sourcepub fn from_bf16_2d(
&self,
data: &[bf16],
shape: (usize, usize),
) -> InferenceResult<Array2<f32>>
pub fn from_bf16_2d( &self, data: &[bf16], shape: (usize, usize), ) -> InferenceResult<Array2<f32>>
Convert BF16 to 2D FP32 array
Sourcepub fn config(&self) -> &PrecisionConfig
pub fn config(&self) -> &PrecisionConfig
Get the configuration
Auto Trait Implementations§
impl Freeze for PrecisionConverter
impl RefUnwindSafe for PrecisionConverter
impl Send for PrecisionConverter
impl Sync for PrecisionConverter
impl Unpin for PrecisionConverter
impl UnwindSafe for PrecisionConverter
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> 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>
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