Skip to content

Upgrade to TF 2.18.0 #608

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 12 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
33 changes: 5 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
jobs:
check-format:
if: github.event_name == 'pull_request'
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Configure Java
uses: actions/setup-java@v2
Expand All @@ -35,7 +35,7 @@ jobs:
run: |
mvn spotless:check -Pjdk17 -B -U -e
prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
repositoryUrl: ${{ steps.repository.outputs.repositoryUrl }}
steps:
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }}
linux-x86_64:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: prepare
strategy:
matrix:
Expand Down Expand Up @@ -137,29 +137,6 @@ jobs:
- name: Deploy native artifact
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }}
macosx-x86_64:
runs-on: macos-13
needs: prepare
strategy:
matrix:
ext: [""]
steps:
- name: Configure Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Checkout repository
uses: actions/checkout@v1
- name: Build project
run: |
clang --version
mvn -version
echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml
mvn clean install -pl '!tensorflow-framework' -B -U -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }}
- name: Deploy native artifact
if: env.DEPLOY_RELEASE == 'true' || env.DEPLOY_SNAPSHOT == 'true'
run: mvn -f tensorflow-core/tensorflow-core-native/pom.xml deploy:deploy-file@native-only -B -e -Djavacpp.platform=${{ github.job }} -Djavacpp.platform.extension=${{ matrix.ext }} -Durl=${{ needs.prepare.outputs.repositoryUrl }}
windows-x86_64:
runs-on: windows-2019
needs: prepare
Expand Down Expand Up @@ -208,8 +185,8 @@ jobs:
if ERRORLEVEL 1 exit /b
deploy:
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/staging') }} # DEPLOY_SNAPSHOT (releases should be signed and deployed manually from local machine)
needs: [linux-x86_64, macosx-x86_64, windows-x86_64, macosx-arm64, linux-arm64]
runs-on: ubuntu-20.04
needs: [linux-x86_64, windows-x86_64, macosx-arm64, linux-arm64]
runs-on: ubuntu-22.04
steps:
- name: Configure Java
uses: actions/setup-java@v2
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ To upgrade the version of TensorFlow that is embedded within TensorFlow Java, pl
3. Update `urls`, `sha256` and `strip_prefix` fields of the `org_tensorflow` archive rule in Bazel [workspace](https://github.com/tensorflow/java/blob/master/tensorflow-core/tensorflow-core-native/WORKSPACE#L19)
4. Extract the archive in a temporary folder
5. Copy the content of `tensorflow-x.x.x/.bazelrc` file to `tensorflow-core/tensorflow-core-native/tensorflow.bazelrc` under TensorFlow Java source tree
6. Copy the content of `tensorflow-x.x.x/WORKSPACE` after the "###### Copy content of..." notice if `tensorflow-core/tensorflow-core-native/WORKSPACE`, read notice for more details
6. Copy the content of `tensorflow-x.x.x/WORKSPACE` after the "###### Copy content of..." notice to `tensorflow-core/tensorflow-core-native/WORKSPACE`, read notice for more details
7. Copy the content of `tensorflow-x.x.x/.bazelversion` file to `tensorflow-core/tensorflow-core-native/.bazelversion`
8. Validate that options in `tensorflow-core/tensorflow-core-native/.bazelrc` are still accurate or update them accordingly
9. Update URLs of existing TensorFlow binaries in the `tensorflow-core/tensorflow-core-native/scripts/dist_download` script
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,24 @@ only binaries for the followings are being **supported and distributed** by this
- `linux-x86_64`: Linux platforms on Intel/AMD chips
- `linux-x86_64-gpu`: Linux platforms on Intel/AMD chips with Cuda GPU support
- `linux-arm64`: Linux platforms on Arm chips
- `macosx-x86_64`: MacOS X platforms on Intel/AMD chips
- `macosx-arm64`: MacOS X platforms on Apple Silicon chips
- `windows-x86_64`: Windows platforms on Intel/AMD chips

Binaries for `macosx-x86_64` are available for TF-Java 1.0 series releases and earlier, they were dropped from
TF-Java 1.1 and newer as they are no longer supported or released by Google.

For example, for building a JAR that uses TensorFlow and is targeted to be deployed only on Linux
systems with no GPU support, you should add the following dependencies:
```xml
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-api</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-native</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
<classifier>linux-x86_64</classifier>
</dependency>
```
Expand All @@ -85,24 +87,24 @@ native dependencies as follows:
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-api</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-native</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
<classifier>linux-x86_64-gpu</classifier>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-native</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
<classifier>macosx-arm64</classifier>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-native</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
<classifier>windows-x86_64</classifier>
</dependency>
```
Expand All @@ -119,15 +121,15 @@ For Ubuntu 24.04, you can install them with the following command:
In some cases, it might be preferable to add a single dependency that includes transitively all the artifacts
required to run TensorFlow Java on any [supported platforms](README.md#individual-dependencies)

- `tensorflow-core-platform`: Includes `tensorflow-core-api`, plus native artifacts for `linux-x86_64`, `linux-x86_64-arm64`, `macosx-arm64`, `macosx-x86_64` and `windows-x86_64`
- `tensorflow-core-platform`: Includes `tensorflow-core-api`, plus native artifacts for `linux-x86_64`, `linux-x86_64-arm64`, `macosx-arm64` and `windows-x86_64`

For example, to run TensorFlow Java on any CPU platform for which a binary is being distributed by this project, you can
simply add this dependency to your application:
```xml
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
</dependency>
```

Expand Down Expand Up @@ -157,7 +159,7 @@ to add Sonatype OSS repository in your pom.xml, like the following
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
```
Expand All @@ -179,7 +181,8 @@ This table shows the mapping between TensorFlow, TensorFlow Java and minimum sup
| 0.5.0 | 2.10.1 | 11 |
| 1.0.0-rc.1 | 2.16.1 | 11 |
| 1.0.0-rc.2 | 2.16.2 | 11 |
| 1.0.0-SNAPSHOT | 2.16.2 | 11 |
| 1.0.0 | 2.16.2 | 11 |
| 1.1.0-SNAPSHOT | 2.18.0 | 11 |

## How to Contribute?

Expand Down
13 changes: 8 additions & 5 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ following platforms:

* Ubuntu 20.04 or higher; 64-bit, x86
* Ubuntu 22.04 or higher; 64-bit, arm
* macOS 12 or higher; 64-bit, x86
* macOS 14 or higher; 64-bit, arm
* Windows 10 or higher; 64-bit, x86

TensorFlow Java 1.0 series and earlier releases also have binaries for:

* macOS 12 or higher; 64-bit, x86

*Note: To use TensorFlow on Android, see
[TensorFlow Lite](https://tensorflow.org/lite)*

Expand Down Expand Up @@ -59,7 +62,7 @@ For example,
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
</dependency>
```

Expand Down Expand Up @@ -102,7 +105,7 @@ snapshots repository in your `pom.xml`.
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
```
Expand All @@ -119,7 +122,7 @@ repositories {
}

dependencies {
compile group: 'org.tensorflow', name: 'tensorflow-core-platform', version: '1.0.0-rc.2'
compile group: 'org.tensorflow', name: 'tensorflow-core-platform', version: '1.0.0'
}
```

Expand Down Expand Up @@ -165,7 +168,7 @@ add the TensorFlow dependency to the project's `pom.xml` file:
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-platform</artifactId>
<version>1.0.0-rc.2</version>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-java</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>TensorFlow Java Parent</name>
Expand Down Expand Up @@ -212,7 +212,7 @@
<!--arg>-Werror</arg--> <!-- Disabled (temporarily?) -->
<arg>-Xlint:all</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<!-- FIXME: turn me on again! arg>-Xplugin:ErrorProne</arg-->
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>

Expand Down
4 changes: 2 additions & 2 deletions tensorflow-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-java</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>tensorflow-core</artifactId>
<packaging>pom</packaging>
Expand Down Expand Up @@ -59,7 +59,7 @@
<javacpp.platform.macosx-arm64.extension>macosx-arm64${javacpp.platform.extension}</javacpp.platform.macosx-arm64.extension>
<javacpp.platform.macosx-x86_64.extension>macosx-x86_64${javacpp.platform.extension}</javacpp.platform.macosx-x86_64.extension>
<javacpp.platform.windows-x86_64.extension>windows-x86_64${javacpp.platform.extension}</javacpp.platform.windows-x86_64.extension>
<javacpp.version>1.5.10</javacpp.version>
<javacpp.version>1.5.11</javacpp.version>
</properties>

<profiles>
Expand Down
2 changes: 1 addition & 1 deletion tensorflow-core/tensorflow-core-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>tensorflow-core-api</artifactId>
<packaging>jar</packaging>
Expand Down
9 changes: 6 additions & 3 deletions tensorflow-core/tensorflow-core-api/scripts/test_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ DOWNLOAD_FOLDER="$1"

case ${PLATFORM:-} in
'linux-x86_64')
TEXT_WHEEL_URL='https://files.pythonhosted.org/packages/43/dd/8f03331107b76e63313d2089ddfbd13f15e51fb8ed73517cdd0ab3341928/tensorflow-2.16.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl'
TEXT_WHEEL_URL='https://files.pythonhosted.org/packages/f3/73/3a906feb0d71d9353c6fb2363d4052856cc6eff5a78a097b1a6002d4e908/tensorflow_text-2.18.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl'
;;
'macosx-x86_64')
TEXT_WHEEL_URL='https://files.pythonhosted.org/packages/6d/69/9999c2d9e8a3b08dfcfc7e9259a05fb1da5f700936091d2eb4a7985c2776/tensorflow-2.16.2-cp311-cp311-macosx_10_15_x86_64.whl'
'linux-arm64')
TEXT_WHEEL_URL='https://files.pythonhosted.org/packages/8a/9a/ebba9f6274f8b51e5fe1ac2411b8b6bf680a32d10bd6e9c54be1faeec062/tensorflow_text-2.18.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl'
;;
'macosx-arm64')
TEXT_WHEEL_URL='https://files.pythonhosted.org/packages/18/b6/8ad233edb0732847db1da538cea941dcccc42f59304ff6fb449676e6dd5a/tensorflow_text-2.18.1-cp311-cp311-macosx_11_0_arm64.whl'
;;
*)
echo "TensorFlow Text distribution for ${PLATFORM} is not supported for download"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "CheckPinned"
endpoint {
name: "CheckPinned"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
op {
graph_op_name: "ComputeDedupDataSize"
visibility: VISIBLE
visibility: SKIP
endpoint {
name: "tpu.ComputeDedupDataSize"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "ComputeDedupDataSizeV2"
endpoint {
name: "tpu.ComputeDedupDataSize"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
op {
visibility: VISIBLE
visibility: SKIP
graph_op_name: "ComputeDedupDataTupleMask"
endpoint {
name: "tpu.ComputeDedupDataTupleMask"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "ComputeDedupDataTupleMaskV2"
endpoint {
name: "tpu.ComputeDedupDataTupleMask"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
op {
graph_op_name: "ConvertToListOfSparseCoreCooTensors"
visibility: VISIBLE
endpoint {
name: "sparse.ConvertToListOfSparseCoreCooTensors"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
op {
graph_op_name: "ConvertToSparseCoreCsrWrappedCooTensor"
visibility: VISIBLE
endpoint {
name: "sparse.ConvertToSparseCoreCsrWrappedCooTensor"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
op {
visibility: VISIBLE
visibility: SKIP
graph_op_name: "FinalizeTPUEmbedding"
endpoint {
name: "tpu.FinalizeTPUEmbedding"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "FinalizeTPUEmbeddingV2"
endpoint {
name: "tpu.FinalizeTPUEmbedding"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
op {
graph_op_name: "GetStatsFromListOfSparseCoreCooTensors"
visibility: VISIBLE
endpoint {
name: "sparse.GetStatsFromListOfSparseCoreCooTensors"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
op {
graph_op_name: "GetTpuTaskId"
visibility: VISIBLE
endpoint {
name: "tpu.GetTpuTaskId"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "GlobalShuffleDataset"
endpoint {
name: "data.GlobalShuffleDataset"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
op {
graph_op_name: "IndexFlatMapDataset"
visibility: VISIBLE
endpoint {
name: "data.IndexFlatMapDataset"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "IteratorGetModelProto"
endpoint {
name: "data.IteratorGetModelProto"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
op {
graph_op_name: "SortListOfSparseCoreCooTensors"
endpoint {
name: "sparse.SortListOfSparseCoreCooTensors"
}
}
Loading
Loading