pub struct Encoder { /* private fields */ }Implementations§
Source§impl Encoder
impl Encoder
pub fn new( kernel: Kernel, shape: Shape, output: Output, max_tokens: usize, tensors: &dyn Tensors, ) -> Result<Self, EncoderError>
Sourcepub fn new_with_precision(
kernel: Kernel,
shape: Shape,
output: Output,
max_tokens: usize,
tensors: &dyn Tensors,
precision: CpuPrecision,
) -> Result<Self, EncoderError>
pub fn new_with_precision( kernel: Kernel, shape: Shape, output: Output, max_tokens: usize, tensors: &dyn Tensors, precision: CpuPrecision, ) -> Result<Self, EncoderError>
Loads with an explicit projection policy; CpuPrecision gives each
preset’s requirements.
Sourcepub fn new_with_precision_and_workers(
kernel: Kernel,
shape: Shape,
output: Output,
max_tokens: usize,
tensors: &dyn Tensors,
precision: CpuPrecision,
workers: NonZeroUsize,
) -> Result<Self, EncoderError>
pub fn new_with_precision_and_workers( kernel: Kernel, shape: Shape, output: Output, max_tokens: usize, tensors: &dyn Tensors, precision: CpuPrecision, workers: NonZeroUsize, ) -> Result<Self, EncoderError>
Loads with a dedicated inference pool, independent of RAYON_NUM_THREADS.
pub fn max_tokens(&self) -> usize
Sourcepub fn precision(&self) -> CpuPrecision
pub fn precision(&self) -> CpuPrecision
The explicitly selected CPU projection policy.
Sourcepub fn numerical_identity(&self) -> &'static str
pub fn numerical_identity(&self) -> &'static str
The label a fingerprint hashes with crate::NUMERICAL_SOURCES, the
Kernel and the model bytes.
Sourcepub fn threads(&self) -> usize
pub fn threads(&self) -> usize
Without a dedicated pool, batches of up to 256 tokens may run on a smaller pool of performance cores.
Sourcepub fn enable_profiling(&mut self)
pub fn enable_profiling(&mut self)
Times every stage of every later batch; see Encoder::profile.
Sourcepub fn profile(&self) -> Option<&Profile>
pub fn profile(&self) -> Option<&Profile>
Wall time per stage of the batches since profiling was enabled.
Sourcepub fn output_width(&self) -> usize
pub fn output_width(&self) -> usize
Values returned per sequence: hidden for sentence vectors, 1 for scores.
Sourcepub fn calibrate(
&mut self,
inputs: &[TokenSequence],
) -> Result<(), EncoderError>
pub fn calibrate( &mut self, inputs: &[TokenSequence], ) -> Result<(), EncoderError>
Quantizes a centered preset by GPTQ over the FP32 forward of inputs, two or more
tokens each and one with interior tokens; once only, a failure leaves it uncalibrated.
Sourcepub fn calibration(&self) -> Result<Vec<u8>, EncoderError>
pub fn calibration(&self) -> Result<Vec<u8>, EncoderError>
The calibration as the bytes Self::install_calibration takes back.
Sourcepub fn install_calibration(&mut self, tables: &[u8]) -> Result<(), EncoderError>
pub fn install_calibration(&mut self, tables: &[u8]) -> Result<(), EncoderError>
Installs Self::calibration’s bytes without the forward pass. Malformed
tables are refused and leave the encoder uncalibrated; once only.
Sourcepub fn export_reproducible(&self) -> Result<EncoderExport, EncoderError>
pub fn export_reproducible(&self) -> Result<EncoderExport, EncoderError>
Calibrated parameters for bit-identical execution on another backend.
Sourcepub fn encode(
&mut self,
ids: &[i32],
types: &[i32],
lengths: &[usize],
) -> Result<Vec<f32>, EncoderError>
pub fn encode( &mut self, ids: &[i32], types: &[i32], lengths: &[usize], ) -> Result<Vec<f32>, EncoderError>
Encodes sequences packed back to back by lengths, Encoder::output_width
values each; no sequence depends on another in the batch.
Auto Trait Implementations§
impl !RefUnwindSafe for Encoder
impl !UnwindSafe for Encoder
impl Forget for Encoder
impl Freeze for Encoder
impl Move for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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