[][src]Trait tract_hir::internal::TypedOp

pub trait TypedOp: 'static + StatefullOp + Op + Send + Sync + Debug + Downcast + DynHash + DynClone {
    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]>, TractError>; fn invariants(
        &self,
        model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
    ) -> Result<Invariants, TractError> { ... }
fn fuse(
        &self,
        _model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        _node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
    ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>>, TractError> { ... }
fn declutter(
        &self,
        model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
    ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>>, TractError> { ... }
fn cost(
        &self,
        _inputs: &[&TypedFact]
    ) -> Result<SmallVec<[(Cost, TDim); 4]>, TractError> { ... }
fn suggested_axis_changes(
        &self
    ) -> Result<SmallVec<[(InOut, AxisOp); 4]>, TractError> { ... }
fn change_axes(
        &self,
        model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>,
        io: InOut,
        change: &AxisOp
    ) -> Result<Option<AxisChangeConsequence>, TractError> { ... }
fn slice_output(
        &self,
        model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>,
        patch: &mut ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>,
        output_slot: usize,
        axis: usize,
        start: usize,
        end: usize
    ) -> Result<Option<OutletId>, TractError> { ... }
fn quantize(
        &self,
        model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>,
        dt: DatumType,
        scale: f32,
        zero_point: i32
    ) -> Result<Option<Box<dyn TypedOp + 'static>>, TractError> { ... }
fn pulsify(
        &self,
        _source: &ModelImpl<NormalizedFact, Box<dyn TypedOp + 'static>>,
        node: &BaseNode<NormalizedFact, Box<dyn TypedOp + 'static>>,
        _target: &mut ModelImpl<PulsedFact, Box<dyn PulsedOp + 'static>>,
        _mapping: &HashMap<OutletId, OutletId, RandomState>,
        _pulse: usize
    ) -> Result<SmallVec<[OutletId; 4]>, TractError> { ... }
fn codegen(
        &self,
        _model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
        _node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
    ) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>>, TractError> { ... }
fn nested_model_multipliers(
        &self,
        inputs: &[&TypedFact]
    ) -> Vec<(Cow<str>, f64)> { ... } }

Required methods

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

Reinterpret the TypedOp as an Op.

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

Reinterpret the TypedOp as an Op, mutably.

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

Deduce output facts from input facts.

Loading content...

Provided methods

fn invariants(
    &self,
    model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
) -> Result<Invariants, TractError>

fn fuse(
    &self,
    _model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    _node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>>, TractError>

Fuse op after codegen to deal with local optimisations.

fn declutter(
    &self,
    model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>>, TractError>

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

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

Computes a cost hint of the operation.

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

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

fn change_axes(
    &self,
    model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>,
    io: InOut,
    change: &AxisOp
) -> Result<Option<AxisChangeConsequence>, TractError>

fn slice_output(
    &self,
    model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>,
    patch: &mut ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>,
    output_slot: usize,
    axis: usize,
    start: usize,
    end: usize
) -> Result<Option<OutletId>, TractError>

fn quantize(
    &self,
    model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>,
    dt: DatumType,
    scale: f32,
    zero_point: i32
) -> Result<Option<Box<dyn TypedOp + 'static>>, TractError>

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

Returns None if the op can not be translated.

fn pulsify(
    &self,
    _source: &ModelImpl<NormalizedFact, Box<dyn TypedOp + 'static>>,
    node: &BaseNode<NormalizedFact, Box<dyn TypedOp + 'static>>,
    _target: &mut ModelImpl<PulsedFact, Box<dyn PulsedOp + 'static>>,
    _mapping: &HashMap<OutletId, OutletId, RandomState>,
    _pulse: usize
) -> Result<SmallVec<[OutletId; 4]>, TractError>

Translate an op in a normalized network (no constants) to a pulsing form, if possible.

fn codegen(
    &self,
    _model: &ModelImpl<TypedFact, Box<dyn TypedOp + 'static>>,
    _node: &BaseNode<TypedFact, Box<dyn TypedOp + 'static>>
) -> Result<Option<ModelPatch<TypedFact, Box<dyn TypedOp + 'static>>>, TractError>

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 nested_model_multipliers(
    &self,
    inputs: &[&TypedFact]
) -> Vec<(Cow<str>, f64)>

Nested model multipliers, with label (for profiling).

Loading content...

Trait Implementations

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

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

Implementations on Foreign Types

impl TypedOp for MergeOp[src]

impl<T> TypedOp for Im2Col<T> where
    T: Datum + Copy + Zero
[src]

impl TypedOp for TypedSource[src]

impl TypedOp for Delay[src]

impl TypedOp for TypedBinOp[src]

impl TypedOp for ElementWiseOp[src]

impl TypedOp for FiniteReshape[src]

impl TypedOp for MultiBroadcastTo[src]

impl TypedOp for MergeOpUnicast[src]

impl TypedOp for Tile[src]

impl TypedOp for MatMulUnary[src]

impl<T> TypedOp for MatMatMulPackB<T> where
    T: Copy + Datum + Zero
[src]

impl TypedOp for Reduce[src]

impl TypedOp for TypedReshape[src]

impl TypedOp for UnaryOp[src]

Loading content...

Implementors

impl TypedOp for AxisOp[src]

impl TypedOp for ConstantLike[src]

impl TypedOp for EyeLike[src]

impl TypedOp for Flatten[src]

impl TypedOp for Gather[src]

impl TypedOp for Pad[src]

impl TypedOp for Shape[src]

impl TypedOp for Size[src]

impl TypedOp for TypedConcat[src]

impl TypedOp for AvgPool[src]

impl TypedOp for ConvUnary[src]

impl TypedOp for MaxPool[src]

impl TypedOp for Downsample[src]

impl TypedOp for Dummy[src]

impl TypedOp for Identity[src]

impl TypedOp for Const[src]

impl TypedOp for Iff[src]

impl TypedOp for MatMul[src]

impl TypedOp for ArgMaxMin[src]

impl TypedOp for GlobalAvgPool[src]

impl TypedOp for GlobalLpPool[src]

impl TypedOp for GlobalMaxPool[src]

impl TypedOp for LayerHardmax[src]

impl TypedOp for DequantizeLinearF32[src]

impl TypedOp for Scan[src]

impl<D> TypedOp for Slice<D> where
    D: DimLike + ToDim + Hash
[src]

Loading content...