Output meaningful logs for tf profiler.

PiperOrigin-RevId: 324229311
Change-Id: I95fbd8c90905e3c2dc78167aadb2e6c2db774bca
This commit is contained in:
A. Unique TensorFlower 2020-07-31 10:03:28 -07:00 committed by TensorFlower Gardener
parent d8d6160034
commit b511ad39ba
2 changed files with 9 additions and 6 deletions
tensorflow
core/profiler/internal
python/profiler

View File

@ -325,11 +325,13 @@ class TFGraphNode {
(*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) {
@ -665,6 +667,8 @@ class TFGraphNode {
}
if (complete_shape) {
return params;
} else {
absl::FPrintF(stderr, "Incomplete shape.\n");
}
}
return 0;

View File

@ -91,7 +91,7 @@ def _get_logged_ops(graph, run_meta=None, add_trace=True,
if run_meta:
graph = _fill_missing_graph_shape(graph, run_meta)
missing_shape_ops = []
op_missing_shape = 0
logged_ops = {}
string_to_id = {}
string_to_id['none'] = len(string_to_id)
@ -102,7 +102,7 @@ def _get_logged_ops(graph, run_meta=None, add_trace=True,
graph, op.node_def, REGISTERED_FLOP_STATS)
except ValueError:
# Catch Exception When shape is incomplete. Skip it.
missing_shape_ops.append(op.name)
op_missing_shape += 1
stats = None
entry = tfprof_log_pb2.OpLogEntry()
@ -136,10 +136,9 @@ def _get_logged_ops(graph, run_meta=None, add_trace=True,
else:
logged_ops[v.op.name].types.append(TRAINABLE_VARIABLES)
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)
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)
return logged_ops, string_to_id