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>
impl<B: Backend> Executor<B>
Sourcepub fn new(
backend: B,
tensors: &[HostTensor<'_>],
graph: Graph,
buckets: &Buckets,
stage: &str,
vocab: usize,
types: usize,
) -> Result<Self>
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.
Sourcepub fn plans_mut(&mut self) -> impl Iterator<Item = &mut B::Plan> + '_
pub fn plans_mut(&mut self) -> impl Iterator<Item = &mut B::Plan> + '_
The plans built so far, to inspect or profile.
Sourcepub fn run(&mut self, batch: &Batch<'_>, out: &mut Outputs) -> Result<Bucket>
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§
Auto Trait Implementations§
impl<B> Freeze for Executor<B>
impl<B> RefUnwindSafe for Executor<B>where
B: RefUnwindSafe,
<B as Backend>::Weights: RefUnwindSafe,
Vec<(Bucket, <B as Backend>::Plan)>: RefUnwindSafe,
impl<B> Send for Executor<B>
impl<B> Sync for Executor<B>
impl<B> Unpin for Executor<B>
impl<B> UnsafeUnpin for Executor<B>where
B: UnsafeUnpin,
<B as Backend>::Weights: UnsafeUnpin,
Vec<(Bucket, <B as Backend>::Plan)>: UnsafeUnpin,
impl<B> UnwindSafe for Executor<B>where
B: UnwindSafe,
<B as Backend>::Weights: UnwindSafe,
Vec<(Bucket, <B as Backend>::Plan)>: 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