Skip to main content

InferenceModel

Struct InferenceModel 

Source
pub struct InferenceModel<B, InP, OutP, const MAX_BATCH: usize>
where B: ComputeBackend<InP, OutP>, InP: Payload, OutP: Payload + Default + Copy,
{ /* private fields */ }
Expand description

Generic 1×1 inference node for any backend (dyn-free).

  • MAX_BATCH is a compile-time cap used for the no-alloc path.
  • When alloc is enabled, the batched path uses Vec (still no unsafe).

Implementations§

Source§

impl<B, InP, OutP, const MAX_BATCH: usize> InferenceModel<B, InP, OutP, MAX_BATCH>
where B: ComputeBackend<InP, OutP>, InP: Payload, OutP: Payload + Default + Copy,

Source

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.
Source

pub fn backend_capabilities(&self) -> BackendCapabilities

Return cached backend capabilities for this node.

Source

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>

Source

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.

Source

pub fn kind() -> NodeKind

Handy constant for tests.

Trait Implementations§

Source§

impl<B, InP, OutP, const MAX_BATCH: usize> Node<1, 1, InP, OutP> for InferenceModel<B, InP, OutP, MAX_BATCH>
where B: ComputeBackend<InP, OutP>, InP: Payload + Default + Copy, OutP: Payload + Default + Copy,

Source§

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

Return the node’s capability descriptor.
Source§

fn input_acceptance(&self) -> [PlacementAcceptance; 1]

Return the node’s port placement acceptances (zero-copy compatibility).
Source§

fn output_acceptance(&self) -> [PlacementAcceptance; 1]

Return the node’s output placement preferences (zero-copy compatibility).
Source§

fn policy(&self) -> NodePolicy

Return the node’s policy bundle.
Source§

fn node_kind(&self) -> NodeKind

Return the type of node (Model, processing, source, sink).
Source§

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,

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,

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,

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,

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>
where C: PlatformClock + Sized, Tel: Telemetry,

Handle watchdog timeouts by applying over-budget policy (degrade/default/skip).
Source§

fn stop<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<(), NodeError>
where Tel: Telemetry,

Flush and release resources, if any. Default: no-op.

Auto Trait Implementations§

§

impl<B, InP, OutP, const MAX_BATCH: usize> Freeze for InferenceModel<B, InP, OutP, MAX_BATCH>
where B: Freeze, <B as ComputeBackend<InP, OutP>>::Model: Freeze, OutP: Freeze,

§

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>
where B: Send, <B as ComputeBackend<InP, OutP>>::Model: Send, OutP: Send, InP: Send,

§

impl<B, InP, OutP, const MAX_BATCH: usize> Sync for InferenceModel<B, InP, OutP, MAX_BATCH>
where B: Sync, <B as ComputeBackend<InP, OutP>>::Model: Sync, OutP: Sync, InP: Sync,

§

impl<B, InP, OutP, const MAX_BATCH: usize> Unpin for InferenceModel<B, InP, OutP, MAX_BATCH>
where B: Unpin, <B as ComputeBackend<InP, OutP>>::Model: Unpin, OutP: Unpin, InP: Unpin,

§

impl<B, InP, OutP, const MAX_BATCH: usize> UnsafeUnpin for InferenceModel<B, InP, OutP, MAX_BATCH>
where B: UnsafeUnpin, <B as ComputeBackend<InP, OutP>>::Model: UnsafeUnpin, OutP: UnsafeUnpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.