Class GraphOperation

java.lang.Object
org.tensorflow.GraphOperation
All Implemented Interfaces:
Operation

public final class GraphOperation extends Object
Implementation for an Operation added as a node to a Graph.

GraphOperation instances are valid only as long as the Graph they are a part of is valid. Thus, if Graph.close() has been invoked, then methods on the GraphOperation instance may fail with an IllegalStateException.

GraphOperation instances are immutable and thread-safe.

  • Method Details

    • name

      public String name()
      Description copied from interface: Operation
      Returns the full name of the Operation.
    • type

      public String type()
      Description copied from interface: Operation
      Returns the type of the operation, i.e., the name of the computation performed by the operation.
    • env

      public Graph env()
      Description copied from interface: Operation
      Returns the execution environment this operation was created in.
    • numOutputs

      public int numOutputs()
      Description copied from interface: Operation
      Returns the number of tensors produced by this operation.
    • outputListLength

      public int outputListLength(String name)
      Description copied from interface: Operation
      Returns the size of the list of Tensors produced by this operation.

      An Operation has multiple named outputs, each of which produces either a single tensor or a list of tensors. This method returns the size of the list of tensors for a specific named output of the operation.

      Parameters:
      name - identifier of the list of tensors (of which there may be many) produced by this operation.
      Returns:
      the size of the list of Tensors produced by this named output.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • inputListLength

      public int inputListLength(String name)
      Description copied from interface: Operation
      Returns the size of the given inputs list of Tensors for this operation.

      An Operation has multiple named inputs, each of which contains either a single tensor or a list of tensors. This method returns the size of the list of tensors for a specific named input of the operation.

      Parameters:
      name - identifier of the list of tensors (of which there may be many) inputs to this operation.
      Returns:
      the size of the list of Tensors produced by this named input.
    • device

      public String device()
      Get the op's device.
    • numInputs

      public int numInputs()
      Get the number of inputs to the op, not including control inputs.
    • input

      public Output<?> input(int idx)
      Gets the input at the given index
    • attributes

      public OperationAttributeInspector attributes()
      Get an inspector for the graph operation's attributes.
    • inputList

      public Output<?>[] inputList(int idx, int length)
      Get the input list that starts at idx and has length length
      Parameters:
      idx - the starting index of the list
      length - the length of the list
      Returns:
      the input list
      See Also:
    • inputs

      public List<Operand<?>> inputs()
      Get the op's inputs, not including control inputs.
    • numConsumers

      public int numConsumers(int index)
      Get the number of ops that use this op's designated output as an input, not including control dependencies.
      Parameters:
      index - the output to look for usages of
    • consumers

      public Set<GraphOperation> consumers(int index)
      Get the ops that use this op's designated output as an input, not including control dependencies.
      Parameters:
      index - the output to look for usages of
    • numConsumers

      public int numConsumers()
      Get the number of ops that use any of this op's outputs as an input, not including control dependencies.
    • consumers

      public Set<GraphOperation> consumers()
      Get the ops that use any of this op's outputs as an input, not including control dependencies.
    • numControlInputs

      public int numControlInputs()
      Get the number of control inputs for this op.
    • controlInputs

      public Set<GraphOperation> controlInputs()
      Get the control inputs of this op.
    • numControlConsumers

      public int numControlConsumers()
      Get the number of ops with this op as a control dependency.
    • controlConsumers

      public Set<GraphOperation> controlConsumers()
      Get the ops with this op as a control dependency.
    • getUnsafeNativeHandle

      public TF_Operation getUnsafeNativeHandle()
      Get the native handle of this operation.

      No liveness or non-null checking is done, the operation may have been deallocated.

    • outputList

      public Output<?>[] outputList(int idx, int length)
      Description copied from interface: Operation
      Returns symbolic handles to a list of tensors produced by this operation.
      Specified by:
      outputList in interface Operation
      Parameters:
      idx - index of the first tensor of the list
      length - number of tensors in the list
      Returns:
      array of Output
    • output

      public <T extends TType> Output<T> output(int idx)
      Description copied from interface: Operation
      Returns a symbolic handle to one of the tensors produced by this operation.

      Warning: Does not check that the type of the tensor matches T. It is recommended to call this method with an explicit type parameter rather than letting it be inferred, e.g. operation.<Integer>output(0)

      Specified by:
      output in interface Operation
      Type Parameters:
      T - The expected element type of the tensors produced by this output.
      Parameters:
      idx - The index of the output among the outputs produced by this operation.
    • toString

      public String toString()
      Overrides:
      toString in class Object