Output meaningful logs for tf profiler.
PiperOrigin-RevId: 324217592
Change-Id: Iaea30dde65d0acc51a6915e39a58a18983c6e2ef
diff --git a/tensorflow/core/profiler/internal/tfprof_node.h b/tensorflow/core/profiler/internal/tfprof_node.h
index 5b2cd5f..4ce8f20 100644
--- a/tensorflow/core/profiler/internal/tfprof_node.h
+++ b/tensorflow/core/profiler/internal/tfprof_node.h
@@ -325,13 +325,11 @@
(*node_.mutable_attrs())[attr.first].MergeFrom(attr.second);
if (attr.first == "shape" && attr.second.has_shape()) {
if (!shape_.empty()) {
- absl::FPrintF(stderr, "Found duplicated shapes!\n");
continue;
}
shape_ = ShapeProtoToVec(attr.second.shape());
} else if (attr.first == "_output_shapes" && attr.second.has_list()) {
if (!output_shapes_.empty()) {
- absl::FPrintF(stderr, "Found duplicated output shapes!\n");
continue;
}
for (int i = 0; i < attr.second.list().shape_size(); ++i) {
@@ -667,8 +665,6 @@
}
if (complete_shape) {
return params;
- } else {
- absl::FPrintF(stderr, "Incomplete shape.\n");
}
}
return 0;
diff --git a/tensorflow/python/profiler/tfprof_logger.py b/tensorflow/python/profiler/tfprof_logger.py
index 8aff8ce..27a1d36 100644
--- a/tensorflow/python/profiler/tfprof_logger.py
+++ b/tensorflow/python/profiler/tfprof_logger.py
@@ -91,7 +91,7 @@
if run_meta:
graph = _fill_missing_graph_shape(graph, run_meta)
- op_missing_shape = 0
+ missing_shape_ops = []
logged_ops = {}
string_to_id = {}
string_to_id['none'] = len(string_to_id)
@@ -102,7 +102,7 @@
graph, op.node_def, REGISTERED_FLOP_STATS)
except ValueError:
# Catch Exception When shape is incomplete. Skip it.
- op_missing_shape += 1
+ missing_shape_ops.append(op.name)
stats = None
entry = tfprof_log_pb2.OpLogEntry()
@@ -136,9 +136,10 @@
else:
logged_ops[v.op.name].types.append(TRAINABLE_VARIABLES)
- if op_missing_shape > 0 and not run_meta:
- sys.stderr.write('%d ops no flops stats due to incomplete shapes.\n' %
- op_missing_shape)
+ if missing_shape_ops and not run_meta:
+ sys.stderr.write(
+ '%d ops have no flops stats due to incomplete shapes: [%s] \n' %
+ len(missing_shape_ops), missing_shape_ops)
return logged_ops, string_to_id