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?
examples/remove_node_bench.rs (lines 13-18)
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more