Trait tract_hir::infer::InferenceOp[][src]

pub trait InferenceOp: Op + Debug + DynClone + Send + Sync + 'static + Downcast + EvalOp + DynHash {
    fn infer_facts(
        &mut self,
        inputs: TVec<&InferenceFact>,
        outputs: TVec<&InferenceFact>,
        observed: TVec<&InferenceFact>
    ) -> TractResult<(TVec<InferenceFact>, TVec<InferenceFact>, TVec<InferenceFact>)>;
fn as_op(&self) -> &dyn Op;
fn as_op_mut(&mut self) -> &mut dyn Op; fn infer(
        &mut self,
        inputs: TVec<&InferenceFact>,
        outputs: TVec<&InferenceFact>,
        observed: TVec<&InferenceFact>
    ) -> TractResult<(TVec<InferenceFact>, TVec<InferenceFact>, TVec<InferenceFact>)> { ... }
fn observe_outlets(
        &self,
        _model: &InferenceModel,
        _node: &InferenceNode
    ) -> TractResult<Vec<OutletId>> { ... }
fn incorporate(
        &self,
        model: &InferenceModel,
        node: &InferenceNode
    ) -> TractResult<Option<InferenceModelPatch>> { ... }
fn nboutputs(&self) -> TractResult<usize> { ... }
fn to_typed(
        &self,
        source: &InferenceModel,
        node: &InferenceNode,
        target: &mut TypedModel,
        mapping: &HashMap<OutletId, OutletId>
    ) -> TractResult<TVec<OutletId>> { ... } }

An operation with tensor type inference

Required methods

fn infer_facts(
    &mut self,
    inputs: TVec<&InferenceFact>,
    outputs: TVec<&InferenceFact>,
    observed: TVec<&InferenceFact>
) -> TractResult<(TVec<InferenceFact>, TVec<InferenceFact>, TVec<InferenceFact>)>
[src]

Infer properties about inputs and output tensors. This method does not need to deal with the “trivial” stateless op with fully determined inputs cases.

Most of the time, it is implemented using InferenceRulesOp.

fn as_op(&self) -> &dyn Op[src]

Reinterpret the InferenceOp as an Op.

fn as_op_mut(&mut self) -> &mut dyn Op[src]

Reinterpret the InferenceOp as an Op, mutably.

Loading content...

Provided methods

fn infer(
    &mut self,
    inputs: TVec<&InferenceFact>,
    outputs: TVec<&InferenceFact>,
    observed: TVec<&InferenceFact>
) -> TractResult<(TVec<InferenceFact>, TVec<InferenceFact>, TVec<InferenceFact>)>
[src]

Infers properties about the input and output tensors.

The inputs and outputs arguments correspond to properties about the input and output tensors that are already known.

The default implementation will call the private infer_facts method, which is usually implemented using the InferenceRulesOp trait. It will also try to eval() the op if its a EvalOp and if the inputs are fully determined.

Returns Err in case of an unrecoverable error during the inference, and the refined properties about the inputs and outputs otherwise.

fn observe_outlets(
    &self,
    _model: &InferenceModel,
    _node: &InferenceNode
) -> TractResult<Vec<OutletId>>
[src]

Allow an op to specify a supplementary list of outlets facts that will trigger inference again.

fn incorporate(
    &self,
    model: &InferenceModel,
    node: &InferenceNode
) -> TractResult<Option<InferenceModelPatch>>
[src]

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 nboutputs(&self) -> TractResult<usize>[src]

fn to_typed(
    &self,
    source: &InferenceModel,
    node: &InferenceNode,
    target: &mut TypedModel,
    mapping: &HashMap<OutletId, OutletId>
) -> TractResult<TVec<OutletId>>
[src]

Called during translation to TypedModel.

Loading content...

Trait Implementations

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

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

Implementors

impl InferenceOp for InferenceScan[src]

impl<O: InferenceRulesOp + Op> InferenceOp for O[src]

Loading content...