aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/profiler
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-11-14 15:33:12 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-11-14 15:37:15 -0800
commit1bc367859c6dc3c3ab17fad25198f9fb25132e2f (patch)
treef786333028c31501f82ec7bf4a7c541339e6187d /tensorflow/core/profiler
parent6357bafeb80523c45bee21a19def146d221cd295 (diff)
A few profiler improvements.
1. Op view proto copy uses too much memory and time, optimized. 2. Add a hint to use "bazel-bin" instead of "bazel run" 3. Make proto string parsing explicit (seems no longer throwing error) PiperOrigin-RevId: 175745677
Diffstat (limited to 'tensorflow/core/profiler')
-rw-r--r--tensorflow/core/profiler/g3doc/profiler_ui.jpgbin220483 -> 190596 bytes
-rw-r--r--tensorflow/core/profiler/internal/tfprof_op.cc18
-rw-r--r--tensorflow/core/profiler/profiler.cc13
3 files changed, 19 insertions, 12 deletions
diff --git a/tensorflow/core/profiler/g3doc/profiler_ui.jpg b/tensorflow/core/profiler/g3doc/profiler_ui.jpg
index 36aa94502a..77346e61ae 100644
--- a/tensorflow/core/profiler/g3doc/profiler_ui.jpg
+++ b/tensorflow/core/profiler/g3doc/profiler_ui.jpg
Binary files differ
diff --git a/tensorflow/core/profiler/internal/tfprof_op.cc b/tensorflow/core/profiler/internal/tfprof_op.cc
index c04b0ea0c6..5a8429d489 100644
--- a/tensorflow/core/profiler/internal/tfprof_op.cc
+++ b/tensorflow/core/profiler/internal/tfprof_op.cc
@@ -109,7 +109,6 @@ const ShowMultiNode* TFOp::ShowInternal(const Options& opts,
fprintf(stderr, "Only 'code' view supports pprof output now.\n");
return root_.get();
}
-
if (opts.output_type == kOutput[1] || opts.output_type == kOutput[2]) {
root_->formatted_str = FormatNode(root_.get(), root_.get(), opts);
}
@@ -130,7 +129,6 @@ const ShowMultiNode* TFOp::ShowInternal(const Options& opts,
nodes.push_back(n.second.get());
}
nodes = SortNodes(nodes, opts);
-
// pre keeps track of previous visited node.
OpNode* pre = nullptr;
std::vector<OpNode*> account_nodes;
@@ -166,10 +164,6 @@ const ShowMultiNode* TFOp::ShowInternal(const Options& opts,
(*it)->AddSelfToTotalStats();
if (pre) (*it)->AggregateTotalStats(pre);
}
- if (pre) {
- (*it)->mutable_proto()->add_children()->MergeFrom(pre->proto());
- pre->mutable_proto()->clear_children();
- }
pre = *it;
}
if (opts.account_displayed_op_only) {
@@ -178,11 +172,6 @@ const ShowMultiNode* TFOp::ShowInternal(const Options& opts,
root_->AggregateTotalStats(pre);
}
}
- if (pre) {
- root_->mutable_proto()->add_children()->MergeFrom(pre->proto());
- pre->mutable_proto()->clear_children();
- }
-
if (opts.output_type == kOutput[1] || opts.output_type == kOutput[2]) {
string display_str = FormatLegend(opts);
for (OpNode* node : show_nodes) {
@@ -192,6 +181,13 @@ const ShowMultiNode* TFOp::ShowInternal(const Options& opts,
// TODO(xpan): Is it the right choice?
root_->formatted_str = display_str;
}
+ // Populate the chidren field.
+ auto* pre_pb = root_->mutable_proto();
+ for (auto& show_node : show_nodes) {
+ pre_pb->clear_children();
+ pre_pb->add_children()->Swap(show_node->mutable_proto());
+ pre_pb = pre_pb->mutable_children(0);
+ }
return root_.get();
}
diff --git a/tensorflow/core/profiler/profiler.cc b/tensorflow/core/profiler/profiler.cc
index a5e513aa21..b280242df1 100644
--- a/tensorflow/core/profiler/profiler.cc
+++ b/tensorflow/core/profiler/profiler.cc
@@ -266,7 +266,18 @@ int Run(int argc, char** argv) {
linenoiseSetCompletionCallback(completion);
linenoiseHistoryLoad(".tfprof_history.txt");
- for (char* line = nullptr; (line = linenoise("tfprof> ")) != nullptr;) {
+ bool looped = false;
+ while (true) {
+ char* line = linenoise("tfprof> ");
+ if (line == nullptr) {
+ if (!looped) {
+ fprintf(stderr,
+ "Cannot start interative shell, "
+ "use 'bazel-bin' instead of 'bazel run'.\n");
+ }
+ break;
+ }
+ looped = true;
string line_s = line;
free(line);