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>> { ... } }
Expand description

An operation with tensor type inference

Required methods

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.

Reinterpret the InferenceOp as an Op.

Reinterpret the InferenceOp as an Op, mutably.

Provided methods

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.

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

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.

Called during translation to TypedModel.

Trait Implementations

Performs the conversion.

Performs the conversion.

Implementors