diff options
Diffstat (limited to 'tensorflow/java/src/main/java/org/tensorflow/Output.java')
-rw-r--r-- | tensorflow/java/src/main/java/org/tensorflow/Output.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tensorflow/java/src/main/java/org/tensorflow/Output.java b/tensorflow/java/src/main/java/org/tensorflow/Output.java index ab128c2b30..ad28eb2743 100644 --- a/tensorflow/java/src/main/java/org/tensorflow/Output.java +++ b/tensorflow/java/src/main/java/org/tensorflow/Output.java @@ -15,13 +15,17 @@ limitations under the License. package org.tensorflow; +import java.util.Objects; /** * A symbolic handle to a tensor produced by an {@link Operation}. * * <p>An Output is a symbolic handle to a tensor. The value of the Tensor is computed by executing * the {@link Operation} in a {@link Session}. + * + * <p>By implementing the {@link Input} interface, instances of this class could also be passed + * directly in input to an operation. */ -public final class Output { +public final class Output implements Input { /** Handle to the idx-th output of the Operation {@code op}. */ public Output(Operation op, int idx) { @@ -49,6 +53,35 @@ public final class Output { return operation.dtype(index); } + @Override + public Output asOutput() { + return this; + } + + @Override + public int hashCode() { + return Objects.hash(operation, index); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof Output) { + Output that = (Output) o; + return index == that.index && operation.equals(that.operation); + } + return false; + } + + @Override + public String toString() { + return String.format( + "<%s '%s:%d' shape=%s dtype=%s>", + operation.type(), operation.name(), index, shape().toString(), dataType()); + } + private final Operation operation; private final int index; } |