MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _fill_missing_graph_shape

Function _fill_missing_graph_shape

tensorflow/python/profiler/tfprof_logger.py:39–65  ·  view source on GitHub ↗

Fill Tensor shapes in 'graph' with run time shape from 'run_meta'.

(graph, run_meta)

Source from the content-addressed store, hash-verified

37
38
39def _fill_missing_graph_shape(graph, run_meta):
40 """Fill Tensor shapes in 'graph' with run time shape from 'run_meta'."""
41 for dev_stat in run_meta.step_stats.dev_stats:
42 for node_stat in dev_stat.node_stats:
43 if not node_stat.output:
44 continue
45 try:
46 op = graph.get_operation_by_name(node_stat.node_name)
47 except KeyError as e:
48 # Graph doesn't contains the node_stat, usually RecvTensor.
49 continue
50 if len(node_stat.output) != len(op.outputs):
51 # For example, conditional op has only 1 output at run time.
52 continue
53 for (i, node_stat_out) in enumerate(node_stat.output):
54 if op.outputs[i].get_shape().is_fully_defined():
55 continue
56 node_stat_dims = node_stat_out.tensor_description.shape.dim
57 node_stat_shape = tensor_shape.TensorShape(
58 [d.size for d in node_stat_dims])
59 try:
60 op.outputs[i].set_shape(op.outputs[i].get_shape().merge_with(
61 node_stat_shape))
62 except ValueError as e:
63 sys.stderr.write('Node %s incompatible shapes: %s.\n' %
64 (node_stat.node_name, e))
65 return graph
66
67
68def _str_id(s, str_to_id):

Callers 1

_get_logged_opsFunction · 0.85

Calls 6

get_operation_by_nameMethod · 0.80
is_fully_definedMethod · 0.80
get_shapeMethod · 0.45
set_shapeMethod · 0.45
merge_withMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected