pytorch_pfn_extras.training.extensions.ProfileReport#

class pytorch_pfn_extras.training.extensions.ProfileReport(store_keys=None, report_keys=None, trigger=(1, 'epoch'), filename=None, append=False, format=None, **kwargs)#

Bases: Extension

Writes the profile results to a file.

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

Parameters:
  • store_keys (iterable of strs) – Keys of values to write to the profiler report file.

  • report_keys (iterable of strs) – Keys of values that will be reported.

  • trigger (Optional[Union[Trigger, Callable[[ExtensionsManagerProtocol], bool], Tuple[float, str]]]) – Trigger that decides when to aggregate the result and output the values. 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.

  • 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.

  • append (bool, optionsl) – If the file is JSON Lines or YAML, contents will be appended instead of rewriting the file every call.

  • format (str, optional) – accepted values are ‘json’, ‘json-lines’ and ‘yaml’.

  • 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

  • entries (list) – list of str

  • kwargs (Any) –

Returns:

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

Return type:

header (str)

Methods

__init__([store_keys, report_keys, trigger, ...])

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__(store_keys=None, report_keys=None, trigger=(1, 'epoch'), filename=None, append=False, format=None, **kwargs)#
Parameters:
  • store_keys (Optional[Iterable[str]]) –

  • report_keys (Optional[Iterable[str]]) –

  • trigger (Optional[Union[Trigger, Callable[[ExtensionsManagerProtocol], bool], Tuple[float, str]]]) –

  • filename (Optional[str]) –

  • append (bool) –

  • format (Optional[str]) –

  • kwargs (Any) –

finalize(manager)#

Finalizes the extension.

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

Parameters:

manager (ExtensionsManagerProtocol) –

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]