pub struct ChunkedQuantizedMatrix<F> { /* private fields */ }
Expand description
A memory-mapped quantized matrix that operates on chunks of data to avoid loading the entire matrix into memory at once
Implementations§
Source§impl<F> ChunkedQuantizedMatrix<F>where
F: Float + NumAssign + Zero + Sum + One + ScalarOperand + Send + Sync + Debug + FromPrimitive + AsPrimitive<f32> + 'static,
f32: AsPrimitive<F>,
impl<F> ChunkedQuantizedMatrix<F>where
F: Float + NumAssign + Zero + Sum + One + ScalarOperand + Send + Sync + Debug + FromPrimitive + AsPrimitive<f32> + 'static,
f32: AsPrimitive<F>,
Sourcepub fn new(
matrix: &ArrayView2<'_, F>,
bits: u8,
method: QuantizationMethod,
file_path: &str,
) -> LinalgResult<Self>
pub fn new( matrix: &ArrayView2<'_, F>, bits: u8, method: QuantizationMethod, file_path: &str, ) -> LinalgResult<Self>
Create a new chunked quantized matrix from an explicit matrix
Quantizes the matrix and stores it to disk in chunks to support out-of-core processing.
§Arguments
matrix
- Matrix to quantize (will be processed in chunks)bits
- Bit width for quantizationmethod
- Quantization methodfile_path
- Path to store the quantized data
§Returns
A new ChunkedQuantizedMatrix
instance
Sourcepub fn positive_definite(self) -> Self
pub fn positive_definite(self) -> Self
Sourcepub fn params(&self) -> &QuantizationParams
pub fn params(&self) -> &QuantizationParams
Get the quantization parameters
Sourcepub fn apply(&self, x: &ArrayView1<'_, F>) -> LinalgResult<Array1<F>>
pub fn apply(&self, x: &ArrayView1<'_, F>) -> LinalgResult<Array1<F>>
Sourcepub fn tomatrix_free_op(&self) -> LinalgResult<QuantizedMatrixFreeOp<F>>
pub fn tomatrix_free_op(&self) -> LinalgResult<QuantizedMatrixFreeOp<F>>
Convert to a regular QuantizedMatrixFreeOp
This loads the entire matrix into memory, so it should only be used for matrices that can fit in memory.
§Returns
A QuantizedMatrixFreeOp instance
Sourcepub fn solve_conjugate_gradient(
&self,
b: &Array1<F>,
max_iter: usize,
tol: F,
adaptive_precision: bool,
) -> LinalgResult<Array1<F>>
pub fn solve_conjugate_gradient( &self, b: &Array1<F>, max_iter: usize, tol: F, adaptive_precision: bool, ) -> LinalgResult<Array1<F>>
Sourcepub fn from_file(filepath: &str) -> LinalgResult<Self>
pub fn from_file(filepath: &str) -> LinalgResult<Self>
Trait Implementations§
Source§impl<F> MatrixFreeOp<F> for ChunkedQuantizedMatrix<F>where
F: Float + NumAssign + Zero + Sum + One + ScalarOperand + Send + Sync + Debug + 'static + FromPrimitive + AsPrimitive<f32>,
f32: AsPrimitive<F>,
impl<F> MatrixFreeOp<F> for ChunkedQuantizedMatrix<F>where
F: Float + NumAssign + Zero + Sum + One + ScalarOperand + Send + Sync + Debug + 'static + FromPrimitive + AsPrimitive<f32>,
f32: AsPrimitive<F>,
Source§fn apply(&self, x: &ArrayView1<'_, F>) -> LinalgResult<Array1<F>>
fn apply(&self, x: &ArrayView1<'_, F>) -> LinalgResult<Array1<F>>
Apply the linear operator to a vector
Source§fn is_symmetric(&self) -> bool
fn is_symmetric(&self) -> bool
Check if the linear operator is symmetric
Source§fn is_positive_definite(&self) -> bool
fn is_positive_definite(&self) -> bool
Check if the linear operator is positive definite
Auto Trait Implementations§
impl<F> Freeze for ChunkedQuantizedMatrix<F>
impl<F> RefUnwindSafe for ChunkedQuantizedMatrix<F>where
F: RefUnwindSafe,
impl<F> Send for ChunkedQuantizedMatrix<F>where
F: Send,
impl<F> Sync for ChunkedQuantizedMatrix<F>where
F: Sync,
impl<F> Unpin for ChunkedQuantizedMatrix<F>where
F: Unpin,
impl<F> UnwindSafe for ChunkedQuantizedMatrix<F>where
F: UnwindSafe,
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> 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