pub struct Node {
pub id: NodeId,
pub name: String,
pub op_type: String,
pub domain: String,
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).
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.
Examples found in repository?
6fn hub_graph(node_count: usize) -> (Graph, Vec<NodeId>) {
7 let mut graph = Graph::new();
8 let hub = graph.create_value(DataType::Float32, static_shape([1]));
9 graph.add_input(hub);
10 let mut nodes = Vec::with_capacity(node_count);
11 for _ in 0..node_count {
12 let output = graph.create_value(DataType::Float32, static_shape([1]));
13 nodes.push(graph.insert_node(Node::new(
14 NodeId(0),
15 "Identity",
16 vec![Some(hub)],
17 vec![output],
18 )));
19 }
20 (graph, nodes)
21}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.