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

Function profile

tensorflow/python/profiler/model_analyzer.py:310–381  ·  view source on GitHub ↗

Profile model. Tutorials and examples can be found in: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/README.md Args: graph: tf.Graph. If None and eager execution is not enabled, use default graph. run_meta: optional tensorflow.RunMetadata p

(graph=None,
            run_meta=None,
            op_log=None,
            cmd='scope',
            options=_DEFAULT_PROFILE_OPTIONS)

Source from the content-addressed store, hash-verified

308
309@tf_export(v1=['profiler.profile'])
310def profile(graph=None,
311 run_meta=None,
312 op_log=None,
313 cmd='scope',
314 options=_DEFAULT_PROFILE_OPTIONS):
315 """Profile model.
316
317 Tutorials and examples can be found in:
318 https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/README.md
319
320 Args:
321 graph: tf.Graph. If None and eager execution is not enabled, use
322 default graph.
323 run_meta: optional tensorflow.RunMetadata proto. It is necessary to
324 to support run time information profiling, such as time and memory.
325 op_log: tensorflow.tfprof.OpLogProto proto. User can assign "types" to
326 graph nodes with op_log. "types" allow user to flexibly group and
327 account profiles using options['accounted_type_regexes'].
328 cmd: string. Either 'op', 'scope', 'graph' or 'code'.
329 'op' view organizes profile using operation type. (e.g. MatMul)
330 'scope' view organizes profile using graph node name scope.
331 'graph' view organizes profile using graph node inputs/outputs.
332 'code' view organizes profile using Python call stack.
333 options: A dict of options. See core/profiler/g3doc/options.md.
334 Returns:
335 If cmd is 'scope' or 'graph', returns GraphNodeProto proto.
336 If cmd is 'op' or 'code', returns MultiGraphNodeProto proto.
337 Side effect: stdout/file/timeline.json depending on options['output']
338 """
339 if not graph and not context.executing_eagerly():
340 graph = ops.get_default_graph()
341
342 if options == _DEFAULT_PROFILE_OPTIONS:
343 options = (option_builder.ProfileOptionBuilder
344 .trainable_variables_parameter())
345 # pylint: disable=protected-access
346 op_log = tfprof_logger.merge_default_with_oplog(
347 graph, op_log, run_meta, add_trace=cmd == 'code')
348 # pylint: enable=protected-access
349
350 opts = _build_options(options)
351
352 run_meta_str = run_meta.SerializeToString() if run_meta else b''
353
354 graph_str = _graph_string(graph)
355
356 if cmd == 'code' or cmd == 'op':
357 tfprof_node = tfprof_output_pb2.MultiGraphNodeProto()
358 ret = print_mdl.PrintModelAnalysis(graph_str, run_meta_str,
359 op_log.SerializeToString(),
360 cmd.encode('utf-8'),
361 opts.SerializeToString())
362 try:
363 tfprof_node.ParseFromString(ret)
364 except message.DecodeError as e:
365 sys.stderr.write('Cannot parse returned proto: %s.\n' % e)
366
367 elif cmd == 'graph' or cmd == 'scope':

Callers

nothing calls this directly

Calls 8

_build_optionsFunction · 0.85
_graph_stringFunction · 0.85
executing_eagerlyMethod · 0.80
SerializeToStringMethod · 0.45
encodeMethod · 0.45
ParseFromStringMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected