pub struct Graph { /* private fields */ }
Expand description
Graph builder.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new<S: Into<String>>(name: S) -> Self
pub fn new<S: Into<String>>(name: S) -> Self
Creates a new builder.
Examples found in repository?
More examples
examples/add.rs (line 5)
4fn main() {
5 let mut graph = builder::Graph::new("add");
6
7 let x = graph
8 .input("X")
9 .typed(DataType::Float)
10 .dim(1)
11 .dim(10)
12 .node();
13 let y = graph
14 .input("Y")
15 .typed(DataType::Float)
16 .dim(1)
17 .dim(10)
18 .node();
19
20 let z = (x + y).with_name("Z");
21
22 let model = graph.outputs(z).model().build();
23
24 save_model("add.onnx", &model).unwrap();
25}
Sourcepub fn doc_string<S: Into<String>>(self, doc_string: S) -> Self
pub fn doc_string<S: Into<String>>(self, doc_string: S) -> Self
Sets graph doc_string.
Sourcepub fn constant<S: Into<String>, T: Into<TensorProto>>(
&mut self,
name: S,
tensor: T,
) -> Node
pub fn constant<S: Into<String>, T: Into<TensorProto>>( &mut self, name: S, tensor: T, ) -> Node
Creates constant node in a graph.
Examples found in repository?
More examples
Sourcepub fn inputs<T: Into<ValueInfoProto>>(self, input: T) -> Self
pub fn inputs<T: Into<ValueInfoProto>>(self, input: T) -> Self
Inserts graph inputs.
Sourcepub fn outputs<T: Into<ValueInfoProto>>(self, output: T) -> Self
pub fn outputs<T: Into<ValueInfoProto>>(self, output: T) -> Self
Inserts graph outputs.
Examples found in repository?
examples/add.rs (line 22)
4fn main() {
5 let mut graph = builder::Graph::new("add");
6
7 let x = graph
8 .input("X")
9 .typed(DataType::Float)
10 .dim(1)
11 .dim(10)
12 .node();
13 let y = graph
14 .input("Y")
15 .typed(DataType::Float)
16 .dim(1)
17 .dim(10)
18 .node();
19
20 let z = (x + y).with_name("Z");
21
22 let model = graph.outputs(z).model().build();
23
24 save_model("add.onnx", &model).unwrap();
25}
Sourcepub fn outputs_typed<T: Into<ValueInfoProto>, D: Into<TypeProto>>(
self,
output: T,
typ: D,
) -> Self
pub fn outputs_typed<T: Into<ValueInfoProto>, D: Into<TypeProto>>( self, output: T, typ: D, ) -> Self
Inserts typed graph outputs.
Examples found in repository?
More examples
Sourcepub fn initializer<T: Into<TensorProto>>(self, initializer: T) -> Self
pub fn initializer<T: Into<TensorProto>>(self, initializer: T) -> Self
Inserts graph initializers.
Sourcepub fn input<T: Into<String>>(&mut self, name: T) -> Value
pub fn input<T: Into<String>>(&mut self, name: T) -> Value
Creates graph input builder.
Examples found in repository?
More examples
examples/add.rs (line 8)
4fn main() {
5 let mut graph = builder::Graph::new("add");
6
7 let x = graph
8 .input("X")
9 .typed(DataType::Float)
10 .dim(1)
11 .dim(10)
12 .node();
13 let y = graph
14 .input("Y")
15 .typed(DataType::Float)
16 .dim(1)
17 .dim(10)
18 .node();
19
20 let z = (x + y).with_name("Z");
21
22 let model = graph.outputs(z).model().build();
23
24 save_model("add.onnx", &model).unwrap();
25}
Sourcepub fn model(self) -> Model
pub fn model(self) -> Model
Builds a model builder from graph.
Examples found in repository?
More examples
examples/add.rs (line 22)
4fn main() {
5 let mut graph = builder::Graph::new("add");
6
7 let x = graph
8 .input("X")
9 .typed(DataType::Float)
10 .dim(1)
11 .dim(10)
12 .node();
13 let y = graph
14 .input("Y")
15 .typed(DataType::Float)
16 .dim(1)
17 .dim(10)
18 .node();
19
20 let z = (x + y).with_name("Z");
21
22 let model = graph.outputs(z).model().build();
23
24 save_model("add.onnx", &model).unwrap();
25}
Sourcepub fn build(self) -> GraphProto
pub fn build(self) -> GraphProto
Builds the graph.
Trait Implementations§
Source§impl Into<GraphProto> for Graph
impl Into<GraphProto> for Graph
Source§fn into(self) -> GraphProto
fn into(self) -> GraphProto
Converts this type into the (usually inferred) input type.
Auto Trait Implementations§
impl Freeze for Graph
impl !RefUnwindSafe for Graph
impl !Send for Graph
impl !Sync for Graph
impl Unpin for Graph
impl !UnwindSafe for Graph
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