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

Function merge_default_with_oplog

tensorflow/python/profiler/tfprof_logger.py:144–188  ·  view source on GitHub ↗

Merge the tfprof default extra info with caller's op_log. Args: graph: tf.Graph. If None and eager execution is not enabled, use default graph. op_log: OpLogProto proto. run_meta: RunMetadata proto used to complete shape information. add_trace: Whether to add op trace info

(graph, op_log=None, run_meta=None,
                             add_trace=True, add_trainable_var=True)

Source from the content-addressed store, hash-verified

142
143
144def merge_default_with_oplog(graph, op_log=None, run_meta=None,
145 add_trace=True, add_trainable_var=True):
146 """Merge the tfprof default extra info with caller's op_log.
147
148 Args:
149 graph: tf.Graph. If None and eager execution is not enabled, use
150 default graph.
151 op_log: OpLogProto proto.
152 run_meta: RunMetadata proto used to complete shape information.
153 add_trace: Whether to add op trace information.
154 add_trainable_var: Whether to assign tf.compat.v1.trainable_variables() op
155 type '_trainable_variables'.
156 Returns:
157 tmp_op_log: Merged OpLogProto proto.
158 """
159 if not graph and not context.executing_eagerly():
160 graph = ops.get_default_graph()
161
162 tmp_op_log = tfprof_log_pb2.OpLogProto()
163 if not graph:
164 return tmp_op_log
165
166 logged_ops, string_to_id = _get_logged_ops(
167 graph, run_meta, add_trace=add_trace, add_trainable_var=add_trainable_var)
168
169 if not op_log:
170 tmp_op_log.log_entries.extend(logged_ops.values())
171 else:
172 all_ops = {}
173 for entry in op_log.log_entries:
174 all_ops[entry.name] = entry
175 for op_name, entry in six.iteritems(logged_ops):
176 if op_name in all_ops:
177 all_ops[op_name].types.extend(entry.types)
178 if entry.float_ops > 0 and all_ops[op_name].float_ops == 0:
179 all_ops[op_name].float_ops = entry.float_ops
180 if entry.code_def.traces and not all_ops[op_name].code_def.traces:
181 all_ops[op_name].code_def.MergeFrom(entry.code_def)
182 else:
183 all_ops[op_name] = entry
184 tmp_op_log.log_entries.extend(all_ops.values())
185
186 for s, i in six.iteritems(string_to_id):
187 tmp_op_log.id_to_string[i] = s
188 return tmp_op_log
189
190
191@tf_export(v1=['profiler.write_op_log'])

Callers 1

write_op_logFunction · 0.85

Calls 4

_get_logged_opsFunction · 0.85
executing_eagerlyMethod · 0.80
extendMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected