ICM PY3 Migration - //tensorflow/compiler [1]

PiperOrigin-RevId: 274077633
This commit is contained in:
Hye Soo Yang 2019-10-10 17:51:47 -07:00 committed by TensorFlower Gardener
parent c3ec575f83
commit 2c1db69b3c
5 changed files with 17 additions and 6 deletions

View File

@ -35,7 +35,7 @@ py_binary(
name = "make_test_graphs", name = "make_test_graphs",
testonly = 1, testonly = 1,
srcs = ["make_test_graphs.py"], srcs = ["make_test_graphs.py"],
python_version = "PY2", python_version = "PY3",
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
"//tensorflow/core:protos_all_py", "//tensorflow/core:protos_all_py",
@ -50,6 +50,7 @@ py_binary(
"//tensorflow/python:session", "//tensorflow/python:session",
"//tensorflow/python:training", "//tensorflow/python:training",
"//tensorflow/python:variables", "//tensorflow/python:variables",
"@six_archive//:six",
], ],
) )

View File

@ -1,3 +1,4 @@
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -22,6 +23,9 @@ import argparse
import os import os
import sys import sys
import six
from six.moves import range
from tensorflow.core.protobuf import saver_pb2 from tensorflow.core.protobuf import saver_pb2
from tensorflow.python.client import session from tensorflow.python.client import session
from tensorflow.python.framework import constant_op from tensorflow.python.framework import constant_op
@ -76,7 +80,7 @@ def tfadd_with_ckpt_saver(out_dir):
# Without the SaverDef, the restore op won't be named correctly. # Without the SaverDef, the restore op won't be named correctly.
saver_file = os.path.join(out_dir, 'test_graph_tfadd_with_ckpt_saver.saver') saver_file = os.path.join(out_dir, 'test_graph_tfadd_with_ckpt_saver.saver')
with open(saver_file, 'wb') as f: with open(saver_file, 'wb') as f:
f.write(saver.as_saver_def().SerializeToString()) f.write(six.ensure_binary(saver.as_saver_def().SerializeToString()))
def tfassert_eq(_): def tfassert_eq(_):
@ -176,7 +180,7 @@ def write_graph(build_graph, out_dir):
build_graph(out_dir) build_graph(out_dir)
filename = os.path.join(out_dir, 'test_graph_%s.pb' % build_graph.__name__) filename = os.path.join(out_dir, 'test_graph_%s.pb' % build_graph.__name__)
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
f.write(g.as_graph_def().SerializeToString()) f.write(six.ensure_binary(g.as_graph_def().SerializeToString()))
def main(_): def main(_):

View File

@ -57,6 +57,7 @@ py_library(
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
deps = [ deps = [
"//third_party/py/numpy", "//third_party/py/numpy",
"@six_archive//:six",
], ],
) )
@ -64,7 +65,7 @@ py_test(
name = "xla_test_test", name = "xla_test_test",
size = "small", size = "small",
srcs = ["xla_test_test.py"], srcs = ["xla_test_test.py"],
python_version = "PY2", python_version = "PY3",
deps = [ deps = [
":xla_test", ":xla_test",
], ],
@ -1298,6 +1299,7 @@ py_library(
"//tensorflow/python:math_ops", "//tensorflow/python:math_ops",
"//tensorflow/python:random_ops", "//tensorflow/python:random_ops",
"//tensorflow/python:variables", "//tensorflow/python:variables",
"@six_archive//:six",
], ],
) )

View File

@ -1,3 +1,4 @@
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -24,6 +25,8 @@ from __future__ import absolute_import
from __future__ import division from __future__ import division
from __future__ import print_function from __future__ import print_function
from six.moves import range
from tensorflow.python.framework import dtypes from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops from tensorflow.python.ops import array_ops

View File

@ -1,3 +1,4 @@
# Lint as: python2, python3
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # Copyright 2018 The TensorFlow Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -19,7 +20,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import numpy as np import numpy as np
from six.moves import xrange # pylint: disable=redefined-builtin from six.moves import range
def ConvertBetweenDataFormats(x, data_format_src, data_format_dst): def ConvertBetweenDataFormats(x, data_format_src, data_format_dst):
@ -69,7 +70,7 @@ _JIT_WARMUP_ITERATIONS = 10
def RunWithWarmup(sess, op_to_run, feed_dict, options=None, run_metadata=None): def RunWithWarmup(sess, op_to_run, feed_dict, options=None, run_metadata=None):
"""Runs a graph a few times to ensure that its clusters are compiled.""" """Runs a graph a few times to ensure that its clusters are compiled."""
for _ in xrange(0, _JIT_WARMUP_ITERATIONS): for _ in range(0, _JIT_WARMUP_ITERATIONS):
sess.run(op_to_run, feed_dict, options=options) sess.run(op_to_run, feed_dict, options=options)
return sess.run( return sess.run(
op_to_run, feed_dict, options=options, run_metadata=run_metadata) op_to_run, feed_dict, options=options, run_metadata=run_metadata)