From 391cd925f2378989bdbfc1390c3c92ba6ce2a0c1 Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Tue, 15 Feb 2022 23:27:36 -0500 Subject: [PATCH 1/7] Upgrade minimal supported JDK to 11 --- .github/workflows/ci.yml | 47 ++++++++++--- pom.xml | 29 +++++--- tensorflow-core/tensorflow-core-api/pom.xml | 1 - .../src/main/java/module-info.java | 68 +++++++++++++++++++ .../src/main/java/module-info.java | 25 +++++++ .../op/generator/AttributeType.java | 2 +- .../tensorflow/op/generator/FullOpDef.java | 2 +- .../tensorflow/op/generator/StatefulPair.java | 2 +- tensorflow-framework/pom.xml | 4 -- .../src/main/java/module-info.java | 36 ++++++++++ 10 files changed, 186 insertions(+), 30 deletions(-) create mode 100644 tensorflow-core/tensorflow-core-api/src/main/java/module-info.java create mode 100644 tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java create mode 100644 tensorflow-framework/src/main/java/module-info.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fd044979af..6026af0fe2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,53 +20,63 @@ jobs: runs-on: ubuntu-latest container: centos:7 steps: - - name: Checkout repository - uses: actions/checkout@v1 - name: Install environment run: | yum -y update yum -y install centos-release-scl-rh epel-release - yum -y install java-11-openjdk-devel devtoolset-9 + yum -y install devtoolset-9 echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/bin/mvn + - name: Configure Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '17' + - name: Checkout repository + uses: actions/checkout@v1 - name: Build project run: | source scl_source enable devtoolset-9 || true export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) echo $JAVA_HOME mvn -version - mvn clean install -Pdev,jdk11 -B -U -e -Dlint.skip=true + mvn clean install -Pdev,jdk17 -B -U -e -Dlint.skip=true - name: Run lint checks run: | - mvn compiler:compile -Pdev,jdk11 -B -U -e + mvn compiler:compile -Pdev,jdk17 -B -U -e check-format: if: github.event_name == 'pull_request' runs-on: ubuntu-latest container: centos:7 steps: - - name: Checkout repository - uses: actions/checkout@v1 - name: Install environment run: | yum -y update yum -y install centos-release-scl-rh epel-release - yum -y install java-11-openjdk-devel devtoolset-9 + yum -y install devtoolset-9 echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/bin/mvn + - name: Configure Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '17' + - name: Checkout repository + uses: actions/checkout@v1 - name: Build project run: | source scl_source enable devtoolset-9 || true export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) echo $JAVA_HOME mvn -version - mvn clean install -Pdev,jdk11 -B -U -e -Dlint.skip=true -Dmaven.test.skip=true + mvn clean install -Pdev,jdk17 -B -U -e -Dlint.skip=true -Dmaven.test.skip=true - name: Run format checks run: | - mvn spotless:check -Pdev,jdk11 -B -U -e + mvn spotless:check -Pdev,jdk17 -B -U -e prepare: runs-on: ubuntu-latest outputs: @@ -99,7 +109,7 @@ jobs: yum --disablerepo updates -y install $GLIBC yum -x "$GLIBC" -y update yum -x "$GLIBC" -y install centos-release-scl-rh epel-release - yum -x "$GLIBC" -y install java-1.8.0-openjdk-devel devtoolset-9 rh-git218 patch perl-Data-Dumper python36-devel python36-numpy python36-pip python36-six + yum -x "$GLIBC" -y install devtoolset-9 rh-git218 patch perl-Data-Dumper python36-devel python36-numpy python36-pip python36-six echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ @@ -124,6 +134,11 @@ jobs: rm -f $(find /usr/local/cuda/ -name '*.a' -and -not -name libcudart_static.a -and -not -name libcudadevrt.a) rm -rf /usr/local/cuda/doc* /usr/local/cuda/libnvvp* /usr/local/cuda/nsight* /usr/local/cuda/samples* fi + - name: Configure Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' - name: Checkout repository uses: actions/checkout@v1 - name: Build project @@ -163,6 +178,11 @@ jobs: curl -L https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel-3.7.2-installer-darwin-x86_64.sh -o bazel.sh --retry 10 bash bazel.sh brew install libomp perl + - name: Configure Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' - name: Checkout repository uses: actions/checkout@v1 - name: Build project @@ -223,6 +243,11 @@ jobs: cp.exe -a cuda/include cuda/lib cuda/bin "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/" ) echo %JAVA_HOME% + - name: Configure Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' - name: Checkout repository uses: actions/checkout@v1 - name: Build project diff --git a/pom.xml b/pom.xml index 66687aade72..c2649887d65 100644 --- a/pom.xml +++ b/pom.xml @@ -37,8 +37,9 @@ UTF8 - 1.8 - 1.8 + 11 + 11 + 11 5.6.2 1.21 2.7 @@ -174,11 +175,11 @@ - jdk11 + jdk17 - 11 - 11 - 11 + 17 + 17 + 17 @@ -189,8 +190,6 @@ lint - - (1.9,) !lint.skip @@ -366,15 +365,12 @@ spotless-maven-plugin ${spotless.version} - origin/master - 1.14.0 - @@ -387,6 +383,17 @@ maven-jar-plugin 3.2.0 + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + **/*Test.java + + false + + diff --git a/tensorflow-core/tensorflow-core-api/pom.xml b/tensorflow-core/tensorflow-core-api/pom.xml index 142aac1065f..255abef3d65 100644 --- a/tensorflow-core/tensorflow-core-api/pom.xml +++ b/tensorflow-core/tensorflow-core-api/pom.xml @@ -433,7 +433,6 @@ maven-surefire-plugin - 3.0.0-M5 org/tensorflow/internal/c_api/presets/*.java diff --git a/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java b/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java index 5fbae9badef..27eb5d57b40 100644 --- a/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java +++ b/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java @@ -18,6 +18,7 @@ requires transitive org.tensorflow.ndarray; requires org.bytedeco.javacpp; requires com.google.protobuf; + requires java.logging; exports org.tensorflow; exports org.tensorflow.exceptions; diff --git a/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java b/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java index cb3fe610acc..5fa3e342594 100644 --- a/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java +++ b/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java @@ -15,10 +15,13 @@ ======================================================================= */ module org.tensorflow.generator { - requires org.commonmark; - requires com.squareup.javapoet; + requires java.compiler; + + requires com.github.javaparser.core; requires com.google.protobuf; requires com.google.common; + requires com.squareup.javapoet; + requires org.commonmark; exports org.tensorflow.processor.operator; exports org.tensorflow.op.generator; From 50a9a367cd0c87fdb69322cd56e624fa267d75f9 Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Thu, 3 Mar 2022 09:06:41 -0500 Subject: [PATCH 3/7] Fix build on JDK17 and spotless checks --- .mvn/jvm.config | 10 +++++++ pom.xml | 18 ++++++++---- tensorflow-core/tensorflow-core-api/pom.xml | 4 ++- .../src/main/java/module-info.java | 28 +++++++++---------- .../src/main/java/module-info.java | 27 +++++++++--------- .../src/main/java/module-info.java | 27 +++++++++--------- 6 files changed, 65 insertions(+), 49 deletions(-) create mode 100644 .mvn/jvm.config diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 00000000000..8488a4fce61 --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1,10 @@ +--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \ No newline at end of file diff --git a/pom.xml b/pom.xml index c2649887d65..d87daefcb7b 100644 --- a/pom.xml +++ b/pom.xml @@ -192,7 +192,7 @@ - !lint.skip + lint.skip !true @@ -204,13 +204,15 @@ 3.8.0 true - true -Xlint:all -XDcompilePolicy=simple -Xplugin:ErrorProne - + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED @@ -219,8 +221,6 @@ -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED @@ -302,6 +302,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + true + + org.apache.maven.plugins diff --git a/tensorflow-core/tensorflow-core-api/pom.xml b/tensorflow-core/tensorflow-core-api/pom.xml index 3ed415899b7..4acb14dfecd 100644 --- a/tensorflow-core/tensorflow-core-api/pom.xml +++ b/tensorflow-core/tensorflow-core-api/pom.xml @@ -200,10 +200,12 @@ compile - 8 org/tensorflow/internal/c_api/presets/*.java + + 8 + diff --git a/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java b/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java index 27eb5d57b40..9e2866e1f02 100644 --- a/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java +++ b/tensorflow-core/tensorflow-core-api/src/main/java/module-info.java @@ -1,19 +1,19 @@ /* - Copyright 2022 The TensorFlow Authors. All Rights Reserved. +Copyright 2022 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 +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 + 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. - ======================================================================= - */ +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. +======================================================================= +*/ module org.tensorflow { requires transitive org.tensorflow.ndarray; requires org.bytedeco.javacpp; @@ -25,7 +25,6 @@ exports org.tensorflow.types; exports org.tensorflow.types.annotation; exports org.tensorflow.types.family; - exports org.tensorflow.op; exports org.tensorflow.op.annotation; exports org.tensorflow.op.core; @@ -56,7 +55,6 @@ exports org.tensorflow.op.tpu; exports org.tensorflow.op.train; exports org.tensorflow.op.xla; - exports org.tensorflow.proto.data; exports org.tensorflow.proto.data.experimental; exports org.tensorflow.proto.data.model; @@ -66,4 +64,4 @@ exports org.tensorflow.proto.profiler; exports org.tensorflow.proto.util; exports org.tensorflow.proto.util.testlog; -} \ No newline at end of file +} diff --git a/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java b/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java index 5fa3e342594..5574125ecfd 100644 --- a/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java +++ b/tensorflow-core/tensorflow-core-generator/src/main/java/module-info.java @@ -1,22 +1,21 @@ /* - Copyright 2022 The TensorFlow Authors. All Rights Reserved. +Copyright 2022 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 +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 + 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. - ======================================================================= - */ +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. +======================================================================= +*/ module org.tensorflow.generator { requires java.compiler; - requires com.github.javaparser.core; requires com.google.protobuf; requires com.google.common; @@ -25,4 +24,4 @@ exports org.tensorflow.processor.operator; exports org.tensorflow.op.generator; -} \ No newline at end of file +} diff --git a/tensorflow-framework/src/main/java/module-info.java b/tensorflow-framework/src/main/java/module-info.java index b213670707b..56a50ec6ba8 100644 --- a/tensorflow-framework/src/main/java/module-info.java +++ b/tensorflow-framework/src/main/java/module-info.java @@ -1,19 +1,19 @@ /* - Copyright 2022 The TensorFlow Authors. All Rights Reserved. +Copyright 2022 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 +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 + 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. - ======================================================================= - */ +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. +======================================================================= +*/ module org.tensorflow.framework { requires org.tensorflow; @@ -27,10 +27,9 @@ exports org.tensorflow.framework.optimizers; exports org.tensorflow.framework.regularizers; exports org.tensorflow.framework.utils; - exports org.tensorflow.framework.op; exports org.tensorflow.framework.op.linalg; exports org.tensorflow.framework.op.math; exports org.tensorflow.framework.op.nn; exports org.tensorflow.framework.op.sets; -} \ No newline at end of file +} From 2d194be52a559dab72d36d52a92a89a461ba07d5 Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Thu, 3 Mar 2022 09:34:34 -0500 Subject: [PATCH 4/7] Use JAVA_HOME from setup-java action --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6026af0fe2a..820d7c740e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,6 @@ jobs: - name: Build project run: | source scl_source enable devtoolset-9 || true - export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) echo $JAVA_HOME mvn -version mvn clean install -Pdev,jdk17 -B -U -e -Dlint.skip=true @@ -70,7 +69,6 @@ jobs: - name: Build project run: | source scl_source enable devtoolset-9 || true - export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) echo $JAVA_HOME mvn -version mvn clean install -Pdev,jdk17 -B -U -e -Dlint.skip=true -Dmaven.test.skip=true From fdfc6e074b2d235b925d1430a5ae68fd794327c1 Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Thu, 3 Mar 2022 18:46:38 -0500 Subject: [PATCH 5/7] Enforce usage of VC2019 on Windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 820d7c740e1..4eeaf85de8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,7 +204,7 @@ jobs: df -h windows-x86_64: if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build') - runs-on: windows-latest + runs-on: windows-2019 needs: prepare strategy: matrix: From 377185cd4ef955645d80b14fbe567ece492f2d5a Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Tue, 8 Mar 2022 10:53:47 -0500 Subject: [PATCH 6/7] Add minimum Java version to version mapping table --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 305fb1e759a..f98176730a6 100644 --- a/README.md +++ b/README.md @@ -137,19 +137,19 @@ to add Sonatype OSS repository in your pom.xml, like the following ``` -## TensorFlow Version Support - -This table shows the mapping between different version of TensorFlow for Java and the core runtime libraries. - -| TensorFlow Java Version | TensorFlow Version | -| ------------- | ------------- | -| 0.2.0 | 2.3.1 | -| 0.3.0 | 2.4.1 | -| 0.3.1 | 2.4.1 | -| 0.3.2 | 2.4.1 | -| 0.3.3 | 2.4.1 | -| 0.4.0 | 2.7.0 | -| 0.5.0-SNAPSHOT | 2.7.0 | +## TensorFlow/JDK Version Support + +This table shows the mapping between TensorFlow, TensorFlow Java and minimum supported Java versions. + +| TensorFlow Java Version | TensorFlow Version | Minimum Java Version | +| ------------- | ------------- | --------------- | +| 0.2.0 | 2.3.1 | 8 | +| 0.3.0 | 2.4.1 | 8 | +| 0.3.1 | 2.4.1 | 8 | +| 0.3.2 | 2.4.1 | 8 | +| 0.3.3 | 2.4.1 | 8 | +| 0.4.0 | 2.7.0 | 8 | +| 0.5.0-SNAPSHOT | 2.7.0 | 11 | ## How to Contribute? From 1a2a8ce9b408d5923fe8378c3e88c432cc72165b Mon Sep 17 00:00:00 2001 From: Karl Lessard Date: Tue, 8 Mar 2022 10:54:37 -0500 Subject: [PATCH 7/7] Add minimum Java version to version mapping table --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f98176730a6..33aed938816 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ to add Sonatype OSS repository in your pom.xml, like the following ``` -## TensorFlow/JDK Version Support +## TensorFlow/Java Version Support This table shows the mapping between TensorFlow, TensorFlow Java and minimum supported Java versions.