onnx_runtime_shape_inference/report.rs
1//! The result summary returned by whole-graph inference.
2
3use std::collections::HashMap;
4
5use onnx_runtime_ir::ValueId;
6
7use crate::context::ValueType;
8
9/// A summary of what whole-graph inference resolved.
10///
11/// A value is "resolved" once it has a known dtype and a known-rank shape (every
12/// dimension is concrete or symbolic — never unknown). Values an op rule could
13/// not resolve (unregistered op, data-dependent extent without shape-data) are
14/// listed in [`unresolved`](InferenceReport::unresolved).
15#[derive(Clone, Debug, Default, PartialEq, Eq)]
16pub struct InferenceReport {
17 /// Total number of live values in the graph.
18 pub total_values: usize,
19 /// Values that ended with a resolved shape.
20 pub resolved: Vec<ValueId>,
21 /// Values left without a resolved shape.
22 pub unresolved: Vec<ValueId>,
23 /// Number of fresh symbolic dimensions minted during inference.
24 pub fresh_symbols: usize,
25 /// Container-typed values (`Sequence`/`Optional`/`Map`) and their inferred
26 /// element type. Empty for pure-tensor graphs (the tensor path never
27 /// materialises a [`ValueType`]), which keeps that path byte-identical.
28 /// Populated for `Sequence`-family producers and control-flow nodes whose
29 /// body outputs are containers.
30 pub containers: HashMap<ValueId, ValueType>,
31}
32
33impl InferenceReport {
34 /// The number of resolved values.
35 pub fn num_resolved(&self) -> usize {
36 self.resolved.len()
37 }
38
39 /// The number of unresolved values.
40 pub fn num_unresolved(&self) -> usize {
41 self.unresolved.len()
42 }
43
44 /// Whether every live value in the graph resolved to a known shape.
45 pub fn fully_resolved(&self) -> bool {
46 self.unresolved.is_empty()
47 }
48}