pub struct PrefixedLoader<'a, B: Backend> { /* private fields */ }Expand description
Adapter that prepends a fixed prefix to every tensor name before delegating to an underlying loader.
Use case: a single safetensors file contains a sub-model (e.g.
Qwen3-TTS stores the Talker LM under talker.model.*) and we want
to reuse a backbone loader like LlamaFamilyModel::new that
expects bare model.* names. Wrapping with
PrefixedLoader { inner, prefix: "talker." } lets the backbone
code stay prefix-agnostic.
Implementations§
Source§impl<'a, B: Backend> PrefixedLoader<'a, B>
impl<'a, B: Backend> PrefixedLoader<'a, B>
pub fn new(inner: &'a dyn WeightLoader<B>, prefix: impl Into<String>) -> Self
Trait Implementations§
Source§impl<'a, B: Backend> WeightLoader<B> for PrefixedLoader<'a, B>
impl<'a, B: Backend> WeightLoader<B> for PrefixedLoader<'a, B>
Source§fn load_tensor(&self, name: &str) -> Result<B::Buffer>
fn load_tensor(&self, name: &str) -> Result<B::Buffer>
Load a single tensor by fully qualified name
(e.g.
"model.embed_tokens.weight").Source§fn load_linear(&self, name: &str) -> Result<Box<dyn Linear<B>>>
fn load_linear(&self, name: &str) -> Result<Box<dyn Linear<B>>>
Load a projection as a
Linear<B>. The concrete implementation
(DenseLinear / GptqLinear / AwqLinear / GgufLinear) depends on the
loader’s file format and quant config. Read moreSource§fn has_tensor(&self, name: &str) -> bool
fn has_tensor(&self, name: &str) -> bool
Whether a tensor with this name exists in the source.
Source§fn quant_config(&self) -> Option<&QuantConfig>
fn quant_config(&self) -> Option<&QuantConfig>
Quantization metadata (parsed from
quantize_config.json or a GGUF header).
None means the source is dense.Auto Trait Implementations§
impl<'a, B> Freeze for PrefixedLoader<'a, B>
impl<'a, B> !RefUnwindSafe for PrefixedLoader<'a, B>
impl<'a, B> Send for PrefixedLoader<'a, B>
impl<'a, B> Sync for PrefixedLoader<'a, B>
impl<'a, B> Unpin for PrefixedLoader<'a, B>
impl<'a, B> UnsafeUnpin for PrefixedLoader<'a, B>
impl<'a, B> !UnwindSafe for PrefixedLoader<'a, B>
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