Skip to content

Commit 768ac15

Browse files
Upgrade to TF 2.7.0. (#650)
* Upgrade to TF 2.7.0. * fix install docs. * fixed import format. * add default to c++14. * Add c++14 in src. * try moving to bazelrc file.
1 parent 05f51c7 commit 768ac15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+366
-18
lines changed

WORKSPACE

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ http_archive(
1212

1313
http_archive(
1414
name = "org_tensorflow",
15-
sha256 = "2023a377a16e5566b8981400af9e8c8e25d3367d82824ffec2b5b6b9c7dba55d",
16-
strip_prefix = "tensorflow-2.5.1",
15+
sha256 = "249b48ddee927801c7a4f8e5442cf1a3c860f6f46b85a2ff7a78b501507dd561",
16+
strip_prefix = "tensorflow-2.7.0",
1717
urls = [
18-
"https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.5.1.zip",
18+
"https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.7.0.zip",
1919
],
2020
)
2121

22+
2223
load("@org_tensorflow//tensorflow:workspace3.bzl", "workspace")
2324

2425
workspace()
@@ -50,3 +51,4 @@ bind(
5051
name = "six",
5152
actual = "@six_archive//:six",
5253
)
54+

configure.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ write_to_bazelrc "build --strategy=Genrule=standalone"
105105
write_to_bazelrc "build --experimental_repo_remote_exec"
106106
write_to_bazelrc "build -c opt"
107107
write_to_bazelrc "build --cxxopt=\"-D_GLIBCXX_USE_CXX11_ABI=0\""
108+
write_to_bazelrc "build --cxxopt=\"-std=c++14\""
108109

109110

110111
if is_windows; then

docs/install.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ TensorFlow Quantum is supported on Python 3.6, 3.7, and 3.8 and depends directly
1717
### Requirements
1818

1919
* pip 19.0 or later (requires `manylinux2010` support)
20-
* [TensorFlow == 2.5.1](https://www.tensorflow.org/install/pip)
20+
* [TensorFlow == 2.4.1](https://www.tensorflow.org/install/pip)
2121

2222
See the [TensorFlow install guide](https://www.tensorflow.org/install/pip) to
2323
set up your Python development environment and an (optional) virtual environment.
@@ -27,7 +27,7 @@ Upgrade `pip` and install TensorFlow
2727
<!-- common_typos_disable -->
2828
<pre class="devsite-click-to-copy">
2929
<code class="devsite-terminal">pip3 install --upgrade pip</code>
30-
<code class="devsite-terminal">pip3 install tensorflow==2.5.1</code>
30+
<code class="devsite-terminal">pip3 install tensorflow==2.4.1</code>
3131
</pre>
3232
<!-- common_typos_enable -->
3333

@@ -43,7 +43,7 @@ Install the latest stable release of TensorFlow Quantum:
4343

4444
Success: TensorFlow Quantum is now installed.
4545

46-
Install the latest nightly version of TensorFlow Quantum:
46+
Nightly builds which might depend on newer version of TensorFlow can be installed with:
4747

4848
<!-- common_typos_disable -->
4949
<pre class="devsite-click-to-copy">
@@ -84,7 +84,7 @@ As noted in the TensorFlow
8484
guide, the <a href="https://bazel.build/" class="external">Bazel</a>
8585
build system will be required.
8686

87-
Our latest source builds use TensorFlow 2.5.1. To ensure compatibility we use `bazel` version 3.7.2. To remove any existing version of Bazel:
87+
Our latest source builds use TensorFlow 2.7.0. To ensure compatibility we use `bazel` version 3.7.2. To remove any existing version of Bazel:
8888

8989
<!-- common_typos_disable -->
9090
<pre class="devsite-click-to-copy">
@@ -122,7 +122,7 @@ Finally, confirm installation of the correct `bazel` version:
122122
### 4. Build TensorFlow from source
123123

124124
Here we adapt instructions from the TensorFlow [build from source](https://www.tensorflow.org/install/source)
125-
guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version&nbsp;2.5.
125+
guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version&nbsp;2.7.0.
126126

127127
Download the
128128
<a href="https://github.com/tensorflow/tensorflow" class="external">TensorFlow source code</a>:
@@ -131,7 +131,7 @@ Download the
131131
<pre class="devsite-click-to-copy">
132132
<code class="devsite-terminal">git clone https://github.com/tensorflow/tensorflow.git</code>
133133
<code class="devsite-terminal">cd tensorflow</code>
134-
<code class="devsite-terminal">git checkout v2.5.1</code>
134+
<code class="devsite-terminal">git checkout v2.7.0</code>
135135
</pre>
136136

137137
Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies:

release/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def finalize_options(self):
5858

5959
# placed as extra to not have required overwrite existing nightly installs if
6060
# they exist.
61-
EXTRA_PACKAGES = ['tensorflow == 2.5.1']
61+
EXTRA_PACKAGES = ['tensorflow == 2.7.0']
6262
CUR_VERSION = '0.6.0'
6363

6464

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ nbconvert==5.6.1
66
nbformat==4.4.0
77
pylint==2.4.4
88
yapf==0.28.0
9-
tensorflow==2.5.1
9+
tensorflow==2.7.0
1010
# Needed for compatibility with cirq program protos.
1111
googleapis-common-protos==1.52.0
1212
google-api-core==1.21.0

tensorflow_quantum/core/ops/BUILD

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ cc_binary(
6969
],
7070
"//conditions:default": [
7171
"-pthread",
72-
"-std=c++11",
72+
"-std=c++14",
7373
"-D_GLIBCXX_USE_CXX11_ABI=0",
7474
],
7575
}),
@@ -132,7 +132,7 @@ cc_binary(
132132
],
133133
"//conditions:default": [
134134
"-pthread",
135-
"-std=c++11",
135+
"-std=c++14",
136136
"-D_GLIBCXX_USE_CXX11_ABI=0",
137137
],
138138
}),
@@ -190,7 +190,7 @@ cc_binary(
190190
],
191191
"//conditions:default": [
192192
"-pthread",
193-
"-std=c++11",
193+
"-std=c++14",
194194
"-D_GLIBCXX_USE_CXX11_ABI=0",
195195
],
196196
}),
@@ -256,7 +256,7 @@ cc_binary(
256256
],
257257
"//conditions:default": [
258258
"-pthread",
259-
"-std=c++11",
259+
"-std=c++14",
260260
"-D_GLIBCXX_USE_CXX11_ABI=0",
261261
],
262262
}),
@@ -284,6 +284,41 @@ cc_library(
284284
name = "parse_context",
285285
srcs = ["parse_context.cc"],
286286
hdrs = ["parse_context.h"],
287+
copts = select({
288+
":windows": [
289+
"/D__CLANG_SUPPORT_DYN_ANNOTATION__",
290+
"/D_USE_MATH_DEFINES",
291+
"/DEIGEN_MPL2_ONLY",
292+
"/DEIGEN_MAX_ALIGN_BYTES=64",
293+
"/DEIGEN_HAS_TYPE_TRAITS=0",
294+
"/DTF_USE_SNAPPY",
295+
"/showIncludes",
296+
"/MD",
297+
"/O2",
298+
"/DNDEBUG",
299+
"/w",
300+
"-DWIN32_LEAN_AND_MEAN",
301+
"-DNOGDI",
302+
"/d2ReducedOptimizeHugeFunctions",
303+
"/arch:AVX",
304+
"/std:c++14",
305+
"-DTENSORFLOW_MONOLITHIC_BUILD",
306+
"/DPLATFORM_WINDOWS",
307+
"/DEIGEN_HAS_C99_MATH",
308+
"/DTENSORFLOW_USE_EIGEN_THREADPOOL",
309+
"/DEIGEN_AVOID_STL_ARRAY",
310+
"/Iexternal/gemmlowp",
311+
"/wd4018",
312+
"/wd4577",
313+
"/DNOGDI",
314+
"/UTF_COMPILE_LIBRARY",
315+
],
316+
"//conditions:default": [
317+
"-pthread",
318+
"-std=c++14",
319+
"-D_GLIBCXX_USE_CXX11_ABI=0",
320+
],
321+
}),
287322
deps = [
288323
":tfq_simulate_utils",
289324
"//tensorflow_quantum/core/proto:pauli_sum_cc_proto",
@@ -333,7 +368,7 @@ cc_binary(
333368
],
334369
"//conditions:default": [
335370
"-pthread",
336-
"-std=c++11",
371+
"-std=c++14",
337372
"-D_GLIBCXX_USE_CXX11_ABI=0",
338373
],
339374
}),
@@ -364,6 +399,41 @@ cc_library(
364399
name = "tfq_simulate_utils",
365400
srcs = ["tfq_simulate_utils.cc"],
366401
hdrs = ["tfq_simulate_utils.h"],
402+
copts = select({
403+
":windows": [
404+
"/D__CLANG_SUPPORT_DYN_ANNOTATION__",
405+
"/D_USE_MATH_DEFINES",
406+
"/DEIGEN_MPL2_ONLY",
407+
"/DEIGEN_MAX_ALIGN_BYTES=64",
408+
"/DEIGEN_HAS_TYPE_TRAITS=0",
409+
"/DTF_USE_SNAPPY",
410+
"/showIncludes",
411+
"/MD",
412+
"/O2",
413+
"/DNDEBUG",
414+
"/w",
415+
"-DWIN32_LEAN_AND_MEAN",
416+
"-DNOGDI",
417+
"/d2ReducedOptimizeHugeFunctions",
418+
"/arch:AVX",
419+
"/std:c++14",
420+
"-DTENSORFLOW_MONOLITHIC_BUILD",
421+
"/DPLATFORM_WINDOWS",
422+
"/DEIGEN_HAS_C99_MATH",
423+
"/DTENSORFLOW_USE_EIGEN_THREADPOOL",
424+
"/DEIGEN_AVOID_STL_ARRAY",
425+
"/Iexternal/gemmlowp",
426+
"/wd4018",
427+
"/wd4577",
428+
"/DNOGDI",
429+
"/UTF_COMPILE_LIBRARY",
430+
],
431+
"//conditions:default": [
432+
"-pthread",
433+
"-std=c++14",
434+
"-D_GLIBCXX_USE_CXX11_ABI=0",
435+
],
436+
}),
367437
deps = [
368438
"@local_config_tf//:libtensorflow_framework",
369439
"@local_config_tf//:tf_header_lib",

tensorflow_quantum/core/ops/batch_util_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515
"""Test parallel Cirq simulations."""
16+
# Remove PYTHONPATH collisions for protobuf.
17+
# pylint: disable=wrong-import-position
18+
import sys
19+
NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x]
20+
sys.path = NEW_PATH
21+
# pylint: enable=wrong-import-position
22+
1623
import numpy as np
1724
import tensorflow as tf
1825
from absl.testing import parameterized

tensorflow_quantum/core/ops/circuit_execution_ops_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515
"""Module to test consistency between Cirq and TFQ circuit execution ops."""
16+
# Remove PYTHONPATH collisions for protobuf.
17+
# pylint: disable=wrong-import-position
18+
import sys
19+
NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x]
20+
sys.path = NEW_PATH
21+
# pylint: enable=wrong-import-position
22+
1623
from unittest import mock
1724
import numpy as np
1825
import tensorflow as tf

tensorflow_quantum/core/ops/cirq_ops_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515
"""Tests for the cirq simulation ops."""
16+
# Remove PYTHONPATH collisions for protobuf.
17+
# pylint: disable=wrong-import-position
18+
import sys
19+
NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x]
20+
sys.path = NEW_PATH
21+
# pylint: enable=wrong-import-position
22+
1623
from unittest import mock
1724
import numpy as np
1825
import tensorflow as tf

tensorflow_quantum/core/ops/math_ops/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cc_binary(
4949
],
5050
"//conditions:default": [
5151
"-pthread",
52-
"-std=c++11",
52+
"-std=c++14",
5353
"-D_GLIBCXX_USE_CXX11_ABI=0",
5454
],
5555
}),

0 commit comments

Comments
 (0)