1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Canonical handling of the default ONNX operator domain.
//!
//! The default ONNX operator set has **two equivalent spellings**: the empty
//! string `""` and the explicit `"ai.onnx"`. They denote the *same* domain.
//!
//! To avoid comparing both spellings in dozens of runtime hot paths, the loader
//! **canonicalizes** the default domain to `""` at the IR-load boundary. This
//! establishes a post-load invariant:
//!
//! > **In loaded IR, the default ONNX domain is always the empty string;
//! > `"ai.onnx"` never appears.**
//!
//! Given that invariant, code operating on already-loaded IR can simply test
//! [`str::is_empty`] (or [`Node::is_default_domain`]). Code that operates on
//! *raw proto* input — before normalization — must still accept both spellings
//! via the free [`is_default_domain`] helper.
/// The explicit spelling of the default ONNX operator domain.
///
/// Semantically identical to the empty string `""`.
pub const AI_ONNX_DOMAIN: &str = "ai.onnx";
/// Canonicalize an operator domain to its post-load form.
///
/// Maps the explicit default-domain spelling `"ai.onnx"` to the canonical empty
/// string `""`; every other domain (including non-default domains such as
/// `com.microsoft`) is returned unchanged.
///
/// The loader applies this at every point it materializes IR from the ONNX
/// proto so that, after load, the IR never contains `"ai.onnx"`.
/// Whether a **raw** operator domain string denotes the default ONNX domain.
///
/// Accepts *both* spellings (`""` and `"ai.onnx"`). Use this on paths that see
/// raw proto or external input before normalization (loader validation, encoder
/// write-back, display). On already-loaded IR, prefer [`str::is_empty`] or
/// [`Node::is_default_domain`], which rely on the post-load invariant.