1
- From 1abbffd2c9892a1f9d0b12b48345a3bf256fdbe8 Mon Sep 17 00:00:00 2001
1
+ From 3e40415231d65c1dc8017f99790898523b659501 Mon Sep 17 00:00:00 2001
2
2
From: Mohaned Qunaibit <
[email protected] >
3
- Date: Mon, 2 Oct 2023 01:09:28 +0300
3
+ Date: Sun, 8 Oct 2023 15:53:04 +0300
4
4
Subject: [PATCH] patch tensorflow 2.14.0
5
5
6
6
---
7
- .tf_configure.bazelrc | 8 +
8
7
WORKSPACE | 7 +-
9
- graalpy_build.py | 252 ++++++++++++++++++
10
- graalpy_patch.py | 120 +++++++++
11
- pyproject.toml | 49 ++++
12
- requirements_lock_3_10.txt | 6 +-
8
+ graalpy_build.py | 253 ++++++++++++++++++
9
+ graalpy_patch.py | 105 ++++++++
10
+ pyproject.toml | 50 ++++
13
11
rules_python-0.23.1.patch | 182 +++++++++++++
14
12
.../python/client/tf_session_wrapper.cc | 4 +-
15
13
tensorflow/python/eager/pywrap_tfe_src.cc | 11 +-
16
14
tensorflow/python/framework/dtypes.py | 2 +-
17
15
.../python_api_dispatcher_wrapper.cc | 2 +-
18
- tensorflow/python/keras/engine/training.py | 1 +
19
- tensorflow/python/keras/saving/hdf5_format.py | 1 +
20
- tensorflow/python/keras/saving/save.py | 1 +
16
+ tensorflow/python/keras/engine/training.py | 2 +-
17
+ tensorflow/python/keras/saving/hdf5_format.py | 2 +-
18
+ tensorflow/python/keras/saving/save.py | 2 +-
21
19
.../tools/api/generator/create_python_api.py | 2 +-
22
20
tensorflow/python/util/module_wrapper.py | 55 +++-
23
21
tensorflow/tools/git/gen_git_source.py | 3 +-
24
22
tensorflow/tools/pip_package/setup.py | 2 +-
25
23
.../devel.usertools/squash_testlogs.py | 13 +-
26
24
.../tools/toolchains/python/python_repo.bzl | 7 +-
27
25
tensorflow/workspace2.bzl | 6 +-
28
- tf_build_backend.py | 55 ++++
26
+ tf_build_backend.py | 57 ++++
29
27
third_party/protobuf/protobuf.patch | 2 +-
30
28
third_party/repo.bzl | 8 +-
31
- tox.ini | 10 +
32
- 25 files changed, 782 insertions(+), 27 deletions(-)
33
- create mode 100644 .tf_configure.bazelrc
29
+ 22 files changed, 749 insertions(+), 28 deletions(-)
34
30
create mode 100644 graalpy_build.py
35
31
create mode 100644 graalpy_patch.py
36
32
create mode 100644 pyproject.toml
37
33
create mode 100644 rules_python-0.23.1.patch
38
34
create mode 100644 tf_build_backend.py
39
- create mode 100644 tox.ini
40
35
41
- diff --git a/.tf_configure.bazelrc b/.tf_configure.bazelrc
42
- new file mode 100644
43
- index 00000000000..b2add9620ca
44
- --- /dev/null
45
- +++ b/.tf_configure.bazelrc
46
- @@ -0,0 +1,8 @@
47
- + build:opt --copt=-Wno-sign-compare
48
- + build:opt --host_copt=-Wno-sign-compare
49
- + test --flaky_test_attempts=3
50
- + test --test_size_filters=small,medium
51
- + test:v1 --test_tag_filters=-benchmark-test,-no_oss,-gpu,-oss_serial
52
- + test:v1 --build_tag_filters=-benchmark-test,-no_oss,-gpu
53
- + test:v2 --test_tag_filters=-benchmark-test,-no_oss,-gpu,-oss_serial,-v1only
54
- + test:v2 --build_tag_filters=-benchmark-test,-no_oss,-gpu,-v1only
55
36
diff --git a/WORKSPACE b/WORKSPACE
56
37
index fb3af8a2bea..44ddffba73c 100644
57
38
--- a/WORKSPACE
@@ -86,10 +67,10 @@ index fb3af8a2bea..44ddffba73c 100644
86
67
load("@pypi//:requirements.bzl", "install_deps")
87
68
diff --git a/graalpy_build.py b/graalpy_build.py
88
69
new file mode 100644
89
- index 00000000000..b98870582c4
70
+ index 00000000000..3da98203ff8
90
71
--- /dev/null
91
72
+++ b/graalpy_build.py
92
- @@ -0,0 +1,252 @@
73
+ @@ -0,0 +1,253 @@
93
74
+
94
75
+ import subprocess
95
76
+ import os
@@ -281,6 +262,7 @@ index 00000000000..b98870582c4
281
262
+ if os.environ.get('PYTHONNOUSERSITE', '0') == '1':
282
263
+ add_isolated_sites(os.environ, lib_dirs)
283
264
+
265
+ + # Site-packages are mostly needed for `rules_python`'s builtin packages
284
266
+ VENV_SITE_PACKAGES = os.pathsep.join(lib_dirs)
285
267
+
286
268
+ if not args.no_all:
@@ -345,10 +327,10 @@ index 00000000000..b98870582c4
345
327
\ No newline at end of file
346
328
diff --git a/graalpy_patch.py b/graalpy_patch.py
347
329
new file mode 100644
348
- index 00000000000..a4330468cc8
330
+ index 00000000000..728d8a8863a
349
331
--- /dev/null
350
332
+++ b/graalpy_patch.py
351
- @@ -0,0 +1,120 @@
333
+ @@ -0,0 +1,105 @@
352
334
+ try:
353
335
+ import __graalpython__
354
336
+ except:
@@ -357,22 +339,11 @@ index 00000000000..a4330468cc8
357
339
+
358
340
+
359
341
+ import sys
342
+ + import os
360
343
+
361
344
+ if sys.prefix == sys.base_prefix:
362
345
+ raise SystemError('Running in virtualenv is required!')
363
346
+
364
- +
365
- + # ATTENTION: GraalPy uses existence of this module to verify that it is
366
- + # running a patched pip in pip_hook.py
367
- + import os
368
- + import re
369
- + from pathlib import Path
370
- + from urllib.parse import urlparse
371
- +
372
- + from pip._vendor import tomli
373
- + from pip._vendor.packaging.specifiers import SpecifierSet
374
- + from pip._vendor.packaging.version import VERSION_PATTERN
375
- +
376
347
+ PATCHES_BASE_DIR = os.path.join(__graalpython__.core_home, "patches")
377
348
+
378
349
+ patch_dict = {
@@ -456,26 +427,23 @@ index 00000000000..a4330468cc8
456
427
+ import autopatch_capi
457
428
+ autopatch_capi.auto_patch_tree(location)
458
429
+
459
- + def print_entry(strip_prefix):
460
- + print('"%s": ""' % strip_prefix)
461
- +
462
- +
430
+ + # There are couple of parts that have been taken from the pip installer patch
463
431
+ def main():
464
432
+ target_dir = sys.argv[1]
465
433
+ target_strip_prefix = sys.argv[2]
466
434
+ find_patch(target_dir, target_strip_prefix)
467
435
+ autopatch(target_dir)
468
- + # print_entry(target_strip_prefix)
469
436
+
470
437
+ if __name__ == '__main__':
471
438
+ main()
472
439
diff --git a/pyproject.toml b/pyproject.toml
473
440
new file mode 100644
474
- index 00000000000..0a08c9d062a
441
+ index 00000000000..841b726f3fe
475
442
--- /dev/null
476
443
+++ b/pyproject.toml
477
- @@ -0,0 +1,49 @@
444
+ @@ -0,0 +1,50 @@
478
445
+ [build-system]
446
+ + # These requirements are needed to cached wheels during bazel build.
479
447
+ requires = [
480
448
+ "setuptools",
481
449
+ "packaging",
@@ -524,30 +492,6 @@ index 00000000000..0a08c9d062a
524
492
+ ]
525
493
+ build-backend = "tf_build_backend"
526
494
+ backend-path = ["."]
527
- diff --git a/requirements_lock_3_10.txt b/requirements_lock_3_10.txt
528
- index 55b56f40b32..d2d3303a33d 100644
529
- --- a/requirements_lock_3_10.txt
530
- +++ b/requirements_lock_3_10.txt
531
- @@ -97,7 +97,8 @@ google-auth-oauthlib==1.0.0 \
532
- --hash=sha256:95880ca704928c300f48194d1770cf5b1462835b6e49db61445a520f793fd5fb \
533
- --hash=sha256:e375064964820b47221a7e1b7ee1fd77051b6323c3f9e3e19785f78ab67ecfc5
534
- # via tensorboard
535
- - grpcio==1.57.0 \
536
- + grpcio==1.56.2 \
537
- + --hash=sha256:0ff789ae7d8ddd76d2ac02e7d13bfef6fc4928ac01e1dcaa182be51b6bcc0aaa \
538
- --hash=sha256:00258cbe3f5188629828363ae8ff78477ce976a6f63fb2bb5e90088396faa82e \
539
- --hash=sha256:092fa155b945015754bdf988be47793c377b52b88d546e45c6a9f9579ac7f7b6 \
540
- --hash=sha256:0f80bf37f09e1caba6a8063e56e2b87fa335add314cf2b78ebf7cb45aa7e3d06 \
541
- @@ -146,7 +147,8 @@ grpcio==1.57.0 \
542
- # via
543
- # -r ./requirements.in
544
- # tensorboard
545
- - h5py==3.9.0 \
546
- + h5py==2.10.0 \
547
- + --hash=sha256:84412798925dc870ffd7107f045d7659e60f5d46d1c70c700375248bf6bf512d \
548
- --hash=sha256:12aa556d540f11a2cae53ea7cfb94017353bd271fb3962e1296b342f6550d1b8 \
549
- --hash=sha256:23e74b878bbe1653ab34ca49b83cac85529cd0b36b9d625516c5830cc5ca2eac \
550
- --hash=sha256:36408f8c62f50007d14e000f9f3acf77e103b9e932c114cbe52a3089e50ebf94 \
551
495
diff --git a/rules_python-0.23.1.patch b/rules_python-0.23.1.patch
552
496
new file mode 100644
553
497
index 00000000000..cb8c98b661b
@@ -821,41 +765,44 @@ index d3f688578a7..071fadb1e45 100644
821
765
throw py::type_error("`*py_classes` must be a tuple of types.");
822
766
}
823
767
diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py
824
- index 1e94ca45aef..004c9ad5b49 100644
768
+ index 1e94ca45aef..8adcb4f99c0 100644
825
769
--- a/tensorflow/python/keras/engine/training.py
826
770
+++ b/tensorflow/python/keras/engine/training.py
827
- @@ -83,6 +83,7 @@ from tensorflow.tools.docs import doc_controls
771
+ @@ -83,7 +83,7 @@ from tensorflow.tools.docs import doc_controls
828
772
829
773
# pylint: disable=g-import-not-at-top
830
774
try:
831
- + raise ImportError
832
- import h5py
775
+ - import h5py
776
+ + raise ImportError; import h5py
833
777
except ImportError:
834
778
h5py = None
779
+ # pylint: enable=g-import-not-at-top
835
780
diff --git a/tensorflow/python/keras/saving/hdf5_format.py b/tensorflow/python/keras/saving/hdf5_format.py
836
- index 1f6bbc43320..a0085d001cc 100644
781
+ index 1f6bbc43320..61edd5143b9 100644
837
782
--- a/tensorflow/python/keras/saving/hdf5_format.py
838
783
+++ b/tensorflow/python/keras/saving/hdf5_format.py
839
- @@ -34,6 +34,7 @@ from tensorflow.python.platform import tf_logging as logging
784
+ @@ -34,7 +34,7 @@ from tensorflow.python.platform import tf_logging as logging
840
785
841
786
# pylint: disable=g-import-not-at-top
842
787
try:
843
- + raise ImportError
844
- import h5py
788
+ - import h5py
789
+ + raise ImportError; import h5py
845
790
HDF5_OBJECT_HEADER_LIMIT = 64512
846
791
except ImportError:
792
+ h5py = None
847
793
diff --git a/tensorflow/python/keras/saving/save.py b/tensorflow/python/keras/saving/save.py
848
- index eee859233e5..4bdddc307a5 100644
794
+ index eee859233e5..eee6eb3093c 100644
849
795
--- a/tensorflow/python/keras/saving/save.py
850
796
+++ b/tensorflow/python/keras/saving/save.py
851
- @@ -25,6 +25,7 @@ from tensorflow.python.keras.utils.io_utils import path_to_string
797
+ @@ -25,7 +25,7 @@ from tensorflow.python.keras.utils.io_utils import path_to_string
852
798
853
799
# pylint: disable=g-import-not-at-top
854
800
try:
855
- + raise ImportError
856
- import h5py
801
+ - import h5py
802
+ + raise ImportError; import h5py
857
803
except ImportError:
858
804
h5py = None
805
+ # pylint: enable=g-import-not-at-top
859
806
diff --git a/tensorflow/python/tools/api/generator/create_python_api.py b/tensorflow/python/tools/api/generator/create_python_api.py
860
807
index 742cc879d0e..cdc65b36473 100644
861
808
--- a/tensorflow/python/tools/api/generator/create_python_api.py
@@ -1049,10 +996,10 @@ index 7e9faa558a4..d4ace12a6a6 100644
1049
996
# LINT.IfChange
1050
997
diff --git a/tf_build_backend.py b/tf_build_backend.py
1051
998
new file mode 100644
1052
- index 00000000000..57118801ae9
999
+ index 00000000000..7da2ad7c9ee
1053
1000
--- /dev/null
1054
1001
+++ b/tf_build_backend.py
1055
- @@ -0,0 +1,55 @@
1002
+ @@ -0,0 +1,57 @@
1056
1003
+ import os
1057
1004
+ import re
1058
1005
+ import sys
@@ -1069,6 +1016,8 @@ index 00000000000..57118801ae9
1069
1016
+ SUB_VENV_PYTHON = SUB_VENV_BIN / 'python3'
1070
1017
+
1071
1018
+ def setup_venv():
1019
+ + # During the installation process `pip` isn't available to use,
1020
+ + # So, we create a new environment to have access for fresh `pip` during bazel build.
1072
1021
+ if not os.path.isdir(SUB_VENV_PATH):
1073
1022
+ venv.create(SUB_VENV_PATH, with_pip=True)
1074
1023
+ print('Using virtual env in:\n\t' + str(SUB_VENV_PATH))
@@ -1155,22 +1104,6 @@ index 226f8799392..6d7b830eb2b 100644
1155
1104
"mirror.tensorflow.org",
1156
1105
"mirror.bazel.build",
1157
1106
"storage.googleapis.com",
1158
- diff --git a/tox.ini b/tox.ini
1159
- new file mode 100644
1160
- index 00000000000..cb73413d28d
1161
- --- /dev/null
1162
- +++ b/tox.ini
1163
- @@ -0,0 +1,10 @@
1164
- + [tox]
1165
- + isolated_build = true
1166
- + [testenv]
1167
- + commands =
1168
- + graalpylibtest: python3 graalpy_build.py --j 16 --max-memory 32 --test
1169
- + !graalpylibtest: bazel test -j 16 --config=opt -k //tensorflow/python/...
1170
- + deps = pytest
1171
- + mock
1172
- + !graalpylibtest: -rtensorflow/tools/ci_build/release/requirements_ubuntu.txt
1173
- + !graalpylibtest: -rtensorflow/tools/ci_build/release/requirements_common.txt
1174
1107
- -
1175
1108
2.25.1
1176
1109
0 commit comments