aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/platform
diff options
context:
space:
mode:
authorGravatar Anna R <annarev@google.com>2018-05-02 17:41:26 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-05-02 17:44:23 -0700
commit7833890a0da5226e4c409b1020155f1718c0edb2 (patch)
tree2fcf1ab9d70f4cf9fe4f956f02815301a1413af3 /tensorflow/python/platform
parenta1ef905926d12b0362c0dcf6d669e1c3d2ffcf70 (diff)
Add a collect_trace option to run_op_benchmark for cases when callers just want
to pass RunOptions.FULL_TRACE but don't want to store trace in extras. PiperOrigin-RevId: 195181533
Diffstat (limited to 'tensorflow/python/platform')
-rw-r--r--tensorflow/python/platform/benchmark.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tensorflow/python/platform/benchmark.py b/tensorflow/python/platform/benchmark.py
index 12dae94a64..eba2baaf6f 100644
--- a/tensorflow/python/platform/benchmark.py
+++ b/tensorflow/python/platform/benchmark.py
@@ -213,9 +213,10 @@ class TensorFlowBenchmark(Benchmark):
burn_iters: Number of burn-in iterations to run.
min_iters: Minimum number of iterations to use for timing.
store_trace: Boolean, whether to run an extra untimed iteration and
- store the trace of iteration in the benchmark report.
+ store the trace of iteration in returned extras.
The trace will be stored as a string in Google Chrome trace format
- in the extras field "full_trace_chrome_format".
+ in the extras field "full_trace_chrome_format". Note that trace
+ will not be stored in test_log_pb2.TestResults proto.
store_memory_usage: Boolean, whether to run an extra untimed iteration,
calculate memory usage, and store that in extras fields.
name: (optional) Override the BenchmarkEntry name with `name`.
@@ -227,7 +228,9 @@ class TensorFlowBenchmark(Benchmark):
Returns:
A `dict` containing the key-value pairs that were passed to
- `report_benchmark`.
+ `report_benchmark`. If `store_trace` option is used, then
+ `full_chrome_trace_format` will be included in return dictionary even
+ though it is not passed to `report_benchmark` with `extras`.
"""
for _ in range(burn_iters):
sess.run(op_or_tensor, feed_dict=feed_dict)
@@ -242,6 +245,7 @@ class TensorFlowBenchmark(Benchmark):
deltas[i] = delta
extras = extras if extras is not None else {}
+ unreported_extras = {}
if store_trace or store_memory_usage:
run_options = config_pb2.RunOptions(
trace_level=config_pb2.RunOptions.FULL_TRACE)
@@ -251,7 +255,8 @@ class TensorFlowBenchmark(Benchmark):
tl = timeline.Timeline(run_metadata.step_stats)
if store_trace:
- extras["full_trace_chrome_format"] = tl.generate_chrome_trace_format()
+ unreported_extras["full_trace_chrome_format"] = (
+ tl.generate_chrome_trace_format())
if store_memory_usage:
step_stats_analysis = tl.analyze_step_stats(show_memory=True)
@@ -277,6 +282,7 @@ class TensorFlowBenchmark(Benchmark):
"throughput": mbs / median_delta
}
self.report_benchmark(**benchmark_values)
+ benchmark_values["extras"].update(unreported_extras)
return benchmark_values