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
impl NodeDef
pub fn get_attr_raw_str(&self, name: &str) -> TractResult<&[u8]>
pub fn get_attr_opt_raw_str(&self, name: &str) -> TractResult<Option<&[u8]>>
pub fn get_attr_str(&self, name: &str) -> TractResult<String>
pub fn get_attr_opt_str(&self, name: &str) -> TractResult<Option<String>>
pub fn get_attr_bool(&self, name: &str) -> TractResult<bool>
pub fn get_attr_opt_bool(&self, name: &str) -> TractResult<Option<bool>>
pub fn get_attr_datum_type(&self, name: &str) -> TractResult<DatumType>
pub fn get_attr_opt_datum_type( &self, name: &str, ) -> TractResult<Option<DatumType>>
pub fn get_attr_shape(&self, name: &str) -> TractResult<TVec<isize>>
pub fn get_attr_opt_shape(&self, name: &str) -> TractResult<Option<TVec<isize>>>
pub fn get_attr_tensor(&self, name: &str) -> TractResult<Tensor>
pub fn get_attr_opt_tensor(&self, name: &str) -> TractResult<Option<Tensor>>
pub fn get_attr_int<T: FromPrimitive>(&self, name: &str) -> TractResult<T>
pub fn get_attr_opt_int<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Option<T>>
pub fn get_attr_float<T: FromPrimitive>(&self, name: &str) -> TractResult<T>
pub fn get_attr_opt_float<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Option<T>>
pub fn get_attr_list_int<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Vec<T>>
pub fn get_attr_opt_list_int<T: FromPrimitive>( &self, name: &str, ) -> TractResult<Option<Vec<T>>>
Trait Implementations§
Source§impl Message for NodeDef
impl Message for NodeDef
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
.impl StructuralPartialEq for NodeDef
Auto Trait Implementations§
impl Freeze for NodeDef
impl RefUnwindSafe for NodeDef
impl Send for NodeDef
impl Sync for NodeDef
impl Unpin for NodeDef
impl UnwindSafe for NodeDef
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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