pub fn analyse_one(&mut self, node: usize) -> TractResult<Vec<(OutletId, TensorFact)>> {
        let mut changed_edges = vec![];
        {
            let node = &self.model.borrow().nodes()[node];
            debug!("Starting step for #{} {} ({})", node.id, node.name, node.op.name(),);

            let (inputs, outputs) = self.model.borrow().node_facts(node.id)?;
            if log_enabled!(log::Level::Trace) {
                for (ix, i) in inputs.iter().enumerate() {
                    trace!("  Input  #{}: {:?}", ix, i);
                }
                for (ix, o) in outputs.iter().enumerate() {
                    trace!("  Output #{}: {:?}", ix, o);
                }
            }

            let inferred = node
                .op
                .infer(inputs, outputs)
                .map_err(|e| format!("while running inference on {} : {}", node, e))?;

            for (ix, &outlet) in node.inputs.iter().enumerate() {
                let inferred_fact = &inferred.0[ix];
                let old_fact = self.model.borrow().outlet_fact(outlet)?;
                let unified = inferred_fact
                    .unify(&old_fact)
                    .map_err(|e| format!("while unifying inputs of {} : {}", node, e))?;

                if &unified != old_fact {
                    debug!("  Refined {:?}: {:?} -> {:?}", outlet, old_fact, unified);
                    changed_edges.push((outlet, unified));
                }
            }

            for (ix, inferred_fact) in inferred.1.iter().enumerate() {
                let old_fact = self.model.borrow().outlet_fact(OutletId::new(node.id, ix))?;
                let unified = old_fact.unify(inferred_fact)?;

                if &unified != old_fact {
                    let outlet = OutletId::new(node.id, ix);
                    debug!("  Refined {:?}: {:?} -> {:?}", outlet, old_fact, unified);
                    changed_edges.push((outlet, unified));
                }
            }
        }
        for (outlet, fact) in &changed_edges {
            self.model.borrow_mut().set_outlet_fact(*outlet, fact.clone())?;
        }
        Ok(changed_edges)
    }
/// Tries to run a single step of the analysis, and returns whether
/// there was any additional information gained during the step.
Tries to run a single step of the analysis, and returns whether
there was any additional information gained during the step.
Tries to run a single step of the analysis and returns whether there was any additional information gained during the step .
pub fn analyse_one(&mut self, node: usize) -> TractResult<Vec<(OutletId, TensorFact)>> {
        let mut changed_edges = vec![];
        {
            let node = &self.model.borrow().nodes()[node];
            debug!("Starting step for #{} {} ({})", node.id, node.name, node.op.name(),);
            let (inputs, outputs) = self.model.borrow().node_facts(node.id)?;
            if log_enabled!(log::Level::Trace) {
                for (ix, i) in inputs.iter().enumerate() {
                    trace!("  Input  #{}: {:?}", ix, i);
                }
                for (ix, o) in outputs.iter().enumerate() {
                    trace!("  Output #{}: {:?}", ix, o);
                }
            }
            let inferred = node
                .op
                .infer(inputs, outputs)
                .map_err(|e| format!("while running inference on {} : {}", node, e))?;
            for (ix, &outlet) in node.inputs.iter().enumerate() {
                let inferred_fact = &inferred.0[ix];
                let old_fact = self.model.borrow().outlet_fact(outlet)?;
                let unified = inferred_fact
                    .unify(&old_fact)
                    .map_err(|e| format!("while unifying inputs of {} : {}", node, e))?;
                if &unified != old_fact {
                    debug!("  Refined {:?}: {:?} -> {:?}", outlet, old_fact, unified);
                    changed_edges.push((outlet, unified));
                }
            }
            for (ix, inferred_fact) in inferred.1.iter().enumerate() {
                let old_fact = self.model.borrow().outlet_fact(OutletId::new(node.id, ix))?;
                let unified = old_fact.unify(inferred_fact)?;
                if &unified != old_fact {
                    let outlet = OutletId::new(node.id, ix);
                    debug!("  Refined {:?}: {:?} -> {:?}", outlet, old_fact, unified);
                    changed_edges.push((outlet, unified));
                }
            }
        }
        for (outlet, fact) in &changed_edges {
            self.model.borrow_mut().set_outlet_fact(*outlet, fact.clone())?;
        }
        Ok(changed_edges)
    }
pub fn analyse_one ( & mut self , node : usize ) -> TractResult < Vec < ( OutletId , TensorFact ) > > { let mut changed_edges = vec ! [ ] ; { let node = & self . model . borrow ( ) . nodes ( ) [ node ] ; debug ! ( " " node id node name node op name ( ) ) ; let ( inputs , outputs ) = self . model . borrow ( ) . node_facts ( node . id ) ? ; if log_enabled ! ( log Level Trace ) { for ( ix , i ) in inputs . iter ( ) . enumerate ( ) { trace ! ( " " ix i ) ; } for ( ix , o ) in outputs . iter ( ) . enumerate ( ) { trace ! ( " " ix o ) ; } } let inferred = node . op . infer ( inputs , outputs ) . map_err ( | e | format ! ( " " node e ) ) ? ; for ( ix , & outlet ) in node . inputs . iter ( ) . enumerate ( ) { let inferred_fact = & inferred . 0 [ ix ] ; let old_fact = self . model . borrow ( ) . outlet_fact ( outlet ) ? ; let unified = inferred_fact . unify ( & old_fact ) . map_err ( | e | format ! ( " " node e ) ) ? ; if & unified != old_fact { debug ! ( " " outlet old_fact unified ) ; changed_edges . push ( ( outlet , unified ) ) ; } } for ( ix , inferred_fact ) in inferred . 1 . iter ( ) . enumerate ( ) { let old_fact = self . model . borrow ( ) . outlet_fact ( OutletId :: new ( node . id , ix ) ) ? ; let unified = old_fact . unify ( inferred_fact ) ? ; if & unified != old_fact { let outlet = OutletId :: new ( node . id , ix ) ; debug ! ( " " outlet old_fact unified ) ; changed_edges . push ( ( outlet , unified ) ) ; } } } for ( outlet , fact ) in & changed_edges { self . model . borrow_mut ( ) . set_outlet_fact ( * outlet , fact . clone ( ) ) ? ; } Ok ( changed_edges ) }
Tries to run a single step of the analysis, and returns whether
there was any additional information gained during the step.
Tries to run a single step of the analysis and returns whether there was any additional information gained during the step .
&mut self
node
usize
&mut self
node
usize