Trait tract_hir::internal::TypedOp

source ·
pub trait TypedOp: Op + Debug + DynClone + Send + Sync + 'static + Downcast + EvalOp {
Show 15 methods // Required methods fn as_op(&self) -> &(dyn Op + 'static); fn as_op_mut(&mut self) -> &mut (dyn Op + 'static); fn output_facts( &self, inputs: &[&TypedFact] ) -> Result<SmallVec<[TypedFact; 4]>, Error>; // Provided methods fn axes_mapping( &self, inputs: &[&TypedFact], outputs: &[&TypedFact] ) -> Result<AxesMapping, Error> { ... } fn fuse( &self, _model: &Graph<TypedFact, Box<dyn TypedOp>>, _node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error> { ... } fn declutter_with_session( &self, session: &mut OptimizerSession<'_>, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error> { ... } fn declutter( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error> { ... } fn cost( &self, _inputs: &[&TypedFact] ) -> Result<SmallVec<[(Cost, TDim); 4]>, Error> { ... } fn suggested_axis_changes( &self ) -> Result<SmallVec<[(InOut, AxisOp); 4]>, Error> { ... } fn change_axes( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>>, io: InOut, change: &AxisOp ) -> Result<Option<AxisChangeConsequence>, Error> { ... } fn slice( &self, patch: &mut ModelPatch<TypedFact, Box<dyn TypedOp>>, prefix: &str, inputs: &[OutletId], output_axis: usize, start: usize, end: usize ) -> Result<Option<SmallVec<[OutletId; 4]>>, Error> { ... } fn quantize( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>>, dt: DatumType, scale: f32, zero_point: i32 ) -> Result<Option<Box<dyn TypedOp>>, Error> { ... } fn concretize_dims( &self, source: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>>, target: &mut Graph<TypedFact, Box<dyn TypedOp>>, mapping: &HashMap<OutletId, OutletId>, values: &SymbolValues ) -> Result<SmallVec<[OutletId; 4]>, Error> { ... } fn codegen( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error> { ... } fn nested_model_multipliers( &self, inputs: &[&TypedFact] ) -> Vec<(Cow<'_, str>, f64)> { ... }
}

Required Methods§

source

fn as_op(&self) -> &(dyn Op + 'static)

Reinterpret the TypedOp as an Op.

source

fn as_op_mut(&mut self) -> &mut (dyn Op + 'static)

Reinterpret the TypedOp as an Op, mutably.

source

fn output_facts( &self, inputs: &[&TypedFact] ) -> Result<SmallVec<[TypedFact; 4]>, Error>

Deduce output facts from input facts.

Provided Methods§

source

fn axes_mapping( &self, inputs: &[&TypedFact], outputs: &[&TypedFact] ) -> Result<AxesMapping, Error>

source

fn fuse( &self, _model: &Graph<TypedFact, Box<dyn TypedOp>>, _node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error>

Fuse op after codegen to deal with local optimisations.

source

fn declutter_with_session( &self, session: &mut OptimizerSession<'_>, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error>

Declutter the op to the tract_core operator set as much as possible.

source

fn declutter( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error>

Declutter the op to the tract_core operator set as much as possible.

source

fn cost( &self, _inputs: &[&TypedFact] ) -> Result<SmallVec<[(Cost, TDim); 4]>, Error>

Computes a cost hint of the operation.

Each pair is a type of operation and a number per call on eval.

source

fn suggested_axis_changes( &self ) -> Result<SmallVec<[(InOut, AxisOp); 4]>, Error>

source

fn change_axes( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>>, io: InOut, change: &AxisOp ) -> Result<Option<AxisChangeConsequence>, Error>

source

fn slice( &self, patch: &mut ModelPatch<TypedFact, Box<dyn TypedOp>>, prefix: &str, inputs: &[OutletId], output_axis: usize, start: usize, end: usize ) -> Result<Option<SmallVec<[OutletId; 4]>>, Error>

source

fn quantize( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>>, dt: DatumType, scale: f32, zero_point: i32 ) -> Result<Option<Box<dyn TypedOp>>, Error>

Transforms the op in an equivalent one, operating on dt (i8 or u8).

Returns None if the op can not be translated.

source

fn concretize_dims( &self, source: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>>, target: &mut Graph<TypedFact, Box<dyn TypedOp>>, mapping: &HashMap<OutletId, OutletId>, values: &SymbolValues ) -> Result<SmallVec<[OutletId; 4]>, Error>

Transform the op into by providing a value to one or more symbols.

source

fn codegen( &self, model: &Graph<TypedFact, Box<dyn TypedOp>>, node: &Node<TypedFact, Box<dyn TypedOp>> ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp>>>, Error>

Translate the op into the most efficient form possible for execution.

This transformation is supposed to be final, no more pass are expected to be run on the codegen networks.

source

fn nested_model_multipliers( &self, inputs: &[&TypedFact] ) -> Vec<(Cow<'_, str>, f64)>

Nested model multipliers, with label (for profiling).

Implementations§

source§

impl dyn TypedOp

source

pub fn is<__T>(&self) -> bool
where __T: TypedOp,

Returns true if the trait object wraps an object of type __T.

source

pub fn downcast<__T>( self: Box<dyn TypedOp> ) -> Result<Box<__T>, Box<dyn TypedOp>>
where __T: TypedOp,

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

source

pub fn downcast_rc<__T>( self: Rc<dyn TypedOp> ) -> Result<Rc<__T>, Rc<dyn TypedOp>>
where __T: TypedOp,

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

source

pub fn downcast_ref<__T>(&self) -> Option<&__T>
where __T: TypedOp,

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

source

pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>
where __T: TypedOp,

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Trait Implementations§

source§

impl AsMut<dyn Op> for Box<dyn TypedOp>

source§

fn as_mut(&mut self) -> &mut (dyn Op + 'static)

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsMut<dyn Op> for dyn TypedOp

source§

fn as_mut(&mut self) -> &mut (dyn Op + 'static)

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<dyn Op> for Box<dyn TypedOp>

source§

fn as_ref(&self) -> &(dyn Op + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<dyn Op> for dyn TypedOp

source§

fn as_ref(&self) -> &(dyn Op + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'clone> Clone for Box<dyn TypedOp + 'clone>

source§

fn clone(&self) -> Box<dyn TypedOp + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn TypedOp + Send + 'clone>

source§

fn clone(&self) -> Box<dyn TypedOp + Send + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn TypedOp + Send + Sync + 'clone>

source§

fn clone(&self) -> Box<dyn TypedOp + Send + Sync + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'clone> Clone for Box<dyn TypedOp + Sync + 'clone>

source§

fn clone(&self) -> Box<dyn TypedOp + Sync + 'clone>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Display for Box<dyn TypedOp>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Box<dyn TypedOp>> for Box<dyn TypedOp>

source§

fn from(it: &'a Box<dyn TypedOp>) -> Box<dyn TypedOp>

Converts to this type from the input type.
source§

impl<O> From<O> for Box<dyn TypedOp>
where O: TypedOp,

source§

fn from(it: O) -> Box<dyn TypedOp>

Converts to this type from the input type.

Implementors§

source§

impl TypedOp for AxisOp

source§

impl TypedOp for ConstantLike

source§

impl TypedOp for EyeLike

source§

impl TypedOp for GatherNd

source§

impl TypedOp for Pad

source§

impl TypedOp for ScatterNd

source§

impl TypedOp for Slice

source§

impl TypedOp for StridedSlice

source§

impl TypedOp for TypedConcat

source§

impl TypedOp for Downsample

source§

impl TypedOp for Dummy

source§

impl TypedOp for Identity

source§

impl TypedOp for Const

source§

impl TypedOp for IfThenElse

source§

impl TypedOp for DequantizeLinearF32

source§

impl TypedOp for Scan

source§

impl TypedOp for MultiBroadcastTo

source§

impl TypedOp for DynSlice

source§

impl TypedOp for Gather

source§

impl TypedOp for GatherElements

source§

impl TypedOp for OneHot

source§

impl TypedOp for Range

source§

impl TypedOp for FiniteReshape

source§

impl TypedOp for ScatterElements

source§

impl TypedOp for Tile

source§

impl TypedOp for Topk

source§

impl TypedOp for Trilu

source§

impl TypedOp for MergeOpUnicast

source§

impl TypedOp for TypedBinOp

source§

impl TypedOp for Cast

source§

impl TypedOp for Conv

source§

impl TypedOp for Im2Col

source§

impl TypedOp for Deconv

source§

impl TypedOp for MaxPool

source§

impl TypedOp for SumPool

source§

impl TypedOp for BasicMatMul

source§

impl TypedOp for EinSum

source§

impl TypedOp for ElementWiseOp

source§

impl TypedOp for Fft

source§

impl TypedOp for Stft

source§

impl TypedOp for Iff

source§

impl TypedOp for LirMatMulUnary

source§

impl TypedOp for MatMatMulPack

source§

impl TypedOp for ForceEval

source§

impl TypedOp for Load

source§

impl TypedOp for Store

source§

impl TypedOp for Reduce

source§

impl TypedOp for Softmax

source§

impl TypedOp for LirScan

source§

impl TypedOp for TypedSource

source§

impl TypedOp for SubmodelOp