Commit 244b8d6b authored by Andrew Myers's avatar Andrew Myers Committed by Sourabh Bajaj
Browse files

Java API Generics Phase 2 (#11535)

* Phase 1 of the proposed generic Java API.

This adds new classes to represent each of the possible tensor types,
and some scripting support for generating those classes. There is
essentially no effect on existing classes, except that DataType is
made slightly more efficient.

All tests pass.

* Addressed Asim's review.

* Hoisted copyright into a separate declaration. Maybe it should go
in a separate file?

* Added private constructors to TF types and shortened their javadoc to be
more standard.

* Added more explanation about the enum relationship.

* Used more-idiomatic import statement.

* Rename zero column.

* Removed the datatype code from tftypes.csv

* Fix the default value for Double, add one for UInt8.

* Got rid of 'boxed type' column in CSV file

* Somehow I did not notice that TFType.java was not checked in.

* Phase 2 : Tensor, Output and friends are now parameterized.

* All tests now pass.

* Cleaned up and added some Javadoc and made some static fields private.

* Made Outputs more convenient to use.
Improved Javadoc regarding this functionality.
Added explicit type parameters to examples and tests to make them better models of expected practice.

* Removed extra copy of method.

* This change to the Android demo app should allow it to compile successfully

* Backed out unnecessary but presumably harmless removal of calls to clear().

* Change from Unicode times symbol to x, to be more consistent with
the rest of the Javadoc.

* Updated Constant and ConstantTest with generics.

* Registered UInt8 like all the other data types.

* Removed the UINT8 test because UINT8 doesn't seem to be fully supported in next
layer down. That probably should be fixed but it's orthongonal to this change.

* * Added some missing pieces so that uint8 seems now to be supported fully by the Java API,
addressing #12797.
* Resurrected the uint8 test case.
* Allowed arrays of bytes to be used to construct both tensors of strings and tensors of uint8.
* Simplified the computation of the number of dimensions of a Java object representing a tensor.

* Get rid of tab characters that violate the Google Java style guide. My IDE
was not configured correctly.

* Fix javadoc nit.

* Replace testUInt8 with the generic version.

* Ran formatter on code.

* Addressed some of Asim's comments.

- implemented constant() methods in terms of each other to reduce code duplication
- improved a spec regarding when types are checked
- got rid of an unnecessary method that used wildcards

* Back out change to comments in Operand.java

* This is what things look like if we make Tensor run on DataType as much as
possible. Only Tensor.expect() is still using class objects as a way to
represent tensor datatypes. It can be moved off to class Tensors when Tensors
exists, though it will not be as convenient as when it's a method of Tensor.

* Fixed build errors. This is is being committed primarily so Asim can take a look at it conveniently.
More work will be needed before merging.

* - Changed from TF-prefixed types to regular Java classes, e.g. Integer instead of
TFInt32. Deleted most classes in org.tensorflow.types, including TFType.
- Made Tensor mostly work in terms of Class<T> since that is the user-facing
  interface.
- Moved zeroValue() stuff off to the testfile where it belongs

* Remove unnecessary run-time check.

* Updated Android inference test to latest Java API changes.

* Address Asim's comments (thanks!)

- Removed now-gratuitous run-time type-check.
- Fixed non-Google-styled if.
- Reworded/fixed a few comments as requested.
- Removed all uses of unsafe casts and @SuppressWarnings in test cases.
- Cleaned up constant() implementations in LabelImage example.
- Removed reference to Tensors class (next PR!)

* Ran gformat on everything.

* Fixed an old typo in a comment.
Removed a couple of unnecessary casts from the example program.

* Fixed the last suppressed warnings.
parent 0b131503
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment