Skip to main content

Executor

Struct Executor 

Source
pub struct Executor<B: Backend> { /* private fields */ }
Expand description

A graph, its weights on one backend, and a plan per bucket built on first use.

Implementations§

Source§

impl<B: Backend> Executor<B>

Source

pub fn new( backend: B, tensors: &[HostTensor<'_>], graph: Graph, buckets: &Buckets, stage: &str, vocab: usize, types: usize, ) -> Result<Self>

Uploads the weights. vocab and types bound the token ids and question types a batch may hold, and stage names the buckets to use from buckets.

§Errors

From Backend::upload.

Source

pub fn backend(&self) -> &B

The backend.

Source

pub fn warm(&self) -> impl Iterator<Item = Bucket> + '_

The buckets with a plan built.

Source

pub fn plans_mut(&mut self) -> impl Iterator<Item = &mut B::Plan> + '_

The plans built so far, to inspect or profile.

Source

pub fn prepare(&mut self, bucket: Bucket) -> Result<usize>

Builds the plan for bucket now rather than on first use.

§Errors

From Backend::lower.

Source

pub fn run(&mut self, batch: &Batch<'_>, out: &mut Outputs) -> Result<Bucket>

Runs a batch in the smallest bucket that holds it. Once that bucket’s plan exists and out has grown to the batch size, this allocates nothing.

§Errors

Error::Batch for an inconsistent batch, Error::NoBucket for one too big, and anything the backend reports.

Trait Implementations§

Source§

impl<B: Debug + Backend> Debug for Executor<B>
where B::Weights: Debug, B::Plan: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Executor<B>
where B: Freeze, <B as Backend>::Weights: Freeze, Vec<(Bucket, <B as Backend>::Plan)>: Freeze,

§

impl<B> RefUnwindSafe for Executor<B>

§

impl<B> Send for Executor<B>
where <B as Backend>::Weights: Send, Vec<(Bucket, <B as Backend>::Plan)>: Send,

§

impl<B> Sync for Executor<B>
where <B as Backend>::Weights: Sync, Vec<(Bucket, <B as Backend>::Plan)>: Sync,

§

impl<B> Unpin for Executor<B>
where B: Unpin, <B as Backend>::Weights: Unpin, Vec<(Bucket, <B as Backend>::Plan)>: Unpin,

§

impl<B> UnsafeUnpin for Executor<B>

§

impl<B> UnwindSafe for Executor<B>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.