Skip to content

Move op generation to Java #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
edbcd4e
Generate op def file
rnett Mar 18, 2021
f03198e
Cleanup, nicer usage header
rnett Mar 18, 2021
487bc67
Move resource, fix generation
rnett Mar 18, 2021
f8dfc91
Better commenting and usage header
rnett Mar 18, 2021
3f1dbb0
Copy ops.pb into platform jar
rnett Mar 19, 2021
41dfa08
Don't copy generated ops file, leave in git
rnett Mar 20, 2021
5c4551d
Move proto sources to separate source dir
rnett Mar 20, 2021
151aff1
Duplicate protos instead of sharing
rnett Mar 28, 2021
b9990d0
Start of Java-side op generation
rnett Mar 13, 2021
bff2806
Fixes for generation
rnett Mar 14, 2021
30f05df
More fixes, some code cleanup
rnett Mar 14, 2021
60cd127
Cleanup
rnett Mar 14, 2021
41f9b8f
Fix module name
rnett Mar 14, 2021
370a35b
Error if on non-linux OS
rnett Mar 14, 2021
c7f80a3
A couple more fixes, mostly to use Long
rnett Mar 14, 2021
11d5628
Move type stuff to the type resolver
rnett Mar 14, 2021
71a8444
Missed a final
rnett Mar 14, 2021
d2f7f48
Try build fix
rnett Mar 14, 2021
b261bbe
Build updates, new package
rnett Mar 14, 2021
1cc81c7
Commit the build updates
rnett Mar 14, 2021
2d8ef31
Really fix build
rnett Mar 14, 2021
120a63b
Rebuild
rnett Mar 14, 2021
f24a091
Don't fail on javadoc error
rnett Mar 14, 2021
8ace759
Ignore IDEA run configs dir
rnett Mar 15, 2021
756d6b1
Allow non-Linux OSs
rnett Mar 15, 2021
2f2d420
Clean up code, add comments
rnett Mar 15, 2021
18bd5d2
Bump version after rebase
rnett Mar 19, 2021
065f5e8
Move op generator to tensorflow-core-generator, use exported op defs
rnett Mar 20, 2021
6e0ed0e
Fixes
rnett Mar 20, 2021
bca4315
Formatting fix
rnett Mar 20, 2021
567e4c1
Package name constants
rnett Mar 20, 2021
4099c10
Add exec plugin
rnett Mar 20, 2021
af71cc6
Rebase fix
rnett Mar 21, 2021
1882816
Clean up javadoc generation
rnett Mar 21, 2021
04e2699
Remove Java 11 API
rnett Mar 28, 2021
31e7d2c
Duplicate protos instead of sharing
rnett Mar 28, 2021
bf993dd
Remove rebase newline
rnett Mar 28, 2021
533c241
Add a few missed javadoc conversions
rnett Mar 29, 2021
8a18d37
Add commonmark-java
JimClarke5 Mar 29, 2021
003c888
Fix @compatability and @end_compatibility to add <br>
JimClarke5 Mar 29, 2021
3fdee84
Add checks for summary and description when empty, them provide defau…
JimClarke5 Mar 30, 2021
973cffb
Reformat code.
JimClarke5 Mar 30, 2021
29a9155
Reformat code.
JimClarke5 Mar 30, 2021
65b59a7
Reformat code.
JimClarke5 Mar 30, 2021
04e0cb3
Reformat code.
JimClarke5 Mar 30, 2021
f1a0239
Reformat code.
JimClarke5 Mar 30, 2021
3f8cf73
Reformat code.
JimClarke5 Mar 30, 2021
f6b9245
Add unused to renderCodeBlock for unused parameter attributes.
JimClarke5 Mar 30, 2021
e96e9a8
Fix merge and a few newline nits
rnett Apr 5, 2021
e610e79
Merge fixes
rnett Apr 5, 2021
cdc2e8a
Keep only necessary protos
rnett Apr 7, 2021
a6b389d
Add license header
rnett Apr 7, 2021
0f9eb71
Move generator execution to core-api
rnett Apr 7, 2021
6a09b43
pom comment
rnett Apr 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ __pycache__
cmake_build/
tensorflow/contrib/cmake/_build/
.idea/**
.run
/build/
[Bb]uild/
/tensorflow/core/util/version_info.cc
Expand Down
2 changes: 1 addition & 1 deletion tensorflow-core/tensorflow-core-api/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $BAZEL_BIN/java_op_generator \
GEN_RESOURCE_DIR=src/gen/resources/org/tensorflow/op
mkdir -p $GEN_RESOURCE_DIR

# Generate Java operator wrappers
# Export op defs
$BAZEL_BIN/java_op_exporter \
--api_dirs=$BAZEL_SRCS/external/org_tensorflow/tensorflow/core/api_def/base_api,src/bazel/api_def \
$TENSORFLOW_LIB > $GEN_RESOURCE_DIR/ops.pb
Expand Down
35 changes: 35 additions & 0 deletions tensorflow-core/tensorflow-core-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,41 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<!--
An execution to execute the op class generator (which lives in tensorflow-core-generator).
Must be ran after build.sh, which generates the ops.pb file it reads.
Will be ran during the generate-sources phase.
-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>generate-ops</id>
<goals>
<goal>java</goal>
</goals>
<!-- <phase>generate-sources</phase>-->
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-generator</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>org.tensorflow.op.generator.OpGenerator</mainClass>
<arguments>
<argument>${project.basedir}/src/gen/java</argument>
<argument>${project.basedir}/src/gen/resources/org/tensorflow/op/ops.pb</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private static <T extends TType> void register(Class<T> type) {

static {
// TODO (karllessard) scan and registered automatically all annotated tensors types
// TODO use in generator?
register(TBool.class);
register(TFloat64.class);
register(TFloat32.class);
Expand Down
15 changes: 13 additions & 2 deletions tensorflow-core/tensorflow-core-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<artifactId>tensorflow-core-generator</artifactId>
<packaging>jar</packaging>

<name>TensorFlow Core Annotation Processor</name>
<description>Annotation processor for TensorFlow Java client</description>
<name>TensorFlow Core Generators</name>
<description>Code generators for TensorFlow Java client</description>

<properties>
<java.module.name>org.tensorflow.core.generator</java.module.name>
Expand All @@ -28,11 +28,22 @@
<artifactId>javapoet</artifactId>
<version>1.12.1</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf.version}</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.15.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.commonmark/commonmark -->
<dependency>
<groupId>org.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.17.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright 2021 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
*/
package org.tensorflow;

import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;

public class Names {

public static final String TensorflowPackage = "org.tensorflow";
public static final String OpPackage = TensorflowPackage + ".op";
public static final String TypesPackage = TensorflowPackage + ".types";

public static final ClassName Operator = ClassName.get(OpPackage + ".annotation", "Operator");
public static final ClassName Endpoint = ClassName.get(OpPackage + ".annotation", "Endpoint");

public static final ClassName TType = ClassName.get(TypesPackage + ".family", "TType");
public static final ClassName TString = ClassName.get(TypesPackage, "TString");
public static final ClassName TBool = ClassName.get(TypesPackage, "TBool");

public static final ClassName TNumber = ClassName.get(TypesPackage + ".family", "TNumber");

public static final ClassName TFloating = ClassName.get(TypesPackage + ".family", "TFloating");
public static final ClassName TBfloat16 = ClassName.get(TypesPackage, "TBfloat16");
public static final ClassName TFloat16 = ClassName.get(TypesPackage, "TFloat16");
public static final ClassName TFloat32 = ClassName.get(TypesPackage, "TFloat32");
public static final ClassName TFloat64 = ClassName.get(TypesPackage, "TFloat64");

public static final ClassName TIntegral = ClassName.get(TypesPackage + ".family", "TIntegral");
public static final ClassName TUint8 = ClassName.get(TypesPackage, "TUint8");
public static final ClassName TInt32 = ClassName.get(TypesPackage, "TInt32");
public static final ClassName TInt64 = ClassName.get(TypesPackage, "TInt64");

public static final TypeName Op = ClassName.get(OpPackage, "Op");
public static final ClassName RawOp = ClassName.get(OpPackage, "RawOp");
public static final ClassName Operation = ClassName.get(TensorflowPackage, "Operation");
public static final ClassName Operands = ClassName.get(OpPackage, "Operands");
public static final ClassName OperationBuilder = ClassName.get(TensorflowPackage, "OperationBuilder");
public static final TypeName IterableOp = ParameterizedTypeName.get(ClassName.get(Iterable.class), Op);

public static final ClassName Operand = ClassName.get(TensorflowPackage, "Operand");
public static final ClassName Output = ClassName.get(TensorflowPackage, "Output");

public static final ClassName Shape = ClassName.get(TensorflowPackage + ".ndarray", "Shape");
public static final ClassName Tensor = ClassName.get(TensorflowPackage, "Tensor");
public static final ClassName ConcreteFunction = ClassName.get(TensorflowPackage, "ConcreteFunction");

public static final ClassName Scope = ClassName.get(OpPackage, "Scope");
public static final TypeName DeviceSpec = ClassName.get(TensorflowPackage, "DeviceSpec");
public static final ClassName Ops = ClassName.get(OpPackage, "Ops");

public static final TypeName ExecutionEnvironment =
ClassName.get(TensorflowPackage, "ExecutionEnvironment");
public static final TypeName EagerSession = ClassName.get(TensorflowPackage, "EagerSession");

public static final TypeName String = ClassName.get(String.class);

}
Loading