LostTech.TensorFlow : API Documentation

Type ProfileOptionBuilder

Namespace tensorflow.profiler

Parent PythonObjectContainer

Interfaces IProfileOptionBuilder

Option Builder for Profiling API.

For tutorial on the options, see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/options.md
Show Example
# 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)

Methods

Properties

Public instance methods

ProfileOptionBuilder account_displayed_op_only(bool is_true)

Whether only account the statistics of displayed profiler nodes.
Parameters
bool 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
ProfileOptionBuilder
self

object account_displayed_op_only_dyn(object is_true)

Whether only account the statistics of displayed profiler nodes.
Parameters
object 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
object
self

ProfileOptionBuilder order_by(string attribute)

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
Parameters
string attribute
An attribute the profiler node has.
Returns
ProfileOptionBuilder
self

object order_by_dyn(object attribute)

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
Parameters
object attribute
An attribute the profiler node has.
Returns
object
self

ProfileOptionBuilder select(IEnumerable<string> attributes)

Select the attributes to display.

See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/options.md for supported attributes.
Parameters
IEnumerable<string> attributes
A list of attribute the profiler node has.
Returns
ProfileOptionBuilder
self

object select_dyn(object attributes)

Select the attributes to display.

See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/options.md for supported attributes.
Parameters
object attributes
A list of attribute the profiler node has.
Returns
object
self

ProfileOptionBuilder with_accounted_types(IEnumerable<string> account_type_regexes)

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.
Parameters
IEnumerable<string> account_type_regexes
A list of regexes specifying the types.
Returns
ProfileOptionBuilder
self.

object with_accounted_types_dyn(object account_type_regexes)

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.
Parameters
object account_type_regexes
A list of regexes specifying the types.
Returns
object
self.

ProfileOptionBuilder with_empty_output()

Do not generate side-effect outputs.

object with_empty_output_dyn()

Do not generate side-effect outputs.

ProfileOptionBuilder with_file_output(object outfile)

Print the result to a file.

object with_file_output_dyn(object outfile)

Print the result to a file.

ProfileOptionBuilder with_max_depth(int max_depth)

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.
Parameters
int max_depth
Maximum depth of the data structure to display.
Returns
ProfileOptionBuilder
self

object with_max_depth_dyn(object max_depth)

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.
Parameters
object max_depth
Maximum depth of the data structure to display.
Returns
object
self

ProfileOptionBuilder with_min_execution_time(int min_micros, int min_accelerator_micros, int min_cpu_micros)

Only show profiler nodes consuming no less than 'min_micros'.
Parameters
int min_micros
Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times.
int min_accelerator_micros
Only show profiler nodes spend no less than this time on accelerator (e.g. GPU).
int min_cpu_micros
Only show profiler nodes spend no less than this time on cpu.
Returns
ProfileOptionBuilder
self

object with_min_execution_time_dyn(ImplicitContainer<T> min_micros, ImplicitContainer<T> min_accelerator_micros, ImplicitContainer<T> min_cpu_micros)

Only show profiler nodes consuming no less than 'min_micros'.
Parameters
ImplicitContainer<T> min_micros
Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times.
ImplicitContainer<T> min_accelerator_micros
Only show profiler nodes spend no less than this time on accelerator (e.g. GPU).
ImplicitContainer<T> min_cpu_micros
Only show profiler nodes spend no less than this time on cpu.
Returns
object
self

ProfileOptionBuilder with_min_float_operations(object min_float_ops)

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

Please see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/profile_model_architecture.md on the caveats of calculating float operations.
Parameters
object min_float_ops
Only show profiler nodes with float operations no less than this.
Returns
ProfileOptionBuilder
self

object with_min_float_operations_dyn(object min_float_ops)

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

Please see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/g3doc/profile_model_architecture.md on the caveats of calculating float operations.
Parameters
object min_float_ops
Only show profiler nodes with float operations no less than this.
Returns
object
self

ProfileOptionBuilder with_min_memory(int min_bytes, int min_peak_bytes, int min_residual_bytes, int min_output_bytes)

Only show profiler nodes consuming no less than 'min_bytes'.
Parameters
int min_bytes
Only show profiler nodes requested to allocate no less bytes than this.
int 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.
int 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.
int 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
ProfileOptionBuilder
self

object with_min_memory_dyn(ImplicitContainer<T> min_bytes, ImplicitContainer<T> min_peak_bytes, ImplicitContainer<T> min_residual_bytes, ImplicitContainer<T> min_output_bytes)

Only show profiler nodes consuming no less than 'min_bytes'.
Parameters
ImplicitContainer<T> min_bytes
Only show profiler nodes requested to allocate no less bytes than this.
ImplicitContainer<T> 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.
ImplicitContainer<T> 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.
ImplicitContainer<T> 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
object
self

ProfileOptionBuilder with_min_occurrence(int min_occurrence)

Only show profiler nodes including no less than 'min_occurrence' graph nodes.

A "node" means a profiler output node, which can be a python line (code view), an operation type (op view), or a graph node (graph/scope view). A python line includes all graph nodes created by that line, while an operation type includes all graph nodes of that type.
Parameters
int min_occurrence
Only show nodes including no less than this.
Returns
ProfileOptionBuilder
self

object with_min_occurrence_dyn(object min_occurrence)

Only show profiler nodes including no less than 'min_occurrence' graph nodes.

A "node" means a profiler output node, which can be a python line (code view), an operation type (op view), or a graph node (graph/scope view). A python line includes all graph nodes created by that line, while an operation type includes all graph nodes of that type.
Parameters
object min_occurrence
Only show nodes including no less than this.
Returns
object
self

ProfileOptionBuilder with_min_parameters(object min_params)

Only show profiler nodes holding no less than 'min_params' parameters.

'Parameters' normally refers the weights of in TensorFlow variables. It reflects the 'capacity' of models.
Parameters
object min_params
Only show profiler nodes holding number parameters no less than this.
Returns
ProfileOptionBuilder
self

object with_min_parameters_dyn(object min_params)

Only show profiler nodes holding no less than 'min_params' parameters.

'Parameters' normally refers the weights of in TensorFlow variables. It reflects the 'capacity' of models.
Parameters
object min_params
Only show profiler nodes holding number parameters no less than this.
Returns
object
self

ProfileOptionBuilder with_node_names(object start_name_regexes, IEnumerable<string> show_name_regexes, object hide_name_regexes, IEnumerable<string> trim_name_regexes)

Regular expressions used to select profiler nodes to display.

After 'with_accounted_types' is evaluated, 'with_node_names' are evaluated as follows:

For a profile data structure, profiler first finds the profiler nodes matching 'start_name_regexes', and starts displaying profiler nodes from there. Then, if a node matches 'show_name_regexes' and doesn't match 'hide_name_regexes', it's displayed. If a node matches 'trim_name_regexes', profiler stops further searching that branch.
Parameters
object start_name_regexes
list of node name regexes to start displaying.
IEnumerable<string> show_name_regexes
list of node names regexes to display.
object hide_name_regexes
list of node_names regexes that should be hidden.
IEnumerable<string> trim_name_regexes
list of node name regexes from where to stop.
Returns
ProfileOptionBuilder
self

object with_node_names_dyn(object start_name_regexes, object show_name_regexes, object hide_name_regexes, object trim_name_regexes)

Regular expressions used to select profiler nodes to display.

After 'with_accounted_types' is evaluated, 'with_node_names' are evaluated as follows:

For a profile data structure, profiler first finds the profiler nodes matching 'start_name_regexes', and starts displaying profiler nodes from there. Then, if a node matches 'show_name_regexes' and doesn't match 'hide_name_regexes', it's displayed. If a node matches 'trim_name_regexes', profiler stops further searching that branch.
Parameters
object start_name_regexes
list of node name regexes to start displaying.
object show_name_regexes
list of node names regexes to display.
object hide_name_regexes
list of node_names regexes that should be hidden.
object trim_name_regexes
list of node name regexes from where to stop.
Returns
object
self

ProfileOptionBuilder with_pprof_output(object pprof_file)

Generate a pprof profile gzip file.

To use the pprof file: pprof -png --nodecount=100 --sample_index=1
Parameters
object pprof_file
filename for output, usually suffixed with.pb.gz.
Returns
ProfileOptionBuilder
self.

object with_pprof_output_dyn(object pprof_file)

Generate a pprof profile gzip file.

To use the pprof file: pprof -png --nodecount=100 --sample_index=1
Parameters
object pprof_file
filename for output, usually suffixed with.pb.gz.
Returns
object
self.

ProfileOptionBuilder with_stdout_output()

Print the result to stdout.

object with_stdout_output_dyn()

Print the result to stdout.

ProfileOptionBuilder with_step(int step)

Which profile step to use for profiling.

The 'step' here refers to the step defined by `Profiler.add_step()` API.
Parameters
int step
When multiple steps of profiles are available, select which step's profile to use. If -1, use average of all available steps.
Returns
ProfileOptionBuilder
self

object with_step_dyn(object step)

Which profile step to use for profiling.

The 'step' here refers to the step defined by `Profiler.add_step()` API.
Parameters
object step
When multiple steps of profiles are available, select which step's profile to use. If -1, use average of all available steps.
Returns
object
self

ProfileOptionBuilder with_timeline_output(object timeline_file)

Generate a timeline json file.

object with_timeline_output_dyn(object timeline_file)

Generate a timeline json file.

Public static methods

IDictionary<string, object> float_operation()

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
IDictionary<string, object>
A dict of profiling options.

object float_operation_dyn()

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
object
A dict of profiling options.

IDictionary<object, object> time_and_memory(int min_micros, int min_bytes, int min_accelerator_micros, int min_cpu_micros, int min_peak_bytes, int min_residual_bytes, int min_output_bytes)

Show operation time and memory consumptions.
Parameters
int min_micros
Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times.
int min_bytes
Only show profiler nodes requested to allocate no less bytes than this.
int min_accelerator_micros
Only show profiler nodes spend no less than this time on accelerator (e.g. GPU).
int min_cpu_micros
Only show profiler nodes spend no less than this time on cpu.
int 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.
int 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.
int 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
IDictionary<object, object>
A dict of profiling options.

object time_and_memory_dyn(ImplicitContainer<T> min_micros, ImplicitContainer<T> min_bytes, ImplicitContainer<T> min_accelerator_micros, ImplicitContainer<T> min_cpu_micros, ImplicitContainer<T> min_peak_bytes, ImplicitContainer<T> min_residual_bytes, ImplicitContainer<T> min_output_bytes)

Show operation time and memory consumptions.
Parameters
ImplicitContainer<T> min_micros
Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times.
ImplicitContainer<T> min_bytes
Only show profiler nodes requested to allocate no less bytes than this.
ImplicitContainer<T> min_accelerator_micros
Only show profiler nodes spend no less than this time on accelerator (e.g. GPU).
ImplicitContainer<T> min_cpu_micros
Only show profiler nodes spend no less than this time on cpu.
ImplicitContainer<T> 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.
ImplicitContainer<T> 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.
ImplicitContainer<T> 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
object
A dict of profiling options.

IDictionary<string, object> trainable_variables_parameter()

Options used to profile trainable variable parameters.

Normally used together with 'scope' view.
Returns
IDictionary<string, object>
A dict of profiling options.

object trainable_variables_parameter_dyn()

Options used to profile trainable variable parameters.

Normally used together with 'scope' view.
Returns
object
A dict of profiling options.

Public properties

object PythonObject get;