diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-09-08 17:30:55 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-09-08 17:34:54 -0700 |
commit | b76565b39dc23116d8f6c2593d213ce9e0b0d413 (patch) | |
tree | a022fbe276a9d41ab3211b4a462865c5eb8a58a4 /tensorflow/python/profiler | |
parent | 0753b0c79054aa848e8b9eabe486b9d221da2894 (diff) |
Some profiler fixes and cleanup.
PiperOrigin-RevId: 168069346
Diffstat (limited to 'tensorflow/python/profiler')
5 files changed, 11 insertions, 7 deletions
diff --git a/tensorflow/python/profiler/internal/run_metadata_test.py b/tensorflow/python/profiler/internal/run_metadata_test.py index 1e26a9897e..c0de08cad6 100644 --- a/tensorflow/python/profiler/internal/run_metadata_test.py +++ b/tensorflow/python/profiler/internal/run_metadata_test.py @@ -70,6 +70,7 @@ def _run_model(): opts = builder.time_and_memory() opts['min_micros'] = 0 opts['min_bytes'] = 0 + opts['order_by'] = 'name' opts['output'] = 'none' _ = sess.run(y, options=config_pb2.RunOptions( @@ -95,6 +96,7 @@ def _run_loop_model(): run_metadata=run_meta) opts = builder.time_and_memory() + opts['order_by'] = 'name' opts['output'] = 'none' tfprof_node = model_analyzer.profile( diff --git a/tensorflow/python/profiler/model_analyzer.py b/tensorflow/python/profiler/model_analyzer.py index 98d3e58f2a..2071325c7b 100644 --- a/tensorflow/python/profiler/model_analyzer.py +++ b/tensorflow/python/profiler/model_analyzer.py @@ -180,8 +180,7 @@ class Profiler(object): """ # pylint: disable=protected-access op_log = tfprof_logger._merge_default_with_oplog( - self._graph, run_meta=run_meta, add_trace=False, - add_trainable_var=False) + self._graph, run_meta=run_meta) # pylint: enable=protected-access # TODO(xpan): P1: Better to find the current graph. print_mdl.AddStep( diff --git a/tensorflow/python/profiler/model_analyzer_test.py b/tensorflow/python/profiler/model_analyzer_test.py index dcdda1ffa2..494ba2e2a0 100644 --- a/tensorflow/python/profiler/model_analyzer_test.py +++ b/tensorflow/python/profiler/model_analyzer_test.py @@ -305,7 +305,7 @@ class PrintModelAnalysisTest(test.TestCase): _ = model_analyzer.profile( sess.graph, run_meta, cmd='graph', options=opts) - with gfile.Open(outfile, 'r') as f: + with gfile.Open(outfile + '_0', 'r') as f: # Test that a json file is created. # TODO(xpan): tfprof Timeline isn't quite correct on Windows. # Investigate why. diff --git a/tensorflow/python/profiler/option_builder.py b/tensorflow/python/profiler/option_builder.py index 641895ffe5..13942ad6a2 100644 --- a/tensorflow/python/profiler/option_builder.py +++ b/tensorflow/python/profiler/option_builder.py @@ -177,7 +177,7 @@ class ProfileOptionBuilder(object): 'min_params': 0, 'min_float_ops': 0, 'min_occurrence': 0, - 'order_by': 'name', + 'order_by': 'micros', 'account_type_regexes': ['.*'], 'start_name_regexes': ['.*'], 'trim_name_regexes': [], diff --git a/tensorflow/python/profiler/profile_context.py b/tensorflow/python/profiler/profile_context.py index 07adcb9c3f..49fa22e347 100644 --- a/tensorflow/python/profiler/profile_context.py +++ b/tensorflow/python/profiler/profile_context.py @@ -20,6 +20,7 @@ from __future__ import print_function import contextlib import os +import threading from tensorflow.core.protobuf import config_pb2 from tensorflow.python import pywrap_tensorflow as print_mdl @@ -163,6 +164,7 @@ class ProfileContext(object): self._traced_steps = 0 self._auto_profiles = [] self._profiler = None + self._lock = threading.Lock() def add_auto_profiling(self, cmd, options, profile_steps): """Traces and profiles at some session run steps. @@ -181,9 +183,10 @@ class ProfileContext(object): @property def profiler(self): """Returns the current profiler object.""" - if not self._profiler: - self._profiler = model_analyzer.Profiler(ops.get_default_graph()) - return self._profiler + with self._lock: + if not self._profiler: + self._profiler = model_analyzer.Profiler(ops.get_default_graph()) + return self._profiler def trace_next_step(self): """Enables tracing and add traces to profiler at next step.""" |