pub fn eval_order_for_nodes<TI: TensorInfo>(
    nodes: &[Node<TI>],
    inputs: &[usize],
    targets: &[usize],
) -> TractResult<Vec<usize>> {
    let mut done = bit_set::BitSet::with_capacity(nodes.len());
    let mut needed: Vec<usize> = vec![];
    let mut order: Vec<usize> = vec![];
    for &t in targets {
        needed.push(t);
    }
    while let Some(&node) = needed.last() {
        if done.contains(node) {
            needed.pop();
            continue;
        }
        if inputs.contains(&node) || nodes[node].inputs.iter().all(|i| done.contains(i.node)) {
            order.push(node);
            needed.pop();
            done.insert(node);
        } else {
            for input in nodes[node].inputs.iter().rev() {
                if !done.contains(input.node) {
                    needed.push(input.node);
                }
            }
        }
    }
    Ok(order)
}
/// Find a working evaluation order for a list of nodes.
Find a working evaluation order for a list of nodes.
Find a working evaluation order for a list of nodes .
pub fn eval_order_for_nodes<TI: TensorInfo>(
    nodes: &[Node<TI>],
    inputs: &[usize],
    targets: &[usize],
) -> TractResult<Vec<usize>> {
    let mut done = bit_set::BitSet::with_capacity(nodes.len());
    let mut needed: Vec<usize> = vec![];
    let mut order: Vec<usize> = vec![];
    for &t in targets {
        needed.push(t);
    }
    while let Some(&node) = needed.last() {
        if done.contains(node) {
            needed.pop();
            continue;
        }
        if inputs.contains(&node) || nodes[node].inputs.iter().all(|i| done.contains(i.node)) {
            order.push(node);
            needed.pop();
            done.insert(node);
        } else {
            for input in nodes[node].inputs.iter().rev() {
                if !done.contains(input.node) {
                    needed.push(input.node);
                }
            }
        }
    }
    Ok(order)
}
pub fn eval_order_for_nodes < TI : TensorInfo > ( nodes : & [ Node < TI > ] , inputs : & [ usize ] , targets : & [ usize ] , ) -> TractResult < Vec < usize > > { let mut done = bit_set :: BitSet :: with_capacity ( nodes . len ( ) ) ; let mut needed : Vec < usize > = vec ! [ ] ; let mut order : Vec < usize > = vec ! [ ] ; for & t in targets { needed . push ( t ) ; } while let Some ( & node ) = needed . last ( ) { if done . contains ( node ) { needed . pop ( ) ; continue ; } if inputs . contains ( & node ) || nodes [ node ] . inputs . iter ( ) . all ( | i | done . contains ( i . node ) ) { order . push ( node ) ; needed . pop ( ) ; done . insert ( node ) ; } else { for input in nodes [ node ] . inputs . iter ( ) . rev ( ) { if ! done . contains ( input . node ) { needed . push ( input . node ) ; } } } } Ok ( order ) }
Find a working evaluation order for a list of nodes.
Find a working evaluation order for a list of nodes .
nodes
&[Node<TI>]
inputs
&[usize]
targets
&[usize]
nodes
&[Node<TI>]
inputs
&[usize]
targets
&[usize]