pub struct BatchScratch { /* private fields */ }Expand description
Reusable buffers for Mlp::forward_batch.
This stores per-layer outputs for all samples in the batch in flat row-major layout:
- each layer buffer has shape
(batch_size, out_dim).
Implementations§
Source§impl BatchScratch
impl BatchScratch
Sourcepub fn new(mlp: &Mlp, batch_size: usize) -> Self
pub fn new(mlp: &Mlp, batch_size: usize) -> Self
Allocate a batch scratch buffer suitable for mlp and batch_size.
Sourcepub fn batch_size(&self) -> usize
pub fn batch_size(&self) -> usize
Returns the fixed batch size.
Sourcepub fn output(&self) -> &[f32]
pub fn output(&self) -> &[f32]
Returns the final model output buffer from the last forward_batch call.
Shape: (batch_size * output_dim,).
Sourcepub fn output_row(&self, idx: usize) -> &[f32]
pub fn output_row(&self, idx: usize) -> &[f32]
Returns the idx-th output row (shape: (output_dim,)).
Panics if idx >= batch_size.
Trait Implementations§
Source§impl Clone for BatchScratch
impl Clone for BatchScratch
Source§fn clone(&self) -> BatchScratch
fn clone(&self) -> BatchScratch
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BatchScratch
impl RefUnwindSafe for BatchScratch
impl Send for BatchScratch
impl Sync for BatchScratch
impl Unpin for BatchScratch
impl UnwindSafe for BatchScratch
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