Skip to content

Commit 02e7ebf

Browse files
authored
Merge pull request #8 from tensorflow/master
merge
2 parents 04f419a + 496191d commit 02e7ebf

File tree

318 files changed

+936
-1008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+936
-1008
lines changed

ndarray/pom.xml

+15
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
Utility library for N-dimensional data I/O operations.
3333
</description>
3434

35+
<properties>
36+
<java.module.name>org.tensorflow.ndarray</java.module.name>
37+
</properties>
38+
3539
<dependencies>
3640
<dependency>
3741
<groupId>org.junit.jupiter</groupId>
@@ -57,6 +61,17 @@
5761

5862
<build>
5963
<plugins>
64+
<plugin>
65+
<artifactId>maven-jar-plugin</artifactId>
66+
<version>3.2.0</version>
67+
<configuration>
68+
<archive>
69+
<manifestEntries>
70+
<Automatic-Module-Name>${java.module.name}</Automatic-Module-Name>
71+
</manifestEntries>
72+
</archive>
73+
</configuration>
74+
</plugin>
6075
<plugin>
6176
<groupId>org.apache.maven.plugins</groupId>
6277
<artifactId>maven-surefire-plugin</artifactId>

pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@
165165
</repository>
166166
</repositories>
167167
</profile>
168+
169+
<profile>
170+
<id>jdk11</id>
171+
<properties>
172+
<maven.compiler.source>11</maven.compiler.source>
173+
<maven.compiler.target>11</maven.compiler.target>
174+
<maven.compiler.release>11</maven.compiler.release>
175+
</properties>
176+
</profile>
168177
</profiles>
169178

170179
<!-- http://central.sonatype.org/pages/requirements.html#developer-information -->

tensorflow-core/tensorflow-core-api/pom.xml

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<javacpp.build.skip>${native.build.skip}</javacpp.build.skip>
2222
<javacpp.parser.skip>${native.build.skip}</javacpp.parser.skip>
2323
<javacpp.compiler.skip>${native.build.skip}</javacpp.compiler.skip>
24+
<java.module.name>org.tensorflow.core.api</java.module.name>
2425
</properties>
2526

2627
<dependencies>
@@ -330,6 +331,13 @@
330331
<plugin>
331332
<artifactId>maven-jar-plugin</artifactId>
332333
<version>3.1.0</version>
334+
<configuration>
335+
<archive>
336+
<manifestEntries>
337+
<Automatic-Module-Name>${java.module.name}</Automatic-Module-Name>
338+
</manifestEntries>
339+
</archive>
340+
</configuration>
333341
<executions>
334342
<execution>
335343
<!--

tensorflow-core/tensorflow-core-api/src/bazel/op_generator/op_gen_main.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const char kUsageHeader[] =
3434
"provided list of libraries. A wrapper exposes an intuitive and\n"
3535
"strongly-typed interface for building its underlying operation and linking "
3636
"it into a graph.\n\n"
37+
"The first argument is the location of the tensorflow binary built for TF-"
38+
"Java.\nFor example, `bazel-out/k8-opt/bin/external/org_tensorflow/tensorfl"
39+
"ow/libtensorflow_cc.so`.\n\n"
3740
"Operation wrappers are generated under the path specified by the "
3841
"'--output_dir' argument. This path can be absolute or relative to the\n"
3942
"current working directory and will be created if it does not exist.\n\n"
@@ -45,7 +48,9 @@ const char kUsageHeader[] =
4548
"Finally, the `--api_dirs` argument takes a list of comma-separated "
4649
"directories of API definitions can be provided to override default\n"
4750
"values found in the ops definitions. Directories are ordered by priority "
48-
"(the last having precedence over the first).\n\n";
51+
"(the last having precedence over the first).\nFor example, `bazel-tensorf"
52+
"low-core-api/external/org_tensorflow/tensorflow/core/api_def/base_api,src"
53+
"/bazel/api_def`\n\n";
4954

5055
} // namespace java
5156
} // namespace tensorflow

tensorflow-core/tensorflow-core-api/src/bazel/op_generator/op_specs.cc

+55
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,63 @@ OpSpec OpSpec::Create(const OpDef& op_def, const ApiDef& api_def) {
391391
for (const auto& endpoint_def : api_def.endpoint()) {
392392
op.endpoints_.push_back(CreateEndpoint(op_def, api_def, endpoint_def));
393393
}
394+
op.RemoveExtraGenerics();
394395
return op;
395396
}
396397

398+
void OpSpec::RemoveExtraGenerics() {
399+
std::map<string, int> generics;
400+
401+
for (const ArgumentSpec& output : this->outputs()) {
402+
if (output.type().kind() == Type::GENERIC && !output.type().wildcard()) {
403+
if (generics.find(output.type().name()) == generics.end()) {
404+
generics[output.type().name()] = 1;
405+
} else {
406+
generics[output.type().name()] = generics.find(output.type().name())->second + 1;
407+
}
408+
}
409+
}
410+
411+
for (const ArgumentSpec& input : this->inputs()) {
412+
if (input.type().kind() == Type::GENERIC && !input.type().wildcard()) {
413+
if (generics.find(input.type().name()) == generics.end()) {
414+
generics[input.type().name()] = 1;
415+
} else {
416+
generics[input.type().name()] = generics.find(input.type().name())->second + 1;
417+
}
418+
}
419+
}
420+
421+
for (ArgumentSpec& output : this->outputs_) {
422+
if (output.type().kind() == Type::GENERIC && !output.type().wildcard()) {
423+
if (generics[output.type().name()] <= 1) {
424+
output.toUpperBound();
425+
}
426+
}
427+
}
428+
429+
for (ArgumentSpec& input : this->inputs_) {
430+
if (generics[input.type().name()] <= 1) {
431+
input.toUpperBound();
432+
}
433+
}
434+
}
435+
436+
void ArgumentSpec::toUpperBound() {
437+
if(this->type().kind() == Type::GENERIC && this->var().type().name() == "Operand" &&
438+
this->type().supertypes().size() == 1){
439+
Type newType = Type::Wildcard().add_supertype(this->type().supertypes().front());
440+
Type varType = Type::Interface("Operand", "org.tensorflow").add_parameter(newType);
441+
442+
if(this->var().variadic()){
443+
this->var_ = Variable::Varargs(this->var().name(), varType);
444+
} else {
445+
this->var_ = Variable::Create(this->var().name(), varType);
446+
}
447+
448+
this->type_ = newType;
449+
}
450+
}
451+
397452
} // namespace java
398453
} // namespace tensorflow

tensorflow-core/tensorflow-core-api/src/bazel/op_generator/op_specs.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ class ArgumentSpec {
7474
const string& op_def_name() const { return op_def_name_; }
7575
const Variable& var() const { return var_; }
7676
const Type& type() const { return type_; }
77+
void toUpperBound();
7778
const string& description() const { return description_; }
7879
bool iterable() const { return iterable_; }
7980

8081
private:
8182
const string op_def_name_;
82-
const Variable var_;
83-
const Type type_;
83+
Variable var_;
84+
Type type_;
8485
const string description_;
8586
const bool iterable_;
8687
};
@@ -164,6 +165,8 @@ class OpSpec {
164165
hidden_(hidden),
165166
deprecation_explanation_(deprecation_explanation) {}
166167

168+
void RemoveExtraGenerics();
169+
167170
const string graph_op_name_;
168171
const bool hidden_;
169172
const string deprecation_explanation_;

tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/DtypesOps.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public final class DtypesOps {
5959
* @param options carries optional attributes values
6060
* @return a new instance of AsString
6161
*/
62-
public <T extends TType> AsString asString(Operand<T> input, AsString.Options... options) {
62+
public AsString asString(Operand<? extends TType> input, AsString.Options... options) {
6363
return AsString.create(scope, input, options);
6464
}
6565

@@ -72,7 +72,7 @@ public <T extends TType> AsString asString(Operand<T> input, AsString.Options...
7272
* @param options carries optional attributes values
7373
* @return a new instance of Cast
7474
*/
75-
public <U extends TType, T extends TType> Cast<U> cast(Operand<T> x, Class<U> DstT,
75+
public <U extends TType> Cast<U> cast(Operand<? extends TType> x, Class<U> DstT,
7676
Cast.Options... options) {
7777
return Cast.create(scope, x, DstT, options);
7878
}

tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/ImageOps.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public CombinedNonMaxSuppression combinedNonMaxSuppression(Operand<TFloat32> box
213213
* @param options carries optional attributes values
214214
* @return a new instance of CropAndResize
215215
*/
216-
public <T extends TNumber> CropAndResize cropAndResize(Operand<T> image, Operand<TFloat32> boxes,
216+
public CropAndResize cropAndResize(Operand<? extends TNumber> image, Operand<TFloat32> boxes,
217217
Operand<TInt32> boxInd, Operand<TInt32> cropSize, CropAndResize.Options... options) {
218218
return CropAndResize.create(scope, image, boxes, boxInd, cropSize, options);
219219
}
@@ -239,8 +239,8 @@ public <T extends TNumber> CropAndResize cropAndResize(Operand<T> image, Operand
239239
* @param options carries optional attributes values
240240
* @return a new instance of CropAndResizeGradBoxes
241241
*/
242-
public <T extends TNumber> CropAndResizeGradBoxes cropAndResizeGradBoxes(Operand<TFloat32> grads,
243-
Operand<T> image, Operand<TFloat32> boxes, Operand<TInt32> boxInd,
242+
public CropAndResizeGradBoxes cropAndResizeGradBoxes(Operand<TFloat32> grads,
243+
Operand<? extends TNumber> image, Operand<TFloat32> boxes, Operand<TInt32> boxInd,
244244
CropAndResizeGradBoxes.Options... options) {
245245
return CropAndResizeGradBoxes.create(scope, grads, image, boxes, boxInd, options);
246246
}
@@ -573,7 +573,7 @@ public EncodeJpegVariableQuality encodeJpegVariableQuality(Operand<TUint8> image
573573
* @param options carries optional attributes values
574574
* @return a new instance of EncodePng
575575
*/
576-
public <T extends TNumber> EncodePng encodePng(Operand<T> image, EncodePng.Options... options) {
576+
public EncodePng encodePng(Operand<? extends TNumber> image, EncodePng.Options... options) {
577577
return EncodePng.create(scope, image, options);
578578
}
579579

@@ -791,7 +791,7 @@ public <T extends TNumber> RandomCrop<T> randomCrop(Operand<T> image, Operand<TI
791791
* @param options carries optional attributes values
792792
* @return a new instance of ResizeArea
793793
*/
794-
public <T extends TNumber> ResizeArea resizeArea(Operand<T> images, Operand<TInt32> size,
794+
public ResizeArea resizeArea(Operand<? extends TNumber> images, Operand<TInt32> size,
795795
ResizeArea.Options... options) {
796796
return ResizeArea.create(scope, images, size, options);
797797
}
@@ -807,7 +807,7 @@ public <T extends TNumber> ResizeArea resizeArea(Operand<T> images, Operand<TInt
807807
* @param options carries optional attributes values
808808
* @return a new instance of ResizeBicubic
809809
*/
810-
public <T extends TNumber> ResizeBicubic resizeBicubic(Operand<T> images, Operand<TInt32> size,
810+
public ResizeBicubic resizeBicubic(Operand<? extends TNumber> images, Operand<TInt32> size,
811811
ResizeBicubic.Options... options) {
812812
return ResizeBicubic.create(scope, images, size, options);
813813
}
@@ -823,7 +823,7 @@ public <T extends TNumber> ResizeBicubic resizeBicubic(Operand<T> images, Operan
823823
* @param options carries optional attributes values
824824
* @return a new instance of ResizeBilinear
825825
*/
826-
public <T extends TNumber> ResizeBilinear resizeBilinear(Operand<T> images, Operand<TInt32> size,
826+
public ResizeBilinear resizeBilinear(Operand<? extends TNumber> images, Operand<TInt32> size,
827827
ResizeBilinear.Options... options) {
828828
return ResizeBilinear.create(scope, images, size, options);
829829
}
@@ -939,7 +939,7 @@ public <T extends TNumber> SampleDistortedBoundingBox<T> sampleDistortedBounding
939939
* @param options carries optional attributes values
940940
* @return a new instance of ScaleAndTranslate
941941
*/
942-
public <T extends TNumber> ScaleAndTranslate scaleAndTranslate(Operand<T> images,
942+
public ScaleAndTranslate scaleAndTranslate(Operand<? extends TNumber> images,
943943
Operand<TInt32> size, Operand<TFloat32> scale, Operand<TFloat32> translation,
944944
ScaleAndTranslate.Options... options) {
945945
return ScaleAndTranslate.create(scope, images, size, scale, translation, options);

tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/IoOps.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ public ReaderSerializeState readerSerializeState(Operand<?> readerHandle) {
895895
* @param sparseShape 1-D. The `shape` of the minibatch `SparseTensor`.
896896
* @return a new instance of SerializeManySparse
897897
*/
898-
public <T extends TType> SerializeManySparse<TString> serializeManySparse(
899-
Operand<TInt64> sparseIndices, Operand<T> sparseValues, Operand<TInt64> sparseShape) {
898+
public SerializeManySparse<TString> serializeManySparse(Operand<TInt64> sparseIndices,
899+
Operand<? extends TType> sparseValues, Operand<TInt64> sparseShape) {
900900
return SerializeManySparse.create(scope, sparseIndices, sparseValues, sparseShape);
901901
}
902902

@@ -919,9 +919,8 @@ public <T extends TType> SerializeManySparse<TString> serializeManySparse(
919919
* (default) and `variant`.
920920
* @return a new instance of SerializeManySparse
921921
*/
922-
public <U extends TType, T extends TType> SerializeManySparse<U> serializeManySparse(
923-
Operand<TInt64> sparseIndices, Operand<T> sparseValues, Operand<TInt64> sparseShape,
924-
Class<U> outType) {
922+
public <U extends TType> SerializeManySparse<U> serializeManySparse(Operand<TInt64> sparseIndices,
923+
Operand<? extends TType> sparseValues, Operand<TInt64> sparseShape, Class<U> outType) {
925924
return SerializeManySparse.create(scope, sparseIndices, sparseValues, sparseShape, outType);
926925
}
927926

@@ -934,8 +933,8 @@ public <U extends TType, T extends TType> SerializeManySparse<U> serializeManySp
934933
* @param sparseShape 1-D. The `shape` of the `SparseTensor`.
935934
* @return a new instance of SerializeSparse
936935
*/
937-
public <T extends TType> SerializeSparse<TString> serializeSparse(Operand<TInt64> sparseIndices,
938-
Operand<T> sparseValues, Operand<TInt64> sparseShape) {
936+
public SerializeSparse<TString> serializeSparse(Operand<TInt64> sparseIndices,
937+
Operand<? extends TType> sparseValues, Operand<TInt64> sparseShape) {
939938
return SerializeSparse.create(scope, sparseIndices, sparseValues, sparseShape);
940939
}
941940

@@ -950,9 +949,8 @@ public <T extends TType> SerializeSparse<TString> serializeSparse(Operand<TInt64
950949
* (default) and `variant`.
951950
* @return a new instance of SerializeSparse
952951
*/
953-
public <U extends TType, T extends TType> SerializeSparse<U> serializeSparse(
954-
Operand<TInt64> sparseIndices, Operand<T> sparseValues, Operand<TInt64> sparseShape,
955-
Class<U> outType) {
952+
public <U extends TType> SerializeSparse<U> serializeSparse(Operand<TInt64> sparseIndices,
953+
Operand<? extends TType> sparseValues, Operand<TInt64> sparseShape, Class<U> outType) {
956954
return SerializeSparse.create(scope, sparseIndices, sparseValues, sparseShape, outType);
957955
}
958956

@@ -962,7 +960,7 @@ public <U extends TType, T extends TType> SerializeSparse<U> serializeSparse(
962960
* @param tensor A Tensor of type `T`.
963961
* @return a new instance of SerializeTensor
964962
*/
965-
public <T extends TType> SerializeTensor serializeTensor(Operand<T> tensor) {
963+
public SerializeTensor serializeTensor(Operand<? extends TType> tensor) {
966964
return SerializeTensor.create(scope, tensor);
967965
}
968966

tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/LinalgOps.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ public <T extends TNumber> CholeskyGrad<T> choleskyGrad(Operand<T> l, Operand<T>
342342
* @param perm
343343
* @return a new instance of ConjugateTranspose
344344
*/
345-
public <T extends TType, U extends TNumber> ConjugateTranspose<T> conjugateTranspose(Operand<T> x,
346-
Operand<U> perm) {
345+
public <T extends TType> ConjugateTranspose<T> conjugateTranspose(Operand<T> x,
346+
Operand<? extends TNumber> perm) {
347347
return ConjugateTranspose.create(scope, x, perm);
348348
}
349349

@@ -398,7 +398,7 @@ public <T extends TType> Det<T> det(Operand<T> input) {
398398
* @param options carries optional attributes values
399399
* @return a new instance of Eig
400400
*/
401-
public <U extends TType, T extends TType> Eig<U> eig(Operand<T> input, Class<U> Tout,
401+
public <U extends TType> Eig<U> eig(Operand<? extends TType> input, Class<U> Tout,
402402
Eig.Options... options) {
403403
return Eig.create(scope, input, Tout, options);
404404
}
@@ -505,8 +505,8 @@ public <T extends TType> Einsum<T> einsum(Iterable<Operand<T>> inputs, String eq
505505
* @param options carries optional attributes values
506506
* @return a new instance of EuclideanNorm
507507
*/
508-
public <T extends TType, U extends TNumber> EuclideanNorm<T> euclideanNorm(Operand<T> input,
509-
Operand<U> axis, EuclideanNorm.Options... options) {
508+
public <T extends TType> EuclideanNorm<T> euclideanNorm(Operand<T> input,
509+
Operand<? extends TNumber> axis, EuclideanNorm.Options... options) {
510510
return EuclideanNorm.create(scope, input, axis, options);
511511
}
512512

@@ -1373,10 +1373,10 @@ public <T extends TType> Qr<T> qr(Operand<T> input, Qr.Options... options) {
13731373
* @param options carries optional attributes values
13741374
* @return a new instance of QuantizedMatMul
13751375
*/
1376-
public <V extends TType, T extends TType, U extends TType, W extends TType> QuantizedMatMul<V> quantizedMatMul(
1377-
Operand<T> a, Operand<U> b, Operand<TFloat32> minA, Operand<TFloat32> maxA,
1378-
Operand<TFloat32> minB, Operand<TFloat32> maxB, Class<V> Toutput, Class<W> Tactivation,
1379-
QuantizedMatMul.Options... options) {
1376+
public <V extends TType, W extends TType> QuantizedMatMul<V> quantizedMatMul(
1377+
Operand<? extends TType> a, Operand<? extends TType> b, Operand<TFloat32> minA,
1378+
Operand<TFloat32> maxA, Operand<TFloat32> minB, Operand<TFloat32> maxB, Class<V> Toutput,
1379+
Class<W> Tactivation, QuantizedMatMul.Options... options) {
13801380
return QuantizedMatMul.create(scope, a, b, minA, maxA, minB, maxB, Toutput, Tactivation, options);
13811381
}
13821382

@@ -1544,8 +1544,7 @@ public <T extends TType> TensorDiagPart<T> tensorDiagPart(Operand<T> input) {
15441544
* @param perm
15451545
* @return a new instance of Transpose
15461546
*/
1547-
public <T extends TType, U extends TNumber> Transpose<T> transpose(Operand<T> x,
1548-
Operand<U> perm) {
1547+
public <T extends TType> Transpose<T> transpose(Operand<T> x, Operand<? extends TNumber> perm) {
15491548
return Transpose.create(scope, x, perm);
15501549
}
15511550

0 commit comments

Comments
 (0)