mindinsight.profiler

Profiler Module Introduction.

This module provides Python APIs to enable the profiling of MindSpore neural networks. Users can import the mindinsight.profiler.Profiler, initialize the Profiler object to start profiling, and use Profiler.analyse() to stop profiling and analyse the results. To visualize the profiling results, users can open MindInsight Web, find the corresponding run and click the profile link. Now, Profiler supports the AICore operator analysis.

class mindinsight.profiler.Profiler(subgraph='all', is_detail=True, is_show_op_path=False, output_path='./data', optypes_to_deal='', optypes_not_deal='Variable', job_id='')[source]

Performance profiling API.

Enable MindSpore users to profile the performance of neural network.

Parameters
  • subgraph (str) – Define which subgraph to monitor and analyse, can be ‘all’, ‘Default’, ‘Gradients’.

  • is_detail (bool) – Whether to show profiling data for op_instance level, only show optype level if False.

  • is_show_op_path (bool) – Whether to save the full path for each op instance.

  • output_path (str) – Output data path.

  • optypes_to_deal (str) – Op type names, the data of which optype should be collected and analysed, will deal with all op if null; Different op types should be seperated by comma.

  • optypes_not_deal (str) – Op type names, the data of which optype will not be collected and analysed; Different op types should be seperated by comma.

Examples

>>> from mindinsight.profiler import Profiler
>>> context.set_context(mode=context.GRAPH_MODE, device_target="Ascend",
>>>                     device_id=int(os.environ["DEVICE_ID"]))
>>> profiler = Profiler(subgraph='all', is_detail=True, is_show_op_path=False, output_path='./data')
>>> model = Model(train_network)
>>> dataset = get_dataset()
>>> model.train(2, dataset)
>>> profiler.analyse()
analyse()[source]

Collect and analyse performance data, called after training or during training.

Examples

>>> from mindinsight.profiler import Profiler
>>> context.set_context(mode=context.GRAPH_MODE, device_target="Ascend",
>>>                     device_id=int(os.environ["DEVICE_ID"]))
>>> profiler = Profiler(subgraph='all', is_detail=True, is_show_op_path=False, output_path='./data')
>>> model = Model(train_network)
>>> dataset = get_dataset()
>>> model.train(2, dataset)
>>> profiler.analyse()