pytorch_pfn_extras.training.extensions.TimelineTrace#

class pytorch_pfn_extras.training.extensions.TimelineTrace(trigger=(1, 'epoch'), filename=None, enable=None, disable=None, tracer=None, **kwargs)#

Bases: Extension

Writes the profile timeline to a file.

Times are reported by using the pytorch_pfn_extras.profiler.TimeSummary.report() context manager.

Parameters:
  • trigger (Optional[Union[Trigger, Callable[[ExtensionsManagerProtocol], bool], Tuple[float, str]]]) – Trigger that decides when to output the trace. This is distinct from the trigger of this extension itself. If it is a tuple in the form <int>, 'epoch' or <int>, 'iteration', it is passed to IntervalTrigger.

  • enable (Optional[Union[Trigger, Callable[[ExtensionsManagerProtocol], bool], Tuple[float, str]]]) – Trigger that enables the tracing. Note that since the extensions are executed at the end of an iteration the tracer will be enabled from the iteration after the trigger is fired. If it is a tuple in the form <int>, 'epoch' or <int>, 'iteration', it is passed to IntervalTrigger.

  • disable (Optional[Union[Trigger, Callable[[ExtensionsManagerProtocol], bool], Tuple[float, str]]]) – Trigger that disables the tracing. Note that since the extensions are executed at the end of an iteration the tracer will be disabled from the iteration after the trigger is fired. If it is a tuple in the form <int>, 'epoch' or <int>, 'iteration', it is passed to IntervalTrigger.

  • filename (str) – Name of the log file under the output directory. It can be a format string: the last result dictionary is passed for the formatting. For example, users can use ‘{iteration}’ to separate the log files for different iterations. If the log name is None, it does not output the log to any file.

  • writer (writer object, optional) – must be callable. object to dump the log to. If specified, it needs to have a correct savefun defined. The writer can override the save location in the pytorch_pfn_extras.training.ExtensionsManager object

  • tracer (tracer object, optional) – object with the tracing logic. If not specified, the default tracer in the thread local storage with be used.

  • entries (list) – list of str

  • kwargs (Any) –

Returns:

header string templates (str): template string for print values.

Return type:

header (str)

Methods

__init__([trigger, filename, enable, ...])

finalize(manager)

Finalizes the extension.

initialize(manager)

Initializes up the manager state.

load_state_dict(to_load)

on_error(manager, exc, tb)

Handles the error raised during training before finalization.

state_dict()

Serializes the extension state.

Attributes

default_name

Default name of the extension.

is_async

name

needs_model_state

priority

trigger

__call__(manager)#

Invokes the extension.

Implementations should override this operator. This method is called at iterations which the corresponding trigger accepts.

Parameters:

manager (ExtensionsManager) – Manager object to call this operator.

Return type:

None

__init__(trigger=(1, 'epoch'), filename=None, enable=None, disable=None, tracer=None, **kwargs)#
Parameters:
finalize(manager)#

Finalizes the extension.

This method is called at the end of the training loop.

Parameters:

manager (ExtensionsManagerProtocol) –

Return type:

None

initialize(manager)#

Initializes up the manager state.

This method is called before entering the training loop. An extension modifying the state of ExtensionsManager can override this method to initialize it.

When the manager has been restored from a snapshot, this method has to recover an appropriate part of the state of the manager.

Parameters:

manager (ExtensionsManager) – Manager object to call this extension.

Return type:

None

load_state_dict(to_load)#
Parameters:

to_load (Dict[str, Any]) –

Return type:

None

state_dict()#

Serializes the extension state.

It is called when a manager that owns this extension is serialized. It serializes nothing by default.

Return type:

Dict[str, Any]