[][src]Trait tract_core::ops::Op

pub trait Op: Debug + Clone + Send + Sync + 'static + Downcast + StatefullOp {
    fn name(&self) -> Cow<str>;
fn as_typed(&self) -> Option<&dyn TypedOp>; fn incorporate(
        &self,
        _model: &InferenceModel,
        _node: &InferenceNode
    ) -> TractResult<Option<InferenceModelPatch>> { ... }
fn declutter(
        &self,
        _model: &TypedModel,
        _node: &TypedNode
    ) -> TractResult<Option<TypedModelPatch>> { ... }
fn codegen(
        &self,
        _model: &TypedModel,
        _node: &TypedNode
    ) -> TractResult<Option<TypedModelPatch>> { ... }
fn fuse(
        &self,
        _model: &TypedModel,
        _node: &TypedNode
    ) -> TractResult<Option<TypedModelPatch>> { ... }
fn cost(
        &self,
        _inputs: &[&TypedTensorInfo]
    ) -> TractResult<TVec<(Cost, TDim)>> { ... }
fn nested_models(&self) -> Vec<(Cow<str>, &dyn Model)> { ... }
fn validation(&self) -> Validation { ... }
fn axes_info(
        &self,
        _model: &TypedModel,
        _node: &TypedNode
    ) -> TractResult<AxesInfo> { ... }
fn same_as(&self, _other: &dyn Op) -> bool { ... }
fn info(&self) -> TractResult<Vec<String>> { ... }
fn is_canonic(&self) -> bool { ... } }

A base operation

Required methods

fn name(&self) -> Cow<str>

fn as_typed(&self) -> Option<&dyn TypedOp>

Loading content...

Provided methods

fn incorporate(
    &self,
    _model: &InferenceModel,
    _node: &InferenceNode
) -> TractResult<Option<InferenceModelPatch>>

Early pass on inference model, after analyse, but before translation to typed network. Meant to deal with some framework idiosyncrasies that manifest with temporaries nodes that can run some form of inference but require refactoring the network before it can be evaluated.

Called after succesful analyse, but before translating to typed model.

fn declutter(
    &self,
    _model: &TypedModel,
    _node: &TypedNode
) -> TractResult<Option<TypedModelPatch>>

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

fn codegen(
    &self,
    _model: &TypedModel,
    _node: &TypedNode
) -> TractResult<Option<TypedModelPatch>>

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.

fn fuse(
    &self,
    _model: &TypedModel,
    _node: &TypedNode
) -> TractResult<Option<TypedModelPatch>>

Fuse op after codegen to deal with local optimisations.

fn cost(&self, _inputs: &[&TypedTensorInfo]) -> TractResult<TVec<(Cost, TDim)>>

Computes a cost hint of the operation.

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

fn nested_models(&self) -> Vec<(Cow<str>, &dyn Model)>

Nested models, with label (for audit).

fn validation(&self) -> Validation

The kind of accuracy check that should be performed on operation when testing them.

fn axes_info(
    &self,
    _model: &TypedModel,
    _node: &TypedNode
) -> TractResult<AxesInfo>

fn same_as(&self, _other: &dyn Op) -> bool

Compare two ops.

fn info(&self) -> TractResult<Vec<String>>

Short (one-line) strings giving hints on internal implementation or important configuration details to be displayed in dumps.

fn is_canonic(&self) -> bool

Loading content...

Methods

impl dyn Op

pub fn is<__T: Op>(&self) -> bool

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

pub fn downcast<__T: Op>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>

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.

pub fn downcast_ref<__T: Op>(&self) -> Option<&__T>

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

pub fn downcast_mut<__T: Op>(&mut self) -> Option<&mut __T>

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

impl AsMut<dyn Op + 'static> for dyn InferenceOp[src]

impl AsMut<dyn Op + 'static> for Box<dyn InferenceOp>[src]

impl AsMut<dyn Op + 'static> for dyn TypedOp[src]

impl AsMut<dyn Op + 'static> for Box<dyn TypedOp>[src]

impl AsRef<dyn Op + 'static> for dyn InferenceOp[src]

impl AsRef<dyn Op + 'static> for Box<dyn InferenceOp>[src]

impl AsRef<dyn Op + 'static> for dyn TypedOp[src]

impl AsRef<dyn Op + 'static> for Box<dyn TypedOp>[src]

Implementors

impl Op for AddDims[src]

impl Op for Concat[src]

impl Op for ConstantLike[src]

impl Op for ConstantOfShape[src]

impl Op for Crop[src]

impl Op for EyeLike[src]

impl Op for Flatten[src]

impl Op for Gather[src]

impl Op for IntoShape[src]

impl Op for MultiBroadcastTo[src]

impl Op for Pad[src]

impl Op for PermuteAxes[src]

impl Op for Reshape[src]

impl Op for RmDims[src]

impl Op for Shape[src]

impl Op for Size[src]

impl Op for Split[src]

impl Op for Squeeze[src]

impl Op for Tile[src]

impl Op for TypedMultiBroadcastTo[src]

impl Op for InferenceBinOp[src]

impl Op for MergeOp[src]

impl Op for MergeOpUnicast[src]

impl Op for Nary[src]

impl Op for TypedBinOp[src]

impl Op for UnaryOp[src]

impl Op for Cast[src]

impl Op for Direct[src]

impl Op for AvgPool[src]

impl Op for Conv[src]

impl Op for ConvUnary[src]

impl Op for MaxPool[src]

impl Op for Downsample[src]

impl Op for Dummy[src]

impl Op for Identity[src]

impl Op for Const[src]

impl Op for Iff[src]

impl Op for Not[src]

impl Op for MatMul[src]

impl Op for MatMulUnary[src]

impl Op for Abs[src]

impl Op for Acos[src]

impl Op for Acosh[src]

impl Op for Asin[src]

impl Op for Asinh[src]

impl Op for Atan[src]

impl Op for Atanh[src]

impl Op for Ceil[src]

impl Op for Cos[src]

impl Op for Cosh[src]

impl Op for Exp[src]

impl Op for Floor[src]

impl Op for IsNan[src]

impl Op for Ln[src]

impl Op for Neg[src]

impl Op for Recip[src]

impl Op for Rsqrt[src]

impl Op for ScalarMax[src]

impl Op for ScalarMin[src]

impl Op for ScalarMinMax[src]

impl Op for Sign[src]

impl Op for Sin[src]

impl Op for Sinh[src]

impl Op for Sqrt[src]

impl Op for Tan[src]

impl Op for Tanh[src]

impl Op for ArgMaxMin[src]

impl Op for Elu[src]

impl Op for GlobalAvgPool[src]

impl Op for GlobalLpPool[src]

impl Op for GlobalMaxPool[src]

impl Op for Hardsigmoid[src]

impl Op for LayerHardmax[src]

impl Op for LayerLogSoftmax[src]

impl Op for LayerSoftmax[src]

impl Op for LeakyRelu[src]

impl Op for Lrn[src]

impl Op for ParametricSoftplus[src]

impl Op for Reduce[src]

impl Op for ScaledTanh[src]

impl Op for Selu[src]

impl Op for Sigmoid[src]

impl Op for Softplus[src]

impl Op for Softsign[src]

impl Op for ThresholdedRelu[src]

impl Op for Inference[src]

impl Op for Typed[src]

impl Op for Source[src]

impl Op for TypedSource[src]

impl Op for UnimplementedOp[src]

impl Op for Delay[src]

impl<D: DimLike + ToDim> Op for Slice<D>[src]

impl<T> Op for MatMulUnaryFinite<T> where
    T: Copy + Datum + Add + Mul + Zero + FloatLike,
    f32: AsPrimitive<T>, 
[src]

Loading content...