Struct Node

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

Node wrapper.

Implementations§

Source§

impl Node

Source

pub fn from_proto(inner: NodeProto) -> Self

Creates new node from proto.

Source

pub fn name(&self) -> String

Returns node name.

Source

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

Renames output names accordingly.

Examples found in repository?
examples/stddev.rs (line 9)
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}
More examples
Hide additional examples
examples/add.rs (line 20)
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 9)
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 10)
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 abs(&self) -> Node

Creates new absolute operation.

Examples found in repository?
examples/ensemble.rs (line 18)
16fn stddev(graph: &mut builder::Graph, x: &Node) -> Node {
17    let two = graph.constant("two", 2.0f32);
18    (x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt()
19}
More examples
Hide additional examples
examples/stddev.rs (line 8)
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}
Source

pub fn sqrt(&self) -> Node

Creates new square root operation.

Examples found in repository?
examples/ensemble.rs (line 18)
16fn stddev(graph: &mut builder::Graph, x: &Node) -> Node {
17    let two = graph.constant("two", 2.0f32);
18    (x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt()
19}
More examples
Hide additional examples
examples/stddev.rs (line 8)
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}
Source

pub fn pow<T: Into<String>>(&self, power: T) -> Node

Creates new power operation.

Examples found in repository?
examples/ensemble.rs (line 18)
16fn stddev(graph: &mut builder::Graph, x: &Node) -> Node {
17    let two = graph.constant("two", 2.0f32);
18    (x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt()
19}
More examples
Hide additional examples
examples/stddev.rs (line 8)
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}
Source

pub fn sum<A: Into<Axes>>(&self, axes: A, keepdims: bool) -> Node

Creates new reduce sum operation.

Source

pub fn max<A: Into<Axes>>(&self, axes: A, keepdims: bool) -> Node

Creates new reduce max operation.

Source

pub fn mean<A: Into<Axes>>(&self, axes: A, keepdims: bool) -> Node

Creates new reduce mean operation.

Examples found in repository?
examples/ensemble.rs (line 18)
16fn stddev(graph: &mut builder::Graph, x: &Node) -> Node {
17    let two = graph.constant("two", 2.0f32);
18    (x - x.mean(1, true)).abs().pow(two).mean(1, true).sqrt()
19}
20
21fn mean_reverse(graph: &mut builder::Graph, x: &Node) -> Node {
22    let two = graph.constant("two", 2.0f32);
23    -(x - x.mean(1, true)) * two + x
24}
More examples
Hide additional examples
examples/mean_reverse.rs (line 8)
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}
examples/stddev.rs (line 8)
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/concat.rs (line 8)
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}
Source

pub fn min<A: Into<Axes>>(&self, axes: A, keepdims: bool) -> Node

Creates new reduce min operation.

Source

pub fn equal<Rhs: Into<String>>(&self, right: Rhs) -> Node

Creates new equal comparison operation.

Source

pub fn greater<Rhs: Into<String>>(&self, right: Rhs) -> Node

Creates new greater comparison operation.

Source

pub fn less<Rhs: Into<String>>(&self, right: Rhs) -> Node

Creates new less comparison operation.

Source

pub fn and<Rhs: Into<String>>(&self, right: Rhs) -> Node

Creates new logical and operation.

Source

pub fn or<Rhs: Into<String>>(&self, right: Rhs) -> Node

Creates new logical or operation.

Source

pub fn relu(&self) -> Node

Creates new relu activation operation.

Source

pub fn tanh(&self) -> Node

Creates new tanh activation operation.

Source

pub fn size(&self) -> Node

Creates new size operation.

Trait Implementations§

Source§

impl<Rhs: AsRef<Node>> Add<Rhs> for &Node

Source§

type Output = Node

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Rhs) -> Self::Output

Performs the + operation. Read more
Source§

impl<Rhs: AsRef<Node>> Add<Rhs> for Node

Source§

type Output = Node

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Rhs) -> Self::Output

Performs the + operation. Read more
Source§

impl AsRef<Node> for Abs

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Add

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for And

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Concat

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Constant

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Div

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Equal

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Greater

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Less

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Mul

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Neg

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Node

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Not

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Or

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Pow

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for ReduceMax

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for ReduceMean

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for ReduceMin

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for ReduceSum

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Relu

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Size

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Sqrt

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Sub

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Node> for Tanh

Source§

fn as_ref(&self) -> &Node

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

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<Rhs: AsRef<Node>> Div<Rhs> for &Node

Source§

type Output = Node

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Rhs) -> Self::Output

Performs the / operation. Read more
Source§

impl<Rhs: AsRef<Node>> Div<Rhs> for Node

Source§

type Output = Node

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Rhs) -> Self::Output

Performs the / operation. Read more
Source§

impl From<&Node> for String

Source§

fn from(node: &Node) -> String

Converts to this type from the input type.
Source§

impl From<Node> for String

Source§

fn from(node: Node) -> String

Converts to this type from the input type.
Source§

impl From<NodeProto> for Node

Source§

fn from(inner: NodeProto) -> Self

Converts to this type from the input type.
Source§

impl Into<Node> for Abs

Source§

fn into(self) -> Node

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

impl Into<Node> for Add

Source§

fn into(self) -> Node

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

impl Into<Node> for And

Source§

fn into(self) -> Node

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

impl Into<Node> for Concat

Source§

fn into(self) -> Node

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

impl Into<Node> for Constant

Source§

fn into(self) -> Node

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

impl Into<Node> for Div

Source§

fn into(self) -> Node

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

impl Into<Node> for Equal

Source§

fn into(self) -> Node

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

impl Into<Node> for Greater

Source§

fn into(self) -> Node

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

impl Into<Node> for Less

Source§

fn into(self) -> Node

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

impl Into<Node> for Mul

Source§

fn into(self) -> Node

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

impl Into<Node> for Neg

Source§

fn into(self) -> Node

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

impl Into<Node> for Node

Source§

fn into(self) -> Node

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

impl Into<Node> for Not

Source§

fn into(self) -> Node

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

impl Into<Node> for Or

Source§

fn into(self) -> Node

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

impl Into<Node> for Pow

Source§

fn into(self) -> Node

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

impl Into<Node> for ReduceMax

Source§

fn into(self) -> Node

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

impl Into<Node> for ReduceMean

Source§

fn into(self) -> Node

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

impl Into<Node> for ReduceMin

Source§

fn into(self) -> Node

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

impl Into<Node> for ReduceSum

Source§

fn into(self) -> Node

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

impl Into<Node> for Relu

Source§

fn into(self) -> Node

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

impl Into<Node> for Size

Source§

fn into(self) -> Node

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

impl Into<Node> for Sqrt

Source§

fn into(self) -> Node

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

impl Into<Node> for Sub

Source§

fn into(self) -> Node

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

impl Into<Node> for Tanh

Source§

fn into(self) -> Node

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

impl Into<NodeProto> for Node

Source§

fn into(self) -> NodeProto

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

impl<Rhs: AsRef<Node>> Mul<Rhs> for &Node

Source§

type Output = Node

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl<Rhs: AsRef<Node>> Mul<Rhs> for Node

Source§

type Output = Node

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for &Node

Source§

type Output = Node

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for Node

Source§

type Output = Node

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Not for &Node

Source§

type Output = Node

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Not for Node

Source§

type Output = Node

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<Rhs: AsRef<Node>> Sub<Rhs> for &Node

Source§

type Output = Node

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Rhs) -> Self::Output

Performs the - operation. Read more
Source§

impl<Rhs: AsRef<Node>> Sub<Rhs> for Node

Source§

type Output = Node

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Rhs) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl !RefUnwindSafe for Node

§

impl !Send for Node

§

impl !Sync for Node

§

impl Unpin for Node

§

impl !UnwindSafe for Node

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.