pub struct ModelDefinition { /* private fields */ }Expand description
Immutable model code and weights in a shared context. Shape-specific plans allocate private scratch and graph storage for each bounded inference slot.
Implementations§
Source§impl ModelDefinition
impl ModelDefinition
Sourcepub fn context(&self) -> &ModelContext
pub fn context(&self) -> &ModelContext
Shared scheduling and allocation domain.
Sourcepub fn launch_config(
&self,
id: KernelId,
workload_bits: &[u64],
) -> Result<LaunchConfig>
pub fn launch_config( &self, id: KernelId, workload_bits: &[u64], ) -> Result<LaunchConfig>
Evaluate a loaded kernel’s compiler launch program during graph preparation.
Sourcepub fn weight_bytes(&self) -> usize
pub fn weight_bytes(&self) -> usize
Physical immutable weight bytes, counted once regardless of plan or slot count.
Sourcepub unsafe fn prepare(
&self,
commands: &[Command],
inputs: &[(Region, TensorDesc)],
outputs: &[(Region, TensorDesc)],
capacity: usize,
) -> Result<PreparedModel>
pub unsafe fn prepare( &self, commands: &[Command], inputs: &[(Region, TensorDesc)], outputs: &[(Region, TensorDesc)], capacity: usize, ) -> Result<PreparedModel>
Prepare a shape with shared weights and fixed-address private slots. Input/output descriptors select leading bytes of their corresponding regions. Commands must restrict accesses to the selected shape.
§Safety
Dispatch bindings and scalar arguments must exactly describe the trusted compiled code, including accessible extents and every read or write. Writable argument aliasing must be safe for that kernel’s execution.
Sourcepub unsafe fn fragment(
&self,
commands: &[Command],
inputs: &[(Region, TensorDesc)],
outputs: &[(Region, TensorDesc)],
) -> Result<ModelFragment>
pub unsafe fn fragment( &self, commands: &[Command], inputs: &[(Region, TensorDesc)], outputs: &[(Region, TensorDesc)], ) -> Result<ModelFragment>
Validate a shape’s commands once, without allocating inference slots. The fragment owns shared weights and code independently of this definition.
§Safety
Dispatch contracts, accessible extents and writable aliases must satisfy
the same requirements as Self::prepare.
Auto Trait Implementations§
impl Freeze for ModelDefinition
impl RefUnwindSafe for ModelDefinition
impl Send for ModelDefinition
impl Sync for ModelDefinition
impl Unpin for ModelDefinition
impl UnsafeUnpin for ModelDefinition
impl UnwindSafe for ModelDefinition
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