tf.compat.v1.profiler.Profiler
Stay organized with collections
Save and categorize content based on your preferences.
TensorFlow multi-step profiler.
tf.compat.v1.profiler.Profiler(
graph=None, op_log=None
)
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/README.md
Typical use case:
# Currently we are only allowed to create 1 profiler per process.
profiler = Profiler(sess.graph)
for i in xrange(total_steps):
if i % 10000 == 0:
run_meta = tf.compat.v1.RunMetadata()
_ = sess.run(...,
options=tf.compat.v1.RunOptions(
trace_level=tf.RunOptions.FULL_TRACE),
run_metadata=run_meta)
profiler.add_step(i, run_meta)
# Profile the parameters of your model.
profiler.profile_name_scope(options=(option_builder.ProfileOptionBuilder
.trainable_variables_parameter()))
# Or profile the timing of your model operations.
opts = option_builder.ProfileOptionBuilder.time_and_memory()
profiler.profile_operations(options=opts)
# Or you can generate a timeline:
opts = (option_builder.ProfileOptionBuilder(
option_builder.ProfileOptionBuilder.time_and_memory())
.with_step(i)
.with_timeline_output(filename).build())
profiler.profile_graph(options=opts)
else:
_ = sess.run(...)
# Auto detect problems and generate advice.
profiler.advise()
Args |
graph
|
tf.Graph. If None and eager execution is not enabled, use
default graph.
|
op_log
|
optional. tensorflow::tfprof::OpLogProto proto. Used to define
extra op types.
|
Methods
add_step
View source
add_step(
step, run_meta
)
Add statistics of a step.
Args |
step
|
int, An id used to group one or more different run_meta together.
When profiling with the profile_xxx APIs, user can use the step
id in the options to profile these run_meta together.
|
run_meta
|
RunMetadata proto that contains statistics of a session run.
|
advise
View source
advise(
options
)
Automatically detect problems and generate reports.
Args |
options
|
A dict of options. See ALL_ADVICE example above.
|
Returns |
A Advise proto that conains the reports from all checkers.
|
profile_graph
View source
profile_graph(
options
)
Profile the statistics of graph nodes, organized by dataflow graph.
Args |
options
|
A dict of options. See core/profiler/g3doc/options.md.
|
Returns |
a GraphNodeProto that records the results.
|
profile_name_scope
View source
profile_name_scope(
options
)
Profile the statistics of graph nodes, organized by name scope.
Args |
options
|
A dict of options. See core/profiler/g3doc/options.md.
|
Returns |
a GraphNodeProto that records the results.
|
profile_operations
View source
profile_operations(
options
)
Profile the statistics of the Operation types (e.g. MatMul, Conv2D).
Args |
options
|
A dict of options. See core/profiler/g3doc/options.md.
|
Returns |
a MultiGraphNodeProto that records the results.
|
profile_python
View source
profile_python(
options
)
Profile the statistics of the Python codes.
By default, it shows the call stack from root. To avoid
redundant output, you may use options to filter as below
options['show_name_regexes'] = ['.my_code.py.']
Args |
options
|
A dict of options. See core/profiler/g3doc/options.md.
|
Returns |
a MultiGraphNodeProto that records the results.
|
serialize_to_string
View source
serialize_to_string()
Serialize the ProfileProto to a binary string.
Users can write it to file for offline analysis by tfprof commandline
or graphical interface.
Returns |
ProfileProto binary string.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.compat.v1.profiler.Profiler\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L126-L306) |\n\nTensorFlow multi-step profiler. \n\n tf.compat.v1.profiler.Profiler(\n graph=None, op_log=None\n )\n\n\u003chttps://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/README.md\u003e \n\n Typical use case:\n # Currently we are only allowed to create 1 profiler per process.\n profiler = Profiler(sess.graph)\n\n for i in xrange(total_steps):\n if i % 10000 == 0:\n run_meta = tf.compat.v1.RunMetadata()\n _ = sess.run(...,\n options=tf.compat.v1.RunOptions(\n trace_level=tf.RunOptions.FULL_TRACE),\n run_metadata=run_meta)\n profiler.add_step(i, run_meta)\n\n # Profile the parameters of your model.\n profiler.profile_name_scope(options=(option_builder.ProfileOptionBuilder\n .trainable_variables_parameter()))\n\n # Or profile the timing of your model operations.\n opts = option_builder.ProfileOptionBuilder.time_and_memory()\n profiler.profile_operations(options=opts)\n\n # Or you can generate a timeline:\n opts = (option_builder.ProfileOptionBuilder(\n option_builder.ProfileOptionBuilder.time_and_memory())\n .with_step(i)\n .with_timeline_output(filename).build())\n profiler.profile_graph(options=opts)\n else:\n _ = sess.run(...)\n # Auto detect problems and generate advice.\n profiler.advise()\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|--------------------------------------------------------------------------------|\n| `graph` | tf.Graph. If None and eager execution is not enabled, use default graph. |\n| `op_log` | optional. tensorflow::tfprof::OpLogProto proto. Used to define extra op types. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `add_step`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L189-L205) \n\n add_step(\n step, run_meta\n )\n\nAdd statistics of a step.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `step` | int, An id used to group one or more different `run_meta` together. When profiling with the profile_xxx APIs, user can use the `step` id in the `options` to profile these `run_meta` together. |\n| `run_meta` | RunMetadata proto that contains statistics of a session run. |\n\n\u003cbr /\u003e\n\n### `advise`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L279-L291) \n\n advise(\n options\n )\n\nAutomatically detect problems and generate reports.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|--------------------------------------------------|\n| `options` | A dict of options. See ALL_ADVICE example above. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A Advise proto that conains the reports from all checkers. ||\n\n\u003cbr /\u003e\n\n### `profile_graph`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L262-L277) \n\n profile_graph(\n options\n )\n\nProfile the statistics of graph nodes, organized by dataflow graph.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|--------------------------------------------------------|\n| `options` | A dict of options. See core/profiler/g3doc/options.md. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| a GraphNodeProto that records the results. ||\n\n\u003cbr /\u003e\n\n### `profile_name_scope`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L245-L260) \n\n profile_name_scope(\n options\n )\n\nProfile the statistics of graph nodes, organized by name scope.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|--------------------------------------------------------|\n| `options` | A dict of options. See core/profiler/g3doc/options.md. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| a GraphNodeProto that records the results. ||\n\n\u003cbr /\u003e\n\n### `profile_operations`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L228-L243) \n\n profile_operations(\n options\n )\n\nProfile the statistics of the Operation types (e.g. MatMul, Conv2D).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|--------------------------------------------------------|\n| `options` | A dict of options. See core/profiler/g3doc/options.md. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| a MultiGraphNodeProto that records the results. ||\n\n\u003cbr /\u003e\n\n### `profile_python`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L207-L226) \n\n profile_python(\n options\n )\n\nProfile the statistics of the Python codes.\n\nBy default, it shows the call stack from root. To avoid\nredundant output, you may use options to filter as below\noptions\\['show_name_regexes'\\] = \\['.*my_code.py.*'\\]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------|--------------------------------------------------------|\n| `options` | A dict of options. See core/profiler/g3doc/options.md. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| a MultiGraphNodeProto that records the results. ||\n\n\u003cbr /\u003e\n\n### `serialize_to_string`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/profiler/model_analyzer.py#L293-L302) \n\n serialize_to_string()\n\nSerialize the ProfileProto to a binary string.\n\nUsers can write it to file for offline analysis by tfprof commandline\nor graphical interface.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| ProfileProto binary string. ||\n\n\u003cbr /\u003e"]]