pub struct InferenceModel<B, InP, OutP, const MAX_BATCH: usize>{ /* private fields */ }Expand description
Generic 1×1 inference node for any backend (dyn-free).
MAX_BATCHis a compile-time cap used for the no-alloc path.- When
allocis enabled, the batched path usesVec(still no unsafe).
Implementations§
Source§impl<B, InP, OutP, const MAX_BATCH: usize> InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> InferenceModel<B, InP, OutP, MAX_BATCH>
Sourcepub fn new<'desc>(
backend: B,
desc: B::ModelDescriptor<'desc>,
node_policy: NodePolicy,
node_caps: NodeCapabilities,
input_acceptance: [PlacementAcceptance; 1],
output_acceptance: [PlacementAcceptance; 1],
) -> Result<Self, B::Error>
pub fn new<'desc>( backend: B, desc: B::ModelDescriptor<'desc>, node_policy: NodePolicy, node_caps: NodeCapabilities, input_acceptance: [PlacementAcceptance; 1], output_acceptance: [PlacementAcceptance; 1], ) -> Result<Self, B::Error>
Construct a new InferenceModel node.
backend: concrete compute backend (e.g., Tract, TFLM adapter).desc: backend-specific, borrowed model descriptor (e.g., bytes, artifact).node_policy: batching/budget/deadline policies for the node.node_caps: advertised capabilities (e.g., device streams).input_acceptance/output_acceptance: zero-copy placement preferences.
Sourcepub fn backend_capabilities(&self) -> BackendCapabilities
pub fn backend_capabilities(&self) -> BackendCapabilities
Return cached backend capabilities for this node.
Sourcepub fn model_metadata(&self) -> ModelMetadata
pub fn model_metadata(&self) -> ModelMetadata
Return cached model metadata for this node.
Source§impl<const MAX_BATCH: usize> InferenceModel<TestTensorBackend, Tensor<u32, TEST_TENSOR_ELEMENT_COUNT, 2>, Tensor<u32, TEST_TENSOR_ELEMENT_COUNT, 2>, MAX_BATCH>
impl<const MAX_BATCH: usize> InferenceModel<TestTensorBackend, Tensor<u32, TEST_TENSOR_ELEMENT_COUNT, 2>, Tensor<u32, TEST_TENSOR_ELEMENT_COUNT, 2>, MAX_BATCH>
Sourcepub fn new_identity(
node_capabilities: NodeCapabilities,
node_policy: NodePolicy,
input_placement_acceptance: [PlacementAcceptance; 1],
output_placement_acceptance: [PlacementAcceptance; 1],
) -> Result<Self, InferenceError>
pub fn new_identity( node_capabilities: NodeCapabilities, node_policy: NodePolicy, input_placement_acceptance: [PlacementAcceptance; 1], output_placement_acceptance: [PlacementAcceptance; 1], ) -> Result<Self, InferenceError>
Construct the identity test node with your policy/capability params.
Trait Implementations§
Source§impl<B, InP, OutP, const MAX_BATCH: usize> Node<1, 1, InP, OutP> for InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> Node<1, 1, InP, OutP> for InferenceModel<B, InP, OutP, MAX_BATCH>
Source§fn set_policy(&mut self, policy: NodePolicy)
fn set_policy(&mut self, policy: NodePolicy)
TEST ONLY method used to override batching policis for node contract tests.
Source§fn describe_capabilities(&self) -> NodeCapabilities
fn describe_capabilities(&self) -> NodeCapabilities
Return the node’s capability descriptor.
Source§fn input_acceptance(&self) -> [PlacementAcceptance; 1]
fn input_acceptance(&self) -> [PlacementAcceptance; 1]
Return the node’s port placement acceptances (zero-copy compatibility).
Source§fn output_acceptance(&self) -> [PlacementAcceptance; 1]
fn output_acceptance(&self) -> [PlacementAcceptance; 1]
Return the node’s output placement preferences (zero-copy compatibility).
Source§fn policy(&self) -> NodePolicy
fn policy(&self) -> NodePolicy
Return the node’s policy bundle.
Source§fn initialize<C, T>(
&mut self,
_clock: &C,
_telemetry: &mut T,
) -> Result<(), NodeError>where
T: Telemetry,
fn initialize<C, T>(
&mut self,
_clock: &C,
_telemetry: &mut T,
) -> Result<(), NodeError>where
T: Telemetry,
Prepare internal state, acquire buffers, and register telemetry series.
Source§fn start<C, T>(
&mut self,
_clock: &C,
_telemetry: &mut T,
) -> Result<(), NodeError>where
T: Telemetry,
fn start<C, T>(
&mut self,
_clock: &C,
_telemetry: &mut T,
) -> Result<(), NodeError>where
T: Telemetry,
Optional warm-up (e.g., compile kernels, prime pools). Default: no-op.
Source§fn process_message<C>(
&mut self,
msg: &Message<InP>,
_sys_clock: &C,
) -> Result<ProcessResult<OutP>, NodeError>where
C: PlatformClock + Sized,
fn process_message<C>(
&mut self,
msg: &Message<InP>,
_sys_clock: &C,
) -> Result<ProcessResult<OutP>, NodeError>where
C: PlatformClock + Sized,
Per-message processing hook. Read more
Source§fn step<'g, 't, 'c, InQ, OutQ, InM, OutM, C, Tel>(
&mut self,
ctx: &mut StepContext<'g, 't, 'c, 1, 1, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>,
) -> Result<StepResult, NodeError>where
InQ: Edge,
OutQ: Edge,
InM: MemoryManager<InP>,
OutM: MemoryManager<OutP>,
C: PlatformClock + Sized,
Tel: Telemetry + Sized,
fn step<'g, 't, 'c, InQ, OutQ, InM, OutM, C, Tel>(
&mut self,
ctx: &mut StepContext<'g, 't, 'c, 1, 1, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>,
) -> Result<StepResult, NodeError>where
InQ: Edge,
OutQ: Edge,
InM: MemoryManager<InP>,
OutM: MemoryManager<OutP>,
C: PlatformClock + Sized,
Tel: Telemetry + Sized,
Execute one cooperative step using the provided context. Read more
Source§fn step_batch<'g, 't, 'c, InQ, OutQ, InM, OutM, C, Tel>(
&mut self,
ctx: &mut StepContext<'g, 't, 'c, 1, 1, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>,
) -> Result<StepResult, NodeError>where
InQ: Edge,
OutQ: Edge,
InM: MemoryManager<InP>,
OutM: MemoryManager<OutP>,
C: PlatformClock + Sized,
Tel: Telemetry + Sized,
fn step_batch<'g, 't, 'c, InQ, OutQ, InM, OutM, C, Tel>(
&mut self,
ctx: &mut StepContext<'g, 't, 'c, 1, 1, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>,
) -> Result<StepResult, NodeError>where
InQ: Edge,
OutQ: Edge,
InM: MemoryManager<InP>,
OutM: MemoryManager<OutP>,
C: PlatformClock + Sized,
Tel: Telemetry + Sized,
Default batched-step implementation that honors all NodePolicy batching
variants while delegating actual consumption to the implementor’s
single-message
process_message() method.Source§fn on_watchdog_timeout<C, Tel>(
&mut self,
clock: &C,
_telemetry: &mut Tel,
) -> Result<StepResult, NodeError>
fn on_watchdog_timeout<C, Tel>( &mut self, clock: &C, _telemetry: &mut Tel, ) -> Result<StepResult, NodeError>
Handle watchdog timeouts by applying over-budget policy (degrade/default/skip).
Auto Trait Implementations§
impl<B, InP, OutP, const MAX_BATCH: usize> Freeze for InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> RefUnwindSafe for InferenceModel<B, InP, OutP, MAX_BATCH>where
B: RefUnwindSafe,
<B as ComputeBackend<InP, OutP>>::Model: RefUnwindSafe,
OutP: RefUnwindSafe,
InP: RefUnwindSafe,
impl<B, InP, OutP, const MAX_BATCH: usize> Send for InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> Sync for InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> Unpin for InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> UnsafeUnpin for InferenceModel<B, InP, OutP, MAX_BATCH>
impl<B, InP, OutP, const MAX_BATCH: usize> UnwindSafe for InferenceModel<B, InP, OutP, MAX_BATCH>where
B: UnwindSafe,
<B as ComputeBackend<InP, OutP>>::Model: UnwindSafe,
OutP: UnwindSafe,
InP: UnwindSafe,
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