pub struct Scan {
pub skip: usize,
pub reset_every_turn: bool,
pub external_state: bool,
pub body: TypedModel,
pub decluttered: bool,
pub input_mapping: Vec<InputMapping>,
pub output_mapping: Vec<OutputMapping<TDim>>,
}Fields§
§skip: usize§reset_every_turn: bool§external_state: boolTrue iff the caller manages State inputs externally — they supply a
fresh value every run (typically reading the Scan’s last_value_slot
output and feeding it back into the next call’s State input). This
is set explicitly at construction time, e.g. by the ONNX LSTM/GRU/
RNN importer when both initial_h and Y_h are exposed (parakeet
decoder). When true, declutter_single_loop can safely inline a
stateful single-iter Scan because the caller’s per-call value
reaches the body directly. When false (default), tract carries
State across calls internally and inlining would break recurrence
(issue #2157).
body: TypedModel§decluttered: bool§input_mapping: Vec<InputMapping>§output_mapping: Vec<OutputMapping<TDim>>Implementations§
Source§impl Scan
impl Scan
pub fn to_codegen_op(&self, optimize_inner: bool) -> TractResult<OptScan>
pub fn new( body: TypedModel, input_mapping: Vec<InputMapping>, output_mapping: Vec<OutputMapping<TDim>>, skip: usize, ) -> TractResult<Scan>
pub fn iteration_count(&self, inputs: &[&TypedFact]) -> Option<TDim>
Trait Implementations§
Source§impl EvalOp for Scan
impl EvalOp for Scan
fn is_stateless(&self) -> bool
fn state( &self, session: &TurnState, node_id: usize, ) -> TractResult<Option<Box<dyn OpState>>>
fn eval(&self, inputs: TVec<TValue>) -> TractResult<TVec<TValue>>
fn eval_with_session( &self, node_id: usize, session: &TurnState, inputs: TVec<TValue>, ) -> TractResult<TVec<TValue>>
Source§impl Op for Scan
impl Op for Scan
fn name(&self) -> StaticName
Source§fn info(&self) -> TractResult<Vec<String>>
fn info(&self) -> TractResult<Vec<String>>
Short (one-line) strings giving hints on internal implementation or
important configuration details to be displayed in dumps.
Source§fn validation(&self) -> Validation
fn validation(&self) -> Validation
The kind of accuracy check that should be performed on operation when
testing them.
fn as_typed(&self) -> Option<&dyn TypedOp>
Source§impl TypedOp for Scan
impl TypedOp for Scan
Source§fn output_facts(&self, inputs: &[&TypedFact]) -> TractResult<TVec<TypedFact>>
fn output_facts(&self, inputs: &[&TypedFact]) -> TractResult<TVec<TypedFact>>
Deduce output facts from input facts.
fn axes_mapping( &self, inputs: &[&TypedFact], outputs: &[&TypedFact], ) -> TractResult<AxesMapping>
fn suggested_axis_changes(&self) -> TractResult<TVec<(InOut, AxisOp)>>
fn change_axes( &self, model: &TypedModel, node: &TypedNode, io: InOut, change: &AxisOp, ) -> TractResult<Option<AxisChangeConsequence>>
Source§fn declutter_with_session(
&self,
session: &mut OptimizerSession<'_>,
model: &TypedModel,
node: &TypedNode,
) -> TractResult<Option<TypedModelPatch>>
fn declutter_with_session( &self, session: &mut OptimizerSession<'_>, model: &TypedModel, node: &TypedNode, ) -> TractResult<Option<TypedModelPatch>>
Declutter the op to the tract_core operator set as much as possible.
Source§fn set_symbols(
&self,
_source: &TypedModel,
node: &TypedNode,
target: &mut TypedModel,
mapping: &HashMap<OutletId, OutletId>,
subs: &HashMap<Symbol, TDim>,
) -> TractResult<TVec<OutletId>>
fn set_symbols( &self, _source: &TypedModel, node: &TypedNode, target: &mut TypedModel, mapping: &HashMap<OutletId, OutletId>, subs: &HashMap<Symbol, TDim>, ) -> TractResult<TVec<OutletId>>
Transform the op by substituting one or more symbols with TDim
expressions (a concrete integer is
TDim::Val(v); an expression
can be any other TDim, including symbolic ones).Source§fn codegen(
&self,
model: &TypedModel,
node: &TypedNode,
) -> TractResult<Option<TypedModelPatch>>
fn codegen( &self, model: &TypedModel, node: &TypedNode, ) -> TractResult<Option<TypedModelPatch>>
Translate the op into the most efficient form possible for execution. Read more
Source§fn fuse(
&self,
_model: &TypedModel,
_node: &TypedNode,
) -> TractResult<Option<TypedModelPatch>>
fn fuse( &self, _model: &TypedModel, _node: &TypedNode, ) -> TractResult<Option<TypedModelPatch>>
Fuse op after codegen to deal with local optimisations.
Source§fn declutter(
&self,
model: &TypedModel,
node: &TypedNode,
) -> TractResult<Option<TypedModelPatch>>
fn declutter( &self, model: &TypedModel, node: &TypedNode, ) -> TractResult<Option<TypedModelPatch>>
Declutter the op to the tract_core operator set as much as possible.
Source§fn cost(&self, _inputs: &[&TypedFact]) -> TractResult<TVec<(Cost, TDim)>>
fn cost(&self, _inputs: &[&TypedFact]) -> TractResult<TVec<(Cost, TDim)>>
Computes a cost hint of the operation. Read more
Source§fn input_roi(
&self,
model: &TypedModel,
node: &TypedNode,
) -> TractResult<Option<TVec<Option<TDim>>>>
fn input_roi( &self, model: &TypedModel, node: &TypedNode, ) -> TractResult<Option<TVec<Option<TDim>>>>
Derive ROI (region of interest) expressions for this node’s inputs.
Called by the PropagateRoi pass. Default returns None (no propagation).
Override to introduce ROIs or bubble them through.
fn slice( &self, patch: &mut TypedModelPatch, model: &TypedModel, node: &TypedNode, prefix: &str, inputs: &[OutletId], output_axis: usize, start: &TDim, end: &TDim, ) -> TractResult<Option<TVec<OutletId>>>
Source§fn quantize(
&self,
model: &TypedModel,
node: &TypedNode,
dt: DatumType,
scale: f32,
zero_point: i32,
) -> TractResult<Option<Box<dyn TypedOp>>>
fn quantize( &self, model: &TypedModel, node: &TypedNode, dt: DatumType, scale: f32, zero_point: i32, ) -> TractResult<Option<Box<dyn TypedOp>>>
Transforms the op in an equivalent one, operating on dt (i8 or u8). Read more
Source§fn nested_model_multipliers(
&self,
inputs: &[&TypedFact],
) -> Vec<(StaticName, TDim)>
fn nested_model_multipliers( &self, inputs: &[&TypedFact], ) -> Vec<(StaticName, TDim)>
Nested model multipliers, with label (for profiling).
impl Eq for Scan
Auto Trait Implementations§
impl Freeze for Scan
impl !RefUnwindSafe for Scan
impl Send for Scan
impl Sync for Scan
impl Unpin for Scan
impl UnsafeUnpin for Scan
impl !UnwindSafe for Scan
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
Converts
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> ⓘ
Converts
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