[Type Refactor] Merge TType and Tensor instances as a single entity#160
Conversation
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/DataType.java
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/EagerOperation.java
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/types/family/TType.java
Outdated
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/types/family/TType.java
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/types/TBool.java
Show resolved
Hide resolved
Craigacp
left a comment
There was a problem hiding this comment.
While we're in here, is it worth moving the contents of the types.family package into the types package? It seems strange to me to have the interfaces at a lower level than the concrete implementations.
tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DebuggingOps.java
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java
Show resolved
Hide resolved
| * @param tensor a Tensor holding the constant value | ||
| * @return a constant of the same data type as `tensor` | ||
| */ | ||
| public <T extends TType> Constant<T> capture(T tensor) { |
There was a problem hiding this comment.
s/capture/copy/ or immutableCopy ? I don't particularly like the name capture here as it doesn't actually change the state of the tensor argument.
There was a problem hiding this comment.
I don't like capture neither. As discussed here, eventually the tensors could be automatically converted to constants so we will not need to call this endpoint anymore. Still, I now think copy do sound more appropriate as well, I'll make the change.
There was a problem hiding this comment.
Ok as copy already exist as another primitive op, I've decided to rename capture by constantOf, as it is close enough to the original constant name and will be easier to find by our users on auto-completion.
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/DataType.java
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/RawTensor.java
Outdated
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/types/TBfloat16.java
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/types/family/TType.java
Outdated
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/types/family/TType.java
Outdated
Show resolved
Hide resolved
tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/op/core/GradientsTest.java
Outdated
Show resolved
Hide resolved
tensorflow-framework/src/main/java/org/tensorflow/framework/utils/ShapeUtils.java
Show resolved
Hide resolved
I'm not opposed to this but let's keep it for another PR, more changes in this package are planned for the refactoring in progress. |
72d0653 to
598fdc3
Compare
598fdc3 to
8773ccc
Compare
…ensorflow#160) * Merge TType and Tensor instances as a single entity * Rectify documentation based on PR review * Rebase on master
This PR introduces some breaking changes related to
Tensorand their relationship with theNdArraydata structure, in an effort of simplification and standardization.Instances of
TType(e.g.TFloat32,TInt32, etc.) now implements directlyTensor, which has been converted to a non-parameterized interface. This allows direct access to the tensor n-dimensional data space from a tensor instance, without the need to dereference to a second object by callingTensor.data().An instance of
TTypecan now be passed directly to any method accepting aTensorin input, e.g.Session.Runner.feed. In addition, it is now possible to cast directly a tensor of an unknown type using standard Java explicit or implicit type casting, instead of the custom methodexpect.In a nutshell, important and/or breaking changes are:
Tensorfrom a parameterized class to an non-parameterized interfaceTensorfromTTypeimplementationsRawTensorimplementation ofTensorthat takes care, among other things, of wrapping the native handle of the tensor in a protected wayTensor.data(),Tensor.expect()andOperand.data()methodstf.constant(TType)has to be renamed totf.capture(TType)to avoid conflict with otherConstantendpoints (left untouched).tf.capturewill also become obsolete by implementing directlyOperandfrom tensors.CC\ @deansher , @Craigacp , @wmeddie