Skip to main content

onnx_runtime_shape_inference/
report.rs

1//! The result summary returned by whole-graph inference.
2
3use onnx_runtime_ir::ValueId;
4
5/// A summary of what whole-graph inference resolved.
6///
7/// A value is "resolved" once it has a known dtype and a known-rank shape (every
8/// dimension is concrete or symbolic — never unknown). Values an op rule could
9/// not resolve (unregistered op, data-dependent extent without shape-data) are
10/// listed in [`unresolved`](InferenceReport::unresolved).
11#[derive(Clone, Debug, Default, PartialEq, Eq)]
12pub struct InferenceReport {
13    /// Total number of live values in the graph.
14    pub total_values: usize,
15    /// Values that ended with a resolved shape.
16    pub resolved: Vec<ValueId>,
17    /// Values left without a resolved shape.
18    pub unresolved: Vec<ValueId>,
19    /// Number of fresh symbolic dimensions minted during inference.
20    pub fresh_symbols: usize,
21}
22
23impl InferenceReport {
24    /// The number of resolved values.
25    pub fn num_resolved(&self) -> usize {
26        self.resolved.len()
27    }
28
29    /// The number of unresolved values.
30    pub fn num_unresolved(&self) -> usize {
31        self.unresolved.len()
32    }
33
34    /// Whether every live value in the graph resolved to a known shape.
35    pub fn fully_resolved(&self) -> bool {
36        self.unresolved.is_empty()
37    }
38}