aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/grappler
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <bsteiner@google.com>2018-02-22 12:18:39 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-22 12:24:17 -0800
commit51b334875125b1e76545d02d2e8e18c7ff2be0af (patch)
treeccce37a3e5dda8cb3bb0a6ab989ab8e09b683523 /tensorflow/python/grappler
parente2a9276d485ab3c3b5b0ebfbc92fc105cfa7419f (diff)
Measure the performance of the original placement to ensure that we preserve it
in case the placer isn't given enough time to find a better solution. PiperOrigin-RevId: 186655094
Diffstat (limited to 'tensorflow/python/grappler')
-rw-r--r--tensorflow/python/grappler/graph_placer.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tensorflow/python/grappler/graph_placer.py b/tensorflow/python/grappler/graph_placer.py
index 2cc3536792..1cd51df4d9 100644
--- a/tensorflow/python/grappler/graph_placer.py
+++ b/tensorflow/python/grappler/graph_placer.py
@@ -68,6 +68,16 @@ def PlaceGraph(metagraph,
item = gitem.Item(optimized_metagraph)
+ # Measure the runtime achievable with the original placement.
+ try:
+ _, original_run_time, _ = cluster.MeasureCosts(item)
+ if verbose:
+ print("Runtime for original placement: " + str(original_run_time))
+ except errors.OpError as e:
+ if verbose:
+ print("Original placement isn't feasible: " + str(e))
+ original_run_time = hparams.failing_signal
+
if hparams is None:
hparams = hierarchical_controller.hierarchical_controller_hparams()
# We run with a single child
@@ -98,7 +108,7 @@ def PlaceGraph(metagraph,
print("Failed to run graph:" + str(e))
run_time = hparams.failing_signal
updated = model.update_reward(sess, run_time, verbose=verbose)
- if updated:
+ if updated and run_time < original_run_time:
if verbose:
print("Found better placement, with runtime " + str(run_time))
model.export_placement(metagraph)