tf.compat.v1.profiler.ProfileOptionBuilder

Option Builder for Profiling API.

For tutorial on the options, see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/options.md

# Users can use pre-built options:
opts = (
    tf.profiler.ProfileOptionBuilder.trainable_variables_parameter())

# Or, build your own options:
opts = (tf.compat.v1.profiler.ProfileOptionBuilder()
    .with_max_depth(10)
    .with_min_micros(1000)
    .select(['accelerator_micros'])
    .with_stdout_output()
    .build()

# Or customize the pre-built options:
opts = (tf.compat.v1.profiler.ProfileOptionBuilder(
    tf.profiler.ProfileOptionBuilder.time_and_memory())
    .with_displaying_options(show_name_regexes=['.*rnn.*'])
    .build())

# Finally, profiling with the options:
_ = tf.compat.v1.profiler.profile(tf.compat.v1.get_default_graph(),
                        run_meta=run_meta,
                        cmd='scope',
                        options=opts)

options Optional initial option dict to start with.

Methods

account_displayed_op_only

View source

Whether only account the statistics of displayed profiler nodes.

Args
is_true If true, only account statistics of nodes eventually displayed by the outputs. Otherwise, a node's statistics are accounted by its parents as long as it's types match 'account_type_regexes', even if it is hidden from the output, say, by hide_name_regexes.

Returns
self

build

View source

Build a profiling option.

Returns
A dict of profiling options.

float_operation

View source

Options used to profile float operations.

Please see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/profile_model_architecture.md on the caveats of calculating float operations.

Returns
A dict of profiling options.

order_by

View source

Order the displayed profiler nodes based on a attribute.

Supported attribute includes micros, bytes, occurrence, params, etc. https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/options.md

Args
attribute An attribute the profiler node has.

Returns
self

select

View source

Select the attributes to display.

See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/options.md for supported attributes.

Args
attributes A list of attribute the profiler node has.

Returns
self

time_and_memory

View source

Show operation time and memory consumptions.

Args
min_micros Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times.
min_bytes Only show profiler nodes requested to allocate no less bytes than this.
min_accelerator_micros Only show profiler nodes spend no less than this time on accelerator (e.g. GPU).
min_cpu_micros Only show profiler nodes spend no less than this time on cpu.
min_peak_bytes Only show profiler nodes using no less than this bytes at peak (high watermark). For profiler nodes consist of multiple graph nodes, it sums the graph nodes' peak_bytes.
min_residual_bytes Only show profiler nodes have no less than this bytes not being de-allocated after Compute() ends. For profiler nodes consist of multiple graph nodes, it sums the graph nodes' residual_bytes.
min_output_bytes Only show profiler nodes have no less than this bytes output. The output are not necessarily allocated by this profiler nodes.

Returns
A dict of profiling options.

trainable_variables_parameter

View source

Options used to profile trainable variable parameters.

Normally used together with 'scope' view.

Returns
A dict of profiling options.

with_accounted_types

View source

Selectively counting statistics based on node types.

Here, 'types' means the profiler nodes' properties. Profiler by default consider device name (e.g. /job:xx/.../device:GPU:0) and operation type (e.g. MatMul) as profiler nodes' properties. User can also associate customized 'types' to profiler nodes through OpLogProto proto.

For example, user can select profiler nodes placed on gpu:0 with: account_type_regexes=['.*gpu:0.*']

If none of a node's properties match the specified regexes, the node is not displayed nor accounted.

Args
account_type_regexes A list of regexes specifying the types.

Returns
self.

with_empty_output

View source

Do not generate side-effect outputs.

with_file_output

View source

Print the result to a file.

with_max_depth

View source

Set the maximum depth of display.

The depth depends on profiling view. For 'scope' view, it's the depth of name scope hierarchy (tree), for 'op' view, it's the number of operation types (list), etc.

Args
max_depth Maximum depth of the data structure to display.

Returns
self

with_min_execution_time

View source

Only show profiler nodes consuming no less than 'min_micros'.

Args
min_micros Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times.
min_accelerator_micros Only show profiler nodes spend no less than this time on accelerator (e.g. GPU).
min_cpu_micros Only show profiler nodes spend no less than this time on cpu.

Returns
self

with_min_float_operations