pub struct Operation { /* private fields */ }
Expand description
An Operation
is a node in a Graph
.
It is a computation which accepts inputs and produces outputs.
Implementations§
Source§impl Operation
impl Operation
Sourcepub fn name(&self) -> Result<String, Utf8Error>
pub fn name(&self) -> Result<String, Utf8Error>
Returns the name of the operation.
This is the name of the specific computational step,
not an operation type, so it may look like 'add_x_and_y'
instead of 'Add'
,
although it may be a generated ID like 'Add_123'
.
Sourcepub fn op_type(&self) -> Result<String, Utf8Error>
pub fn op_type(&self) -> Result<String, Utf8Error>
Returns the type of operation.
This will be something like 'Add'
, 'Mul'
, etc.
Sourcepub fn device(&self) -> Result<String, Utf8Error>
pub fn device(&self) -> Result<String, Utf8Error>
Returns the device for this operation. The empty string means unconstrained.
Sourcepub fn num_outputs(&self) -> usize
pub fn num_outputs(&self) -> usize
Returns the number of outputs.
Sourcepub fn output_type(&self, index: usize) -> DataType
pub fn output_type(&self, index: usize) -> DataType
Returns the type of a specific output.
pub fn output_list_length(&self, arg_name: &str) -> Result<usize>
Sourcepub fn num_inputs(&self) -> usize
pub fn num_inputs(&self) -> usize
Returns the number of inputs.
Sourcepub fn input_type(&self, index: usize) -> DataType
pub fn input_type(&self, index: usize) -> DataType
Returns the type of a specific input.
pub fn input_list_length(&self, arg_name: &str) -> Result<usize>
Sourcepub fn input(&self, index: usize) -> (Operation, usize)
pub fn input(&self, index: usize) -> (Operation, usize)
Returns the given input edge. The index argument is the index into the current operation’s input array, and the return value is the source operation and the index into its output array.
Sourcepub fn output_num_consumers(&self, index: usize) -> usize
pub fn output_num_consumers(&self, index: usize) -> usize
Returns the number of consumers of a specific output.
Sourcepub fn output_consumers(&self, index: usize) -> Vec<(Operation, usize)>
pub fn output_consumers(&self, index: usize) -> Vec<(Operation, usize)>
Returns the consumers of a specific output. The index argument is the index into the current operation’s output array, and the return value is a vector of the destination operation and the index into its input array.
Sourcepub fn num_control_inputs(&self) -> usize
pub fn num_control_inputs(&self) -> usize
Returns the number of control inputs.
Sourcepub fn control_inputs(&self) -> Vec<Operation>
pub fn control_inputs(&self) -> Vec<Operation>
Returns the control inputs.
Sourcepub fn num_control_outputs(&self) -> usize
pub fn num_control_outputs(&self) -> usize
Returns the number of control outputs.
Sourcepub fn control_outputs(&self) -> Vec<Operation>
pub fn control_outputs(&self) -> Vec<Operation>
Returns the control outputs.
Sourcepub fn get_attr_metadata(&self, attr_name: &str) -> Result<AttrMetadata>
pub fn get_attr_metadata(&self, attr_name: &str) -> Result<AttrMetadata>
Returns metadata about the value of the attribute attr_name
.
Sourcepub fn get_attr_string(&self, attr_name: &str) -> Result<String>
pub fn get_attr_string(&self, attr_name: &str) -> Result<String>
Returns the value of the attribute attr_name
.
Sourcepub fn get_attr_string_list(&self, attr_name: &str) -> Result<Vec<String>>
pub fn get_attr_string_list(&self, attr_name: &str) -> Result<Vec<String>>
Get the list of strings in the value of the attribute attr_name
.
Sourcepub fn get_attr_int(&self, attr_name: &str) -> Result<i64>
pub fn get_attr_int(&self, attr_name: &str) -> Result<i64>
Returns the value of the attribute attr_name
.
Sourcepub fn get_attr_int_list(&self, attr_name: &str) -> Result<Vec<i64>>
pub fn get_attr_int_list(&self, attr_name: &str) -> Result<Vec<i64>>
Get the list of ints in the value of the attribute attr_name
.
Sourcepub fn get_attr_float(&self, attr_name: &str) -> Result<f32>
pub fn get_attr_float(&self, attr_name: &str) -> Result<f32>
Returns the value of the attribute attr_name
.
Sourcepub fn get_attr_float_list(&self, attr_name: &str) -> Result<Vec<f32>>
pub fn get_attr_float_list(&self, attr_name: &str) -> Result<Vec<f32>>
Get the list of floats in the value of the attribute attr_name
.
Sourcepub fn get_attr_bool(&self, attr_name: &str) -> Result<bool>
pub fn get_attr_bool(&self, attr_name: &str) -> Result<bool>
Returns the value of the attribute attr_name
.
Sourcepub fn get_attr_bool_list(&self, attr_name: &str) -> Result<Vec<bool>>
pub fn get_attr_bool_list(&self, attr_name: &str) -> Result<Vec<bool>>
Get the list of bools in the value of the attribute attr_name
.
Sourcepub fn get_attr_type(&self, attr_name: &str) -> Result<DataType>
pub fn get_attr_type(&self, attr_name: &str) -> Result<DataType>
Returns the value of the attribute attr_name
.
Sourcepub fn get_attr_type_list(&self, attr_name: &str) -> Result<Vec<DataType>>
pub fn get_attr_type_list(&self, attr_name: &str) -> Result<Vec<DataType>>
Get the list of types in the value of the attribute attr_name
.
Sourcepub fn get_attr_shape(&self, attr_name: &str) -> Result<Shape>
pub fn get_attr_shape(&self, attr_name: &str) -> Result<Shape>
Returns the value of the attribute attr_name
.
Sourcepub fn get_attr_shape_list(&self, attr_name: &str) -> Result<Vec<Shape>>
pub fn get_attr_shape_list(&self, attr_name: &str) -> Result<Vec<Shape>>
Get the list of shapes in the value of the attribute attr_name
.
Sourcepub fn get_attr_tensor_shape_proto(&self, attr_name: &str) -> Result<Vec<u8>>
pub fn get_attr_tensor_shape_proto(&self, attr_name: &str) -> Result<Vec<u8>>
Returns the binary-serialized TensorShapeProto value of the attribute
attr_name
.
Sourcepub fn get_attr_tensor_shape_proto_list(
&self,
attr_name: &str,
) -> Result<Vec<Vec<u8>>>
pub fn get_attr_tensor_shape_proto_list( &self, attr_name: &str, ) -> Result<Vec<Vec<u8>>>
Get the list of binary-serialized TensorShapeProtos in the value of the
attribute attr_name
.
Sourcepub fn get_attr_tensor<T: TensorType>(
&self,
attr_name: &str,
) -> Result<Tensor<T>>
pub fn get_attr_tensor<T: TensorType>( &self, attr_name: &str, ) -> Result<Tensor<T>>
Returns the value of the attribute attr_name
. Returns an error if the
type of the tensor value does not match the type of the generic
argument.
Sourcepub fn get_attr_tensor_list<T: TensorType>(
&self,
attr_name: &str,
) -> Result<Vec<Tensor<T>>>
pub fn get_attr_tensor_list<T: TensorType>( &self, attr_name: &str, ) -> Result<Vec<Tensor<T>>>
Get the list of tensors in the value of the attribute attr_name
.
Returns an error if the type of the tensor value does not match the type
of the generic argument.