aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/framework
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-13 00:33:03 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-13 00:38:00 -0700
commit7f3938deb393f7688cd364b630afdd9338460299 (patch)
treed972bc7e82f5dea8f71354ae8a4bb8197b75c7af /tensorflow/python/framework
parent626bc997c28e1dfeaa85041e6c5a057fec7e0a02 (diff)
[TF] Update strings to run on device:CPU
/cpu is an old style and can be misleading for new people trying to specify other devices. Also correct comparison in tensorflow/python/client/timeline_test.py PiperOrigin-RevId: 212769480
Diffstat (limited to 'tensorflow/python/framework')
-rw-r--r--tensorflow/python/framework/test_util.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/tensorflow/python/framework/test_util.py b/tensorflow/python/framework/test_util.py
index 1cc3bb4628..b7398238f5 100644
--- a/tensorflow/python/framework/test_util.py
+++ b/tensorflow/python/framework/test_util.py
@@ -779,7 +779,7 @@ def run_in_graph_and_eager_modes(func=None,
def run_eagerly(self, **kwargs):
if not use_gpu:
- with ops.device("/cpu:0"):
+ with ops.device("/device:CPU:0"):
f(self, **kwargs)
else:
f(self, **kwargs)
@@ -1839,7 +1839,7 @@ class TensorFlowTestCase(googletest.TestCase):
elif use_gpu:
yield sess
else:
- with sess.graph.device("/cpu:0"):
+ with sess.graph.device("/device:CPU:0"):
yield sess
def _create_session(self, graph, config, force_gpu):
@@ -1854,12 +1854,18 @@ class TensorFlowTestCase(googletest.TestCase):
Returns:
A config_pb2.ConfigProto object.
"""
+ # TODO(b/114333779): Enforce allow_soft_placement=False when
+ # use_gpu=False. Currently many tests rely on the fact that any device
+ # will be used even when a specific device is supposed to be used.
+ allow_soft_placement = not force_gpu
if config is None:
config = config_pb2.ConfigProto()
- config.allow_soft_placement = not force_gpu
+ config.allow_soft_placement = allow_soft_placement
config.gpu_options.per_process_gpu_memory_fraction = 0.3
- elif force_gpu and config.allow_soft_placement:
- config = config_pb2.ConfigProto().CopyFrom(config)
+ elif not allow_soft_placement and config.allow_soft_placement:
+ config_copy = config_pb2.ConfigProto()
+ config_copy.CopyFrom(config)
+ config = config_copy
config.allow_soft_placement = False
# Don't perform optimizations for tests so we don't inadvertently run
# gpu ops on cpu