pub struct StatefulInferer<WrapStack: InfererWrapper, Inf: Inferer> { /* private fields */ }Expand description
An inferer that maintains state in wrappers around an inferer.
This is an alternative to direct wrapping of an inferer, which allows the inner inferer to be swapped out while maintaining state in the wrappers.
Implementations§
Source§impl<WrapStack: InfererWrapper, Inf: Inferer> StatefulInferer<WrapStack, Inf>
impl<WrapStack: InfererWrapper, Inf: Inferer> StatefulInferer<WrapStack, Inf>
Sourcepub fn new(wrapper_stack: WrapStack, inferer: Inf) -> Self
pub fn new(wrapper_stack: WrapStack, inferer: Inf) -> Self
Construct a new StatefulInferer by wrapping the given
inferer with the given wrapper stack.
Sourcepub fn with_new_inferer<NewInf: Inferer>(
self,
new_inferer: NewInf,
) -> Result<StatefulInferer<WrapStack, NewInf>, (Self, Error)>
pub fn with_new_inferer<NewInf: Inferer>( self, new_inferer: NewInf, ) -> Result<StatefulInferer<WrapStack, NewInf>, (Self, Error)>
Replace the inner inferer with a new inferer while maintaining any state in wrappers.
Requires that the shapes of the policies are compatible, but they may be different inferer types. If this check fails, will return self unchanged.
Sourcepub fn replace_inferer(&mut self, new_inferer: Inf) -> Result<()>
pub fn replace_inferer(&mut self, new_inferer: Inf) -> Result<()>
Replace the inner inferer with a new inferer while maintaining any state in wrappers.
Requires that the shapes of the policies are compatible If
this check fails, will not change self. Compared to
[with_new_inferer], also requires that the new inferer has
the same type as the old one.
Sourcepub fn check_compatible_shapes<Old: Inferer, New: Inferer>(
old: &Old,
new: &New,
) -> Result<(), Error>
pub fn check_compatible_shapes<Old: Inferer, New: Inferer>( old: &Old, new: &New, ) -> Result<(), Error>
Validate that [Old] and [New] are compatible with each
other.
Sourcepub fn input_shapes(&self) -> &[(String, Vec<usize>)]
pub fn input_shapes(&self) -> &[(String, Vec<usize>)]
Returns the input shapes after all wrappers have been applied.
Sourcepub fn output_shapes(&self) -> &[(String, Vec<usize>)]
pub fn output_shapes(&self) -> &[(String, Vec<usize>)]
Returns the output shapes after all wrappers have been applied.
Trait Implementations§
Source§impl<WrapStack: InfererWrapper, Inf: Inferer> Inferer for StatefulInferer<WrapStack, Inf>
See Inferer for documentation.
impl<WrapStack: InfererWrapper, Inf: Inferer> Inferer for StatefulInferer<WrapStack, Inf>
See Inferer for documentation.
Source§fn select_batch_size(&self, max_count: usize) -> usize
fn select_batch_size(&self, max_count: usize) -> usize
Source§fn infer_raw(&self, batch: &mut ScratchPadView<'_>) -> Result<(), Error>
fn infer_raw(&self, batch: &mut ScratchPadView<'_>) -> Result<(), Error>
Source§fn raw_input_shapes(&self) -> &[(String, Vec<usize>)]
fn raw_input_shapes(&self) -> &[(String, Vec<usize>)]
Source§fn raw_output_shapes(&self) -> &[(String, Vec<usize>)]
fn raw_output_shapes(&self) -> &[(String, Vec<usize>)]
fn begin_agent(&self, id: u64)
fn end_agent(&self, id: u64)
Auto Trait Implementations§
impl<WrapStack, Inf> Freeze for StatefulInferer<WrapStack, Inf>
impl<WrapStack, Inf> RefUnwindSafe for StatefulInferer<WrapStack, Inf>where
WrapStack: RefUnwindSafe,
Inf: RefUnwindSafe,
impl<WrapStack, Inf> Send for StatefulInferer<WrapStack, Inf>
impl<WrapStack, Inf> Sync for StatefulInferer<WrapStack, Inf>
impl<WrapStack, Inf> Unpin for StatefulInferer<WrapStack, Inf>
impl<WrapStack, Inf> UnwindSafe for StatefulInferer<WrapStack, Inf>where
WrapStack: UnwindSafe,
Inf: 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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> InfererExt for Twhere
T: Inferer,
impl<T> InfererExt for Twhere
T: Inferer,
Source§fn with_default_epsilon(self, key: &str) -> Result<EpsilonInjector<Self>>
fn with_default_epsilon(self, key: &str) -> Result<EpsilonInjector<Self>>
Source§fn with_epsilon<G: NoiseGenerator>(
self,
generator: G,
key: &str,
) -> Result<EpsilonInjector<Self, G>>
fn with_epsilon<G: NoiseGenerator>( self, generator: G, key: &str, ) -> Result<EpsilonInjector<Self, G>>
Source§fn into_batched(self) -> Batched<Self>
fn into_batched(self) -> Batched<Self>
Source§fn infer(
&mut self,
observations: HashMap<u64, State<'_>>,
) -> Result<HashMap<u64, Response<'_>>, Error>
fn infer( &mut self, observations: HashMap<u64, State<'_>>, ) -> Result<HashMap<u64, Response<'_>>, Error>
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