Shortcuts

NPUProfilerHook

class mmengine.hooks.NPUProfilerHook(*, begin=0, end=1, result_path='cann_profiling', exit_after_profiling=True, use_e2e_profiler=False, ge_profiling_to_std_out=False)[source]

NPUProfiler to analyze performance during training.

NPU Profiling is used to count the device execution time of all operators. The torch_npu.npu.profile interface is used to complete the profiling data collection at each stage of the project, and the data is analyzed by the msprof tool and the data can be dumped to further manually analyze the key performance bottlenecks. For more details on the torch_npu.npu.profile interface, please visit https://gitee.com/ascend/pytorch/blob/master/torch_npu/npu/profiler.py#profile

Parameters:
  • begin (int) – Number of start iterations for profiling. Defaults to 0.

  • end (int) – Number of end iterations for profiling. Defaults to 1.

  • result_path (str) – The path to save the profiling results file. Defaults to ‘cann_profiling’.

  • exit_after_profiling (bool) – Whether to exit the program after profiling. Defaults to True.

  • use_e2e_profiler (bool) – Turn on E2E profiling, E2E profiling combines performance data at the Pytorch level and the NPU level to analyze the bottlenecks of model performance end-to-end, and cannot show detailed content, and only as an auxiliary analysis. Defaults to False.

  • ge_profiling_to_std_out (bool) – Turn on GE profiling, GE uses to collect the profiling data of the host side scheduling of the Assend device. Defaults to False.

Examples

>>> cfg = ...
>>> profiler_config = dict(type='NPUProfilerHook', end=2)
>>> cfg.merge_from_dict({'custom_hooks': custom_hooks})
>>> runner = Runner.from_cfg(cfg)
>>> runner.train()
after_train_iter(runner, batch_idx, data_batch=None, outputs=None)[source]

All subclasses should override this method, if they need any operations after each training iteration.

Parameters:
  • runner (Runner) – The runner of the training process.

  • batch_idx (int) – The index of the current batch in the train loop.

  • data_batch (dict tuple or list, optional) – Data from dataloader.

  • outputs (dict, optional) – Outputs from model.

before_run(runner)[source]

All subclasses should override this method, if they need any operations before the training validation or testing process.

Parameters:

runner (Runner) – The runner of the training, validation or testing process.

before_train_iter(runner, batch_idx, data_batch=None)[source]

All subclasses should override this method, if they need any operations before each training iteration.

Parameters:
  • runner (Runner) – The runner of the training process.

  • batch_idx (int) – The index of the current batch in the train loop.

  • data_batch (dict or tuple or list, optional) – Data from dataloader.

Read the Docs v: v0.10.4
Versions
latest
stable
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.