mindspore.profiler

Profiler Module Introduction.

This module provides Python APIs to enable the profiling of MindSpore neural networks. Users can import the mindspore.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 mindspore Web, find the corresponding run and click the profile link. Now, Profiler supports the AICore operator analysis.

class mindspore.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 mindspore.profiler import Profiler
>>> import mindspore.context
>>> 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()
>>> model.train()
>>> profiler.analyse()
analyse()[source]

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

Examples

>>> from mindspore.profiler import Profiler
>>> import mindspore.context
>>> 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()
>>> model.train()
>>> profiler.analyse()
static trainable_parameters(network)[source]

Get the number of trainable parameters in the training network.

Parameters

network (Cell) – The training network.

Returns

an integer,the network of trainable parameters.