Struct Value

Source
pub struct Value { /* private fields */ }
Expand description

Value info builder.

Implementations§

Source§

impl Value

Source

pub fn new<S: Into<String>>(name: S) -> Self

Creates a new builder.

Source

pub fn name<S: Into<String>>(self, name: S) -> Self

Sets value name.

Source

pub fn typed<T: Into<DataType>>(self, elem_type: T) -> Self

Sets value element type.

Examples found in repository?
examples/mean_reverse.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("reverse");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let out = -(&x - x.mean(1, true)) * two + x;
9    let graph = graph.outputs_typed(out, DataType::Float);
10    let model = graph.model().build();
11    save_model("mean-reverse.onnx", &model).unwrap();
12}
More examples
Hide additional examples
examples/stddev.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("stddev");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let std = (&x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt();
9    let graph = graph.outputs_typed(std.with_name("stddev"), DataType::Float);
10    let model = graph.model().build();
11    save_model("stddev.onnx", &model).unwrap();
12}
examples/add.rs (line 9)
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}
examples/concat.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("concat");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let mean_reverse = -(&x - x.mean(1, true)) * two + &x;
9    let concat = graph.concat(0, vec![x, mean_reverse]).with_name("concat");
10    let graph = graph.outputs_typed(concat, DataType::Float);
11    let model = graph.model().build();
12    save_model("concat.onnx", &model).unwrap();
13}
examples/ensemble.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("stddev");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let std = stddev(&mut graph, &x);
8    let mrev = mean_reverse(&mut graph, &x);
9    let graph = graph
10        .outputs_typed(std.with_name("stddev"), DataType::Float)
11        .outputs_typed(mrev.with_name("mean_reverse"), DataType::Float);
12    let model = graph.model().build();
13    save_model("ensemble.onnx", &model).unwrap();
14}
Source

pub fn shape<D: Into<Dimension>>(self, shape: Vec<D>) -> Self

Sets value shape.

Source

pub fn dim<D: Into<Dimension>>(self, dim: D) -> Self

Inserts value dimension.

Examples found in repository?
examples/mean_reverse.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("reverse");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let out = -(&x - x.mean(1, true)) * two + x;
9    let graph = graph.outputs_typed(out, DataType::Float);
10    let model = graph.model().build();
11    save_model("mean-reverse.onnx", &model).unwrap();
12}
More examples
Hide additional examples
examples/stddev.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("stddev");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let std = (&x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt();
9    let graph = graph.outputs_typed(std.with_name("stddev"), DataType::Float);
10    let model = graph.model().build();
11    save_model("stddev.onnx", &model).unwrap();
12}
examples/add.rs (line 10)
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}
examples/concat.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("concat");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let mean_reverse = -(&x - x.mean(1, true)) * two + &x;
9    let concat = graph.concat(0, vec![x, mean_reverse]).with_name("concat");
10    let graph = graph.outputs_typed(concat, DataType::Float);
11    let model = graph.model().build();
12    save_model("concat.onnx", &model).unwrap();
13}
examples/ensemble.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("stddev");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let std = stddev(&mut graph, &x);
8    let mrev = mean_reverse(&mut graph, &x);
9    let graph = graph
10        .outputs_typed(std.with_name("stddev"), DataType::Float)
11        .outputs_typed(mrev.with_name("mean_reverse"), DataType::Float);
12    let model = graph.model().build();
13    save_model("ensemble.onnx", &model).unwrap();
14}
Source

pub fn node(self) -> Node

Creates node for input. Requires builder to be bagged.

Examples found in repository?
examples/mean_reverse.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("reverse");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let out = -(&x - x.mean(1, true)) * two + x;
9    let graph = graph.outputs_typed(out, DataType::Float);
10    let model = graph.model().build();
11    save_model("mean-reverse.onnx", &model).unwrap();
12}
More examples
Hide additional examples
examples/stddev.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("stddev");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let std = (&x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt();
9    let graph = graph.outputs_typed(std.with_name("stddev"), DataType::Float);
10    let model = graph.model().build();
11    save_model("stddev.onnx", &model).unwrap();
12}
examples/add.rs (line 12)
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}
examples/concat.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("concat");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let two = graph.constant("two", 2.0f32);
8    let mean_reverse = -(&x - x.mean(1, true)) * two + &x;
9    let concat = graph.concat(0, vec![x, mean_reverse]).with_name("concat");
10    let graph = graph.outputs_typed(concat, DataType::Float);
11    let model = graph.model().build();
12    save_model("concat.onnx", &model).unwrap();
13}
examples/ensemble.rs (line 6)
4fn main() {
5    let mut graph = builder::Graph::new("stddev");
6    let x = graph.input("X").typed(DataType::Float).dim(1).dim(6).node();
7    let std = stddev(&mut graph, &x);
8    let mrev = mean_reverse(&mut graph, &x);
9    let graph = graph
10        .outputs_typed(std.with_name("stddev"), DataType::Float)
11        .outputs_typed(mrev.with_name("mean_reverse"), DataType::Float);
12    let model = graph.model().build();
13    save_model("ensemble.onnx", &model).unwrap();
14}
Source

pub fn build(self) -> ValueInfoProto

Builds the value info.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Value

Source§

fn default() -> Value

Returns the “default value” for a type. Read more
Source§

impl Into<ValueInfoProto> for Value

Source§

fn into(self) -> ValueInfoProto

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.