pub fn most_specific_shape<'a, I: IntoIterator<Item = &'a ShapeFact>>(
    iter: I,
) -> TractResult<Option<&'a ShapeFact>> {
    let mut prev_rank = None;
    let mut prev_concrete = None;
    let mut best = None;

    for shape in iter {
        if let Some(rank) = shape.rank().concretize() {
            if prev_rank.is_some() && rank != prev_rank.unwrap() {
                bail!("Rank mismatch between different shapes.");
            } else {
                prev_rank = Some(rank);
            }

            let concrete = shape.dims().filter(|d| d.is_concrete()).count();

            if prev_concrete.is_none() || concrete > prev_concrete.unwrap() {
                prev_concrete = Some(concrete);
                best = Some(shape)
            }
        }
    }

    Ok(best)
}
/// Returns the most specific closed shape out of an iterator.
Returns the most specific closed shape out of an iterator.
Returns the most specific closed shape out of an iterator .
pub fn most_specific_shape<'a, I: IntoIterator<Item = &'a ShapeFact>>(
    iter: I,
) -> TractResult<Option<&'a ShapeFact>> {
    let mut prev_rank = None;
    let mut prev_concrete = None;
    let mut best = None;
    for shape in iter {
        if let Some(rank) = shape.rank().concretize() {
            if prev_rank.is_some() && rank != prev_rank.unwrap() {
                bail!("Rank mismatch between different shapes.");
            } else {
                prev_rank = Some(rank);
            }
            let concrete = shape.dims().filter(|d| d.is_concrete()).count();
            if prev_concrete.is_none() || concrete > prev_concrete.unwrap() {
                prev_concrete = Some(concrete);
                best = Some(shape)
            }
        }
    }
    Ok(best)
}
pub fn most_specific_shape < ' a , I : IntoIterator < Item = & ' a ShapeFact > > ( iter : I , ) -> TractResult < Option < & ' a ShapeFact > > { let mut prev_rank = None ; let mut prev_concrete = None ; let mut best = None ; for shape in iter { if let Some ( rank ) = shape . rank ( ) . concretize ( ) { if prev_rank . is_some ( ) && rank != prev_rank . unwrap ( ) { bail ! ( " " ) ; } else { prev_rank = Some ( rank ) ; } let concrete = shape . dims ( ) . filter ( | d | d . is_concrete ( ) ) . count ( ) ; if prev_concrete . is_none ( ) || concrete > prev_concrete . unwrap ( ) { prev_concrete = Some ( concrete ) ; best = Some ( shape ) } } } Ok ( best ) }
Returns the most specific closed shape out of an iterator.
Returns the most specific closed shape out of an iterator .
iter
I
iter
I