Skip to content

Commit 2588c83

Browse files
committed
Upgrade Struct2Tensor to use TensorFlow 2.18.1, add ProtoGen patch, and Abseil patch
1 parent 53fcdd7 commit 2588c83

9 files changed

Lines changed: 116 additions & 527 deletions

File tree

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ build:macos --host_cxxopt=-std=c++17
4747
build:short_logs --output_filter=DONT_MATCH_ANYTHING
4848

4949
build:macos --macos_minimum_os=10.12
50+
build --action_env TF_HEADER_DIR="/usr/local/google/home/vkarampudi/anaconda3/envs/3.11/lib/python3.11/site-packages/tensorflow/include"
51+
build --action_env TF_SHARED_LIBRARY_DIR="/usr/local/google/home/vkarampudi/anaconda3/envs/3.11/lib/python3.11/site-packages/tensorflow"
52+
build --action_env TF_SHARED_LIBRARY_NAME="libtensorflow_framework.so.2"

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0

WORKSPACE

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ http_archive(
6060
# 3. Request the new archive to be mirrored on mirror.bazel.build for more
6161
# reliable downloads.
6262

63-
_TENSORFLOW_GIT_COMMIT = "3c92ac03cab816044f7b18a86eb86aa01a294d95" # tf 2.17.1
64-
_TENSORFLOW_ARCHIVE_SHA256 = "317dd95c4830a408b14f3e802698eb68d70d81c7c7cfcd3d28b0ba023fe84a68"
63+
_TENSORFLOW_GIT_COMMIT = "cb64295ec7308f770b22db6047a1e755b35b7bee" # tf 2.18.1
64+
_TENSORFLOW_ARCHIVE_SHA256 = ""
6565

6666
http_archive(
6767
name = "org_tensorflow",
@@ -70,10 +70,19 @@ http_archive(
7070
"https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT,
7171
],
7272
strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT,
73-
patches = ["//third_party:tensorflow.patch"],
74-
patch_args = ["-p1"],
73+
patch_args = ["-p0"],
74+
patches = [
75+
"//third_party:proto_gen.patch",
76+
],
77+
)
78+
local_repository(
79+
name = "local_config_cuda",
80+
path = "third_party/dummy_cuda",
7581
)
7682

83+
84+
85+
7786
load("//third_party:python_configure.bzl", "local_python_configure")
7887
local_python_configure(name = "local_config_python")
7988
local_python_configure(name = "local_execution_config_python")
@@ -83,6 +92,18 @@ local_python_configure(name = "local_execution_config_python")
8392
load("//struct2tensor:workspace.bzl", "struct2tensor_workspace")
8493
struct2tensor_workspace()
8594

95+
# Overriding com_google_absl to apply local patch for GCC 15 compatibility
96+
http_archive(
97+
name = "com_google_absl",
98+
patch_args = ["-p1"],
99+
patches = ["//third_party:absl.patch"],
100+
sha256 = "aa768256d0567f626334fcbe722f564c40b281518fc8423e2708a308e5f983ea",
101+
strip_prefix = "abseil-cpp-fb3621f4f897824c0dbe0615fa94543df6192f30",
102+
urls = [
103+
"https://github.com/abseil/abseil-cpp/archive/fb3621f4f897824c0dbe0615fa94543df6192f30.zip",
104+
],
105+
)
106+
86107
# Load Protobuf dependencies
87108
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
88109
protobuf_deps()

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ dependencies:
3636
- requests==2.32.5
3737
- rich==14.3.3
3838
- six==1.17.0
39-
- tensorboard==2.17.1
39+
- tensorboard==2.18.1
4040
- tensorboard-data-server==0.7.2
41-
- tensorflow==2.17.1
41+
- tensorflow==2.18.1
4242
- tensorflow-io-gcs-filesystem==0.37.1
4343
- tensorflow-metadata==1.17.3
4444
- termcolor==3.3.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def select_constraint(default, nightly=None, git_master=None):
8181
'numpy>=1.22',
8282
'protobuf>=4.25.2,<6.0.0;python_version>="3.11"',
8383
'protobuf>=4.21.6,<6.0.0;python_version<"3.11"',
84-
'tensorflow>=2.17,<2.18',
84+
'tensorflow>=2.18,<2.19',
8585
'tensorflow-metadata'
8686
+ select_constraint(
8787
default='>=1.17.0,<1.18.0',

struct2tensor/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"""Contains the version string of struct2tensor."""
1616

1717
# Note that setup.py uses this version.
18-
__version__ = '0.49.0.dev'
18+
__version__ = '0.49.0'

third_party/absl.patch

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h
2+
--- a/absl/container/internal/container_memory.h
3+
+++ b/absl/container/internal/container_memory.h
4+
@@ -15,5 +15,6 @@
5+
#ifndef ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_
6+
#define ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_
7+
8+
#include <cassert>
9+
+#include <cstdint>
10+
#include <cstddef>
11+
#include <cstring>

third_party/proto_gen.patch

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--- third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl
2+
+++ third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl
3+
@@ -4,1 +4,1 @@
4+
-load("@com_google_protobuf//:protobuf.bzl", "proto_gen")
5+
+# Removed load of missing proto_gen
6+
@@ -848,2 +848,45 @@
7+
def tf_cuda_libdevice_path_deps():
8+
return tf_platform_deps("cuda_libdevice_path")
9+
+def proto_gen_disabled(name, srcs = [], outs = [], gen_cc = 0, includes = [], **kwargs):
10+
+ pass
11+
+def proto_gen(name, srcs = [], outs = [], gen_cc = 0, includes = [], **kwargs):
12+
+ if not srcs:
13+
+ native.filegroup(name = name, srcs = kwargs.get("deps", []))
14+
+ return
15+
+ protoc = "@com_google_protobuf//:protoc"
16+
+ pkg = native.package_name()
17+
+ cmd = ""
18+
+ for s in srcs:
19+
+ if type(s) == "string" and s.startswith(":"):
20+
+ loc = "$(location " + s + ")"
21+
+ else:
22+
+ loc = "$(locations " + s + ")"
23+
+ cmd += "for f in " + loc + "; do "
24+
+ cmd += "rel=\"$$f\"; "
25+
+ cmd += "if [[ \"$$f\" == external/org_tensorflow/third_party/xla/* ]]; then rel=\"$${f#external/org_tensorflow/third_party/xla/}\"; repo=\"external/org_tensorflow/third_party/xla\"; "
26+
+ cmd += "elif [[ \"$$f\" == external/org_tensorflow/* ]]; then rel=\"$${f#external/org_tensorflow/}\"; repo=\"external/org_tensorflow\"; "
27+
+ cmd += "elif [[ \"$$f\" == external/local_tsl/* ]]; then rel=\"$${f#external/local_tsl/}\"; repo=\"external/local_tsl\"; "
28+
+ cmd += "elif [[ \"$$f\" == external/local_xla/* ]]; then rel=\"$${f#external/local_xla/}\"; repo=\"external/local_xla\"; "
29+
+ cmd += "else rel=\"$$f\"; repo=\".\"; fi; "
30+
+ cmd += "h_file=\"$${rel%.proto}.pb.h\"; "
31+
+ cmd += "cc_file=\"$${rel%.proto}.pb.cc\"; "
32+
+ cmd += "mkdir -p \"$(RULEDIR)/$$(dirname \"$$rel\")\"; "
33+
+ cmd += "$(location " + protoc + ") -I$$repo -I. -Iexternal/org_tensorflow -Iexternal/local_tsl -Iexternal/local_xla -Iexternal/org_tensorflow/third_party/xla -Iexternal/com_google_protobuf/src --cpp_out=$(RULEDIR) $$rel; "
34+
+ cmd += "if [[ -n \"" + pkg + "\" ]]; then "
35+
+ cmd += " if [[ \"$(RULEDIR)/$$h_file\" != \"$(RULEDIR)/$${h_file#\"" + pkg + "\"/}\" ]]; then mv \"$(RULEDIR)/$$h_file\" \"$(RULEDIR)/$${h_file#\"" + pkg + "\"/}\"; fi; "
36+
+ cmd += " if [[ \"$(RULEDIR)/$$cc_file\" != \"$(RULEDIR)/$${cc_file#\"" + pkg + "\"/}\" ]]; then mv \"$(RULEDIR)/$$cc_file\" \"$(RULEDIR)/$${cc_file#\"" + pkg + "\"/}\"; fi; "
37+
+ cmd += "fi; done; "
38+
+ stripped_outs = []
39+
+ for o in outs:
40+
+ if pkg and o.startswith(pkg + "/"):
41+
+ stripped_outs.append(o[len(pkg)+1:])
42+
+ else:
43+
+ stripped_outs.append(o)
44+
+ native.genrule(
45+
+ name = name,
46+
+ srcs = srcs,
47+
+ outs = stripped_outs,
48+
+ cmd = cmd,
49+
+ tools = [protoc],
50+
+ tags = ["no-sandbox"],
51+
+ )

0 commit comments

Comments
 (0)