pub struct ScratchRegion { /* private fields */ }Expand description
Bump-allocated scratch space for temporary per-propagator data.
Propagators can request temporary f32 slices from scratch space for intermediate calculations (e.g. neighbourhood sums, gradient buffers). The scratch region is reset between propagator executions within a single tick — allocations do not persist across propagators or ticks.
§Example (conceptual)
let slice = scratch.alloc(100)?;
// use slice for intermediate computation
// scratch.reset() called by engine before next propagatorImplementations§
Source§impl ScratchRegion
impl ScratchRegion
Sourcepub fn new(initial_capacity: usize) -> Self
pub fn new(initial_capacity: usize) -> Self
Create a new scratch region with the given initial capacity (in f32 elements).
Sourcepub fn alloc(&mut self, len: usize) -> Option<&mut [f32]>
pub fn alloc(&mut self, len: usize) -> Option<&mut [f32]>
Allocate len f32 elements from scratch space.
Returns a zero-initialised mutable slice. Returns None if the
scratch region cannot grow to accommodate the request (this should
not happen in practice since Vec grows on demand; None is
returned only if the system is out of memory).
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the scratch region for the next propagator.
This does NOT deallocate or zero the backing storage — it simply
resets the bump pointer. The next alloc call will overwrite
stale data with zeroes before returning.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Memory usage of the backing storage in bytes.