pub struct Node {
pub id: NodeId,
pub name: String,
pub op_type: String,
pub domain: String,
pub version: Option<i64>,
pub inputs: Vec<Option<ValueId>>,
pub outputs: Vec<ValueId>,
pub attributes: HashMap<String, Attribute>,
pub doc_string: Option<String>,
pub device: Option<DeviceId>,
pub exec_order: Option<usize>,
}Expand description
An operation in the graph.
Inputs are Option<ValueId> because ONNX ops may have optional (skipped)
inputs represented by empty names; a None slot preserves positional
arity. Outputs are always present (SSA values).
Fields§
§id: NodeId§name: StringOptional ONNX node name ("" means unnamed).
op_type: String§domain: StringOperator domain ("" == the default ONNX domain).
version: Option<i64>Opset version of the operator called.
If None, the version is unspecified and follows the owning graph’s
opset_imports. This property is special to ONNX IR to allow mixed opset
usage in a graph for more flexible graph transformations; it does not
exist in the ONNX protobuf spec. For example, a fusion may emit an
opset-24 Swish into a graph whose other default-domain nodes still use
the graph’s older exported opset, avoiding a false graph-wide upgrade.
inputs: Vec<Option<ValueId>>§outputs: Vec<ValueId>§attributes: HashMap<String, Attribute>§doc_string: Option<String>§device: Option<DeviceId>Device placement, filled in by the placement pass.
exec_order: Option<usize>Position in the final execution schedule, filled in by the scheduler.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(
id: NodeId,
op_type: impl Into<String>,
inputs: Vec<Option<ValueId>>,
outputs: Vec<ValueId>,
) -> Self
pub fn new( id: NodeId, op_type: impl Into<String>, inputs: Vec<Option<ValueId>>, outputs: Vec<ValueId>, ) -> Self
A new node with the given op type and edges, and no attributes.
Sourcepub fn input_values(&self) -> impl Iterator<Item = ValueId> + '_
pub fn input_values(&self) -> impl Iterator<Item = ValueId> + '_
Iterate over the present (non-skipped) input value ids.
Sourcepub fn is_default_domain(&self) -> bool
pub fn is_default_domain(&self) -> bool
Whether this node belongs to the default ONNX operator domain.
Relies on the post-load invariant that the loader canonicalizes the
default domain to "" (see crate::normalize_domain), so this is a
simple emptiness test — the "ai.onnx" spelling never reaches loaded IR.
Sourcepub fn local_opset(&self) -> Option<u64>
pub fn local_opset(&self) -> Option<u64>
This node’s own opset version, if it names one that could be real.
The single owner of that judgement, so every subsystem reading
Node::version agrees about the same node. Values that cannot be an
opset — negative, zero, or beyond what any opset could plausibly reach —
yield None: a node claiming them describes IR that is already wrong,
and the graph’s own import is the better answer.
Callers with a graph in hand should prefer
Graph::effective_opset, which falls
back to that import. Shape inference has only the node and a map of
imports, so it uses this directly.