pub struct Sampler { /* private fields */ }Expand description
Sampler that picks tokens from logits.
Implementations§
Source§impl Sampler
impl Sampler
pub fn new(vocab_size: usize) -> Self
Sourcepub fn sample(
&mut self,
logits_ptr: DevicePtr,
params: &SamplingParams,
gpu: &dyn GpuBackend,
) -> Result<u32>
pub fn sample( &mut self, logits_ptr: DevicePtr, params: &SamplingParams, gpu: &dyn GpuBackend, ) -> Result<u32>
Sample a token from logits on the GPU.
logits_ptr points to [vocab_size] BF16 values on device.
Reads BF16, expands to FP32, then samples with full precision.
Sourcepub fn sample_batch(
&mut self,
logits_ptr: DevicePtr,
batch_size: usize,
params: &[&SamplingParams],
gpu: &dyn GpuBackend,
) -> Result<Vec<u32>>
pub fn sample_batch( &mut self, logits_ptr: DevicePtr, batch_size: usize, params: &[&SamplingParams], gpu: &dyn GpuBackend, ) -> Result<Vec<u32>>
Sample a batch of tokens (one per sequence in the batch).
logits_ptr points to [batch_size, vocab_size] BF16 values.
Auto Trait Implementations§
impl Freeze for Sampler
impl RefUnwindSafe for Sampler
impl Send for Sampler
impl Sync for Sampler
impl Unpin for Sampler
impl UnwindSafe for Sampler
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