pub struct QuantizedEmbedding {
pub weight: Array,
pub scales: Array,
pub biases: Array,
pub group_size: usize,
pub bits: u32,
}Expand description
An Embedding with its table quantized (MLX’s nn.QuantizedEmbedding): rows are
gathered packed and dequantized; the packed table, scales and biases are frozen.
Fields§
§weight: ArrayThe packed table (uint32), [num_embeddings, dims · bits / 32].
scales: ArrayOne scale per group of values, [num_embeddings, dims / group_size].
biases: ArrayOne bias per group of values, shaped like scales.
group_size: usizeValues per scale and bias.
bits: u32Bits per value.
Implementations§
Source§impl QuantizedEmbedding
impl QuantizedEmbedding
Trait Implementations§
Source§impl Clone for QuantizedEmbedding
impl Clone for QuantizedEmbedding
Source§impl Debug for QuantizedEmbedding
impl Debug for QuantizedEmbedding
Source§impl Module for QuantizedEmbedding
impl Module for QuantizedEmbedding
Source§fn visit(&mut self, p: &mut Parameters<'_>)
fn visit(&mut self, p: &mut Parameters<'_>)
Reports every parameter and submodule to
p, frozen ones included.Source§fn parameters(&self) -> Vec<(String, Array)>
fn parameters(&self) -> Vec<(String, Array)>
Every parameter with its path (
layers.0.weight), in visiting order.Source§fn trainable_parameters(&self) -> Vec<(String, Array)>
fn trainable_parameters(&self) -> Vec<(String, Array)>
The parameters that are trained (not frozen), with their paths.
Source§fn update_trainable(&mut self, values: &[Array]) -> Result<()>
fn update_trainable(&mut self, values: &[Array]) -> Result<()>
Replaces the trainable parameters, given in the order of
Module::trainable_parameters (as optimizers return them).Source§fn load_weights(
&mut self,
weights: impl IntoIterator<Item = (String, Array)>,
strict: bool,
) -> Result<()>
fn load_weights( &mut self, weights: impl IntoIterator<Item = (String, Array)>, strict: bool, ) -> Result<()>
Replaces parameters by path, as MLX’s
load_weights: each weight must have its
parameter’s shape (the dtype is kept as loaded). With strict, every parameter
must be given and no unknown names are allowed.Auto Trait Implementations§
impl Freeze for QuantizedEmbedding
impl RefUnwindSafe for QuantizedEmbedding
impl Send for QuantizedEmbedding
impl Sync for QuantizedEmbedding
impl Unpin for QuantizedEmbedding
impl UnsafeUnpin for QuantizedEmbedding
impl UnwindSafe for QuantizedEmbedding
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
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,
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