NodeDef

Struct NodeDef 

Source
pub struct NodeDef {
    pub name: String,
    pub op: String,
    pub input: Vec<String>,
    pub device: String,
    pub attr: HashMap<String, AttrValue>,
}

Fields§

§name: String

The name given to this operator. Used for naming inputs, logging, visualization, etc. Unique within a single GraphDef. Must match the regexp “[A-Za-z0-9.][A-Za-z0-9_./]*”.

§op: String

The operation name. There may be custom parameters in attrs. Op names starting with an underscore are reserved for internal use.

§input: Vec<String>

Each input is “node:src_output” with “node” being a string name and “src_output” indicating which output tensor to use from “node”. If “src_output” is 0 the “:0” suffix can be omitted. Regular inputs may optionally be followed by control inputs that have the format “^node”.

§device: String

A (possibly partial) specification for the device on which this node should be placed. The expected syntax for this string is as follows:

DEVICE_SPEC ::= PARTIAL_SPEC

PARTIAL_SPEC ::= (“/” CONSTRAINT) * CONSTRAINT ::= (“job:” JOB_NAME) | (“replica:” [1-9][0-9]) | (“task:” [1-9][0-9]) | (“device:” [A-Za-z]* “:” ([1-9][0-9]* | “*”) )

Valid values for this string include:

  • “/job:worker/replica:0/task:1/device:GPU:3” (full specification)
  • “/job:worker/device:GPU:3” (partial specification)
  • “” (no specification)

If the constraints do not resolve to a single device (or if this field is empty or not present), the runtime will attempt to choose a device automatically.

§attr: HashMap<String, AttrValue>

Operation-specific graph-construction-time configuration. Note that this should include all attrs defined in the corresponding OpDef, including those with a value matching the default – this allows the default to change and makes NodeDefs easier to interpret on their own. However, if an attr with a default is not specified in this list, the default will be used. The “names” (keys) must match the regexp “[a-z][a-z0-9_]+” (and one of the names from the corresponding OpDef’s attr field). The values must have a type matching the corresponding OpDef attr’s type field. TODO(josh11b): Add some examples here showing best practices.

Implementations§

Source§

impl NodeDef

Source

pub fn name<S: ToString>(self, n: S) -> NodeDef

Source

pub fn op<S: ToString>(self, n: S) -> NodeDef

Source

pub fn input<S: ToString>(self, n: S) -> NodeDef

Source

pub fn attr<S: ToString, V: Into<AttrValue>>(self, n: S, v: V) -> NodeDef

Source§

impl NodeDef

Source

pub fn get_attr_raw_str(&self, name: &str) -> TractResult<&[u8]>

Source

pub fn get_attr_opt_raw_str(&self, name: &str) -> TractResult<Option<&[u8]>>

Source

pub fn get_attr_str(&self, name: &str) -> TractResult<String>

Source

pub fn get_attr_opt_str(&self, name: &str) -> TractResult<Option<String>>

Source

pub fn get_attr_bool(&self, name: &str) -> TractResult<bool>

Source

pub fn get_attr_opt_bool(&self, name: &str) -> TractResult<Option<bool>>

Source

pub fn get_attr_datum_type(&self, name: &str) -> TractResult<DatumType>

Source

pub fn get_attr_opt_datum_type( &self, name: &str, ) -> TractResult<Option<DatumType>>

Source

pub fn get_attr_shape(&self, name: &str) -> TractResult<TVec<isize>>

Source

pub fn get_attr_opt_shape(&self, name: &str) -> TractResult<Option<TVec<isize>>>

Source

pub fn get_attr_tensor(&self, name: &str) -> TractResult<Tensor>

Source

pub fn get_attr_opt_tensor(&self, name: &str) -> TractResult<Option<Tensor>>

Source

pub fn get_attr_int<T: FromPrimitive>(&self, name: &str) -> TractResult<T>

Source

pub fn get_attr_opt_int<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Option<T>>

Source

pub fn get_attr_float<T: FromPrimitive>(&self, name: &str) -> TractResult<T>

Source

pub fn get_attr_opt_float<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Option<T>>

Source

pub fn get_attr_list_int<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Vec<T>>

Source

pub fn get_attr_opt_list_int<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Option<Vec<T>>>

Trait Implementations§

Source§

impl Clone for NodeDef

Source§

fn clone(&self) -> NodeDef

Returns a duplicate 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 Debug for NodeDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NodeDef

Source§

fn default() -> Self

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

impl Message for NodeDef

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for NodeDef

Source§

fn eq(&self, other: &NodeDef) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for NodeDef

Auto Trait Implementations§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T> CloneAny for T
where T: Any + Clone,