pub struct InferenceRegistry { /* private fields */ }Expand description
A registry mapping (domain, op_type, opset) to an InferenceFn.
Implementations§
Source§impl InferenceRegistry
impl InferenceRegistry
Sourcepub fn infer_graph(
&self,
graph: &mut Graph,
opset_imports: &HashMap<String, u64>,
policy: MergePolicy,
) -> Result<InferenceReport, ShapeInferError>
pub fn infer_graph( &self, graph: &mut Graph, opset_imports: &HashMap<String, u64>, policy: MergePolicy, ) -> Result<InferenceReport, ShapeInferError>
Infer shapes for every value in graph, in topological order.
Seeds every explicitly known value type, runs each node’s rule to fill or
refine its outputs’ types and shape-data, then writes the resolved shapes
back into the graph (lowering symbolic dimension expressions to IR
Dims). Graph outputs are reconciled with their declared shapes under
policy. Returns an InferenceReport of what resolved.
opset_imports selects the effective operator versions; pass
graph.opset_imports.clone() for the model’s own imports.
Source§impl InferenceRegistry
impl InferenceRegistry
Sourcepub fn default_registry() -> Self
pub fn default_registry() -> Self
A registry populated with every built-in rule.
Sourcepub fn register(
&mut self,
domain: &str,
op: &str,
min_opset: u64,
rule: InferenceFn,
)
pub fn register( &mut self, domain: &str, op: &str, min_opset: u64, rule: InferenceFn, )
Register rule for (domain, op) applying from opset min_opset
upward. A later registration at a higher min_opset supersedes this one
for those versions.
Sourcepub fn get(&self, domain: &str, op: &str, version: u64) -> Option<InferenceFn>
pub fn get(&self, domain: &str, op: &str, version: u64) -> Option<InferenceFn>
Look up the rule for (domain, op) effective at opset version: the
registration with the greatest min_opset <= version.
Sourcepub fn operator_count(&self) -> usize
pub fn operator_count(&self) -> usize
Number of distinct (domain, operator) keys in the registry.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of opset-versioned inference rule entries.
Sourcepub fn operator_versions(&self) -> Vec<(&str, &str, u64)>
pub fn operator_versions(&self) -> Vec<(&str, &str, u64)>
Every registered rule as (domain, operator, min_opset), sorted.
This is the full identity of the catalog — its keys and opset floors,
not its handler bodies — and the thing to pin. A swap of the
InferenceFn behind an unchanged triple is deliberately out of scope
here; that is what the behavioural rule tests cover. Neither count above
can see a change that preserves them:
- a rename drops one key and adds another, so
operator_countandentry_countboth hold; - an opset move rewrites an existing entry’s
min_opsetin place, soentry_countholds too.
Both are silent in production rather than loud: Self::get returns
None for a key it does not know and for a version below every
registration, and Self::infer_node treats None permissively —
outputs are left unknown and the model still runs.