pub struct ModelFragment { /* private fields */ }Expand description
Validated, shape-specific model commands with shared immutable weights.
Record into a caller-owned graph to connect stages without copies, or build
a standalone bounded inference pool with Self::prepare.
Implementations§
Source§impl ModelFragment
impl ModelFragment
Sourcepub unsafe fn reuse_private_scratch(self) -> Self
pub unsafe fn reuse_private_scratch(self) -> Self
Reuse private temporaries across fragments recorded into the same graph. Input/output allocations and immutable weights are never recycled. Each inference slot still owns a separate workspace. Graph hazards order reads before a later fragment overwrites that storage, potentially serializing otherwise independent branches in exchange for lower peak memory.
§Safety
Every private scratch byte read by this fragment must first be written by this fragment on every execution, including padding and conditional paths. Neither initial zeroes nor another fragment’s values may be used. All scratch accesses must already be declared by the kernel contracts.
Sourcepub fn prepare(&self, capacity: usize) -> Result<PreparedModel>
pub fn prepare(&self, capacity: usize) -> Result<PreparedModel>
Allocate independent fixed-address slots, exposing their actual model IO.
Sourcepub fn record(
&self,
graph: &mut Graph,
inputs: &[DeviceTensor],
) -> Result<Vec<DeviceTensor>>
pub fn record( &self, graph: &mut Graph, inputs: &[DeviceTensor], ) -> Result<Vec<DeviceTensor>>
Append model commands directly to an unprepared graph. Inputs are bound without a device copy; outputs and scratch are allocated for this graph. Adjacent stages can consume the returned tensors before graph preparation. No pool, host staging, submission or intermediate synchronization is added.
Inputs must describe the complete accessed regions of their allocations. Partial aliases which would require a copy are rejected. Initialization producers are drained here; this is a preparation-time operation.
Auto Trait Implementations§
impl Freeze for ModelFragment
impl RefUnwindSafe for ModelFragment
impl Send for ModelFragment
impl Sync for ModelFragment
impl Unpin for ModelFragment
impl UnsafeUnpin for ModelFragment
impl UnwindSafe for ModelFragment
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
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> ⓘ
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