pub struct OpDef {
    pub name: String,
    pub input_arg: Vec<ArgDef>,
    pub output_arg: Vec<ArgDef>,
    pub attr: Vec<AttrDef>,
    pub deprecation: Option<OpDeprecation>,
    pub summary: String,
    pub description: String,
    pub is_commutative: bool,
    pub is_aggregate: bool,
    pub is_stateful: bool,
    pub allows_uninitialized_input: bool,
}
Expand description

Defines an operation. A NodeDef in a GraphDef specifies an Op by using the “op” field which should match the name of a OpDef. LINT.IfChange

Fields§

§name: String

Op names starting with an underscore are reserved for internal use. Names should be CamelCase and match the regexp “[A-Z][a-zA-Z0-9_]*”.

§input_arg: Vec<ArgDef>

Description of the input(s).

§output_arg: Vec<ArgDef>

Description of the output(s).

§attr: Vec<AttrDef>§deprecation: Option<OpDeprecation>

Optional deprecation based on GraphDef versions.

§summary: String

One-line human-readable description of what the Op does.

§description: String

Additional, longer human-readable description of what the Op does.

§is_commutative: bool

True if the operation is commutative (“op(a,b) == op(b,a)” for all inputs)

§is_aggregate: bool

If is_aggregate is true, then this operation accepts N >= 2 inputs and produces 1 output all of the same type. Should be associative and commutative, and produce output with the same shape as the input. The optimizer may replace an aggregate op taking input from multiple devices with a tree of aggregate ops that aggregate locally within each device (and possibly within groups of nearby devices) before communicating. TODO(josh11b): Implement that optimization.

for things like add

§is_stateful: bool

Ops are marked as stateful if their behavior depends on some state beyond their input tensors (e.g. variable reading op) or if they have a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops must always produce the same output for the same input and have no side-effects.

By default Ops may be moved between devices. Stateful ops should either not be moved, or should only be moved if that state can also be moved (e.g. via some sort of save / restore). Stateful ops are guaranteed to never be optimized away by Common Subexpression Elimination (CSE).

for things like variables, queue

§allows_uninitialized_input: bool

By default, all inputs to an Op must be initialized Tensors. Ops that may initialize tensors for the first time should set this field to true, to allow the Op to take an uninitialized Tensor as input.

for Assign, etc.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Returns the encoded length of the message without a length delimiter.
Clears the message, resetting all fields to their default.
Encodes the message to a buffer. Read more
Encodes the message to a newly allocated buffer.
Encodes the message with a length-delimiter to a buffer. Read more
Encodes the message with a length-delimiter to a newly allocated buffer.
Decodes an instance of the message from a buffer. Read more
Decodes a length-delimited instance of the message from the buffer.
Decodes an instance of the message from a buffer, and merges it into self. Read more
Decodes a length-delimited instance of the message from buffer, and merges it into self. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
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. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.