From cbddd464592197e424fd5fe14274cd071602fce4 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Mon, 8 Mar 2021 21:43:14 -0800 Subject: [PATCH 1/5] Set up configure scripts Signed-off-by: Ryan Nett --- .gitignore | 1 + CONTRIBUTING.md | 11 ++++---- .../tensorflow-core-api/.bazelversion | 1 + tensorflow-core/tensorflow-core-api/WORKSPACE | 9 ------- tensorflow-core/tensorflow-core-api/build.sh | 4 +++ tensorflow-core/tensorflow-core-api/configure | 26 +++++++++++++++++++ .../tensorflow-core-api/configure.cmd | 9 +++++++ 7 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 tensorflow-core/tensorflow-core-api/.bazelversion create mode 100644 tensorflow-core/tensorflow-core-api/configure create mode 100644 tensorflow-core/tensorflow-core-api/configure.cmd diff --git a/.gitignore b/.gitignore index cdbd28eca7c..683795447cb 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ gradleBuild **/target .tf_configure.bazelrc .clwb/ +/tensorflow-core/tensorflow-core-api/config.log diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 88e17c1ca3d..09563247a16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,11 +24,9 @@ complete build could be required to reflect the changes, otherwise `-Pdev` shoul ### Native Builds In some cases, like when adding GPU support or re-generating op classes, you will need to re-build the native library. 99% of this is building -TensorFlow, which by default is configured for the [CI](.github/workflows/ci.yml). The build configuration can be customized using the same methods as -TensorFlow, so if you're building locally, you may need to clone the [tensorflow](https://github.com/tensorflow/tensorflow) project, run its -configuration script (`./configure`), and copy the resulting -`.tf_configure.bazelrc` to `tensorflow-core-api`. This overrides the default options, and you can add to it manually (i.e. adding `build --copt="-g"` -to build with debugging info). +TensorFlow, which by default is configured for the [CI](.github/workflows/ci.yml). The build configuration can be customized using the `configure` +scripts in `tensorflow-core-api`, which call the scripts downloaded with the tensorflow dependency. This overrides the default options, and you can +add to it manually (i.e. adding `build --copt="-g"` to build with debugging info). ### GPU Support @@ -90,7 +88,8 @@ in [IntelliJ](https://github.com/google/styleguide/blob/gh-pages/intellij-java-g ### Dependencies -For dependencies, we can use anything compliant with [this list](https://opensource.google/docs/thirdparty/licenses/#notice), but we want to keep the core libraries as dependency free as possible. +For dependencies, we can use anything compliant with [this list](https://opensource.google/docs/thirdparty/licenses/#notice), but we want to keep the +core libraries as dependency free as possible. ### Code generation diff --git a/tensorflow-core/tensorflow-core-api/.bazelversion b/tensorflow-core/tensorflow-core-api/.bazelversion new file mode 100644 index 00000000000..47b6be3fafe --- /dev/null +++ b/tensorflow-core/tensorflow-core-api/.bazelversion @@ -0,0 +1 @@ +3.7.2 \ No newline at end of file diff --git a/tensorflow-core/tensorflow-core-api/WORKSPACE b/tensorflow-core/tensorflow-core-api/WORKSPACE index bd5ce478f66..cb2de293fd5 100644 --- a/tensorflow-core/tensorflow-core-api/WORKSPACE +++ b/tensorflow-core/tensorflow-core-api/WORKSPACE @@ -7,15 +7,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # the version of this archive (e.g. google protobuf) http_archive( name = "org_tensorflow", - patches = [ - ":tensorflow-visibility.patch", - ":tensorflow-macosx.patch", -# ":tensorflow-windows.patch", # https://github.com/tensorflow/tensorflow/issues/25213 - ":tensorflow-proto.patch", - ], - patch_tool = "patch", - patch_args = ["-p1"], - patch_cmds = ["grep -rl 'java_package' tensorflow/core | xargs sed -i.bak 's/^\(.* java_package = \"org\.tensorflow\.\)\(.*\"\)/\\1proto.\\2'/"], urls = [ "https://github.com/tensorflow/tensorflow/archive/v2.4.1.tar.gz", ], diff --git a/tensorflow-core/tensorflow-core-api/build.sh b/tensorflow-core/tensorflow-core-api/build.sh index 6f283bb66dc..f6c01c093d5 100755 --- a/tensorflow-core/tensorflow-core-api/build.sh +++ b/tensorflow-core/tensorflow-core-api/build.sh @@ -2,6 +2,10 @@ # Script to build native TensorFlow libraries set -eu +if [ ! -f .tf_configure.bazelrc ]; then + echo "WARNING: No .tf_configure.bazelrc, using CI settings. For local builds, run the ./configure script." >&2 +fi + # Allows us to use ccache with Bazel on Mac export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 diff --git a/tensorflow-core/tensorflow-core-api/configure b/tensorflow-core/tensorflow-core-api/configure new file mode 100644 index 00000000000..c1d53eb78af --- /dev/null +++ b/tensorflow-core/tensorflow-core-api/configure @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# +# /* 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. +# ==============================================================================*/ +# +set -e + +bazel fetch @org_tensorflow//- || true + +BASE=$(bazel info output_base) +/mnt/c/Users/jimne/_bazel_Ryan/drtzmoke/external/org_tensorflow/configure +mv /mnt/c/Users/jimne/_bazel_Ryan/drtzmoke/external/org_tensorflow/.tf_configure.bazelrc . +#"$BASE"/external/org_tensorflow/configure \ No newline at end of file diff --git a/tensorflow-core/tensorflow-core-api/configure.cmd b/tensorflow-core/tensorflow-core-api/configure.cmd new file mode 100644 index 00000000000..6f9acd15f9a --- /dev/null +++ b/tensorflow-core/tensorflow-core-api/configure.cmd @@ -0,0 +1,9 @@ +@echo off + +bazel fetch @org_tensorflow//- + +for /f %%i in ('bazel info output_base') do set VAR=%%i + +CALL %VAR%\\external\\org_tensorflow\\configure.cmd + +MOVE %VAR%\\external\\org_tensorflow\\.tf_configure.bazelrc . \ No newline at end of file From 67670cc31966f0f869d6d5711d5855640aef426c Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Mon, 8 Mar 2021 21:44:35 -0800 Subject: [PATCH 2/5] Remove testing hardcoded paths Signed-off-by: Ryan Nett --- tensorflow-core/tensorflow-core-api/configure | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tensorflow-core/tensorflow-core-api/configure b/tensorflow-core/tensorflow-core-api/configure index c1d53eb78af..608b043fea3 100644 --- a/tensorflow-core/tensorflow-core-api/configure +++ b/tensorflow-core/tensorflow-core-api/configure @@ -21,6 +21,5 @@ set -e bazel fetch @org_tensorflow//- || true BASE=$(bazel info output_base) -/mnt/c/Users/jimne/_bazel_Ryan/drtzmoke/external/org_tensorflow/configure -mv /mnt/c/Users/jimne/_bazel_Ryan/drtzmoke/external/org_tensorflow/.tf_configure.bazelrc . -#"$BASE"/external/org_tensorflow/configure \ No newline at end of file +"$BASE"/external/org_tensorflow/configure +mv "$BASE"/external/org_tensorflow/.tf_configure.bazelrc . From 477d82fb425d79ebb0014c535be65db2653e77eb Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Mon, 8 Mar 2021 21:47:13 -0800 Subject: [PATCH 3/5] Undo patch removal Signed-off-by: Ryan Nett --- tensorflow-core/tensorflow-core-api/WORKSPACE | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tensorflow-core/tensorflow-core-api/WORKSPACE b/tensorflow-core/tensorflow-core-api/WORKSPACE index cb2de293fd5..bd5ce478f66 100644 --- a/tensorflow-core/tensorflow-core-api/WORKSPACE +++ b/tensorflow-core/tensorflow-core-api/WORKSPACE @@ -7,6 +7,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # the version of this archive (e.g. google protobuf) http_archive( name = "org_tensorflow", + patches = [ + ":tensorflow-visibility.patch", + ":tensorflow-macosx.patch", +# ":tensorflow-windows.patch", # https://github.com/tensorflow/tensorflow/issues/25213 + ":tensorflow-proto.patch", + ], + patch_tool = "patch", + patch_args = ["-p1"], + patch_cmds = ["grep -rl 'java_package' tensorflow/core | xargs sed -i.bak 's/^\(.* java_package = \"org\.tensorflow\.\)\(.*\"\)/\\1proto.\\2'/"], urls = [ "https://github.com/tensorflow/tensorflow/archive/v2.4.1.tar.gz", ], From 79ea7dbecced2c2f2214b319edd33b90a7db6015 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Tue, 9 Mar 2021 13:51:38 -0800 Subject: [PATCH 4/5] Update copyright, no warning prefix Signed-off-by: Ryan Nett --- tensorflow-core/tensorflow-core-api/build.sh | 2 +- tensorflow-core/tensorflow-core-api/configure | 4 ++-- .../tensorflow-core-api/configure.cmd | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tensorflow-core/tensorflow-core-api/build.sh b/tensorflow-core/tensorflow-core-api/build.sh index f6c01c093d5..947d10f4988 100755 --- a/tensorflow-core/tensorflow-core-api/build.sh +++ b/tensorflow-core/tensorflow-core-api/build.sh @@ -3,7 +3,7 @@ set -eu if [ ! -f .tf_configure.bazelrc ]; then - echo "WARNING: No .tf_configure.bazelrc, using CI settings. For local builds, run the ./configure script." >&2 + echo "No .tf_configure.bazelrc, using CI settings. For local builds, run the ./configure script." fi # Allows us to use ccache with Bazel on Mac diff --git a/tensorflow-core/tensorflow-core-api/configure b/tensorflow-core/tensorflow-core-api/configure index 608b043fea3..f52079bc55b 100644 --- a/tensorflow-core/tensorflow-core-api/configure +++ b/tensorflow-core/tensorflow-core-api/configure @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# /* Copyright 2021 The TensorFlow Authors. All Rights Reserved. +# 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. @@ -14,7 +14,7 @@ # 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. -# ==============================================================================*/ +# ============================================================================== # set -e diff --git a/tensorflow-core/tensorflow-core-api/configure.cmd b/tensorflow-core/tensorflow-core-api/configure.cmd index 6f9acd15f9a..15c5cc12b8c 100644 --- a/tensorflow-core/tensorflow-core-api/configure.cmd +++ b/tensorflow-core/tensorflow-core-api/configure.cmd @@ -1,5 +1,22 @@ @echo off +:: +:: 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. +:: ============================================================================== +:: + bazel fetch @org_tensorflow//- for /f %%i in ('bazel info output_base') do set VAR=%%i From a4c71fe8977d223e0fead369dcfe5b256abba740 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sun, 11 Apr 2021 14:52:59 -0700 Subject: [PATCH 5/5] Use same bazel version as the CI Signed-off-by: Ryan Nett --- tensorflow-core/tensorflow-core-api/.bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow-core/tensorflow-core-api/.bazelversion b/tensorflow-core/tensorflow-core-api/.bazelversion index 47b6be3fafe..a0cd9f0ccb0 100644 --- a/tensorflow-core/tensorflow-core-api/.bazelversion +++ b/tensorflow-core/tensorflow-core-api/.bazelversion @@ -1 +1 @@ -3.7.2 \ No newline at end of file +3.1.0 \ No newline at end of file