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’ button/option and click the profile link. Now, Profiler supports the AICore operator analysis.

class mindspore.profiler.Profiler(**kwargs)[source]

Performance profiling API.

This API enables MindSpore users to profile the performance of neural network. Profiler supports Ascend and GPU, both of them are used in the same way, but only output_path in args works on GPU.

Parameters
  • output_path (str) – Output data path.

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

  • ascend_job_id (str) – (Ascend only) The directory where the profiling files to be parsed are located; This parameter is used to support offline parsing.

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()
>>> 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()
>>> model = Model()
>>> model.train()
>>> profiler.analyse()
static profile(network=None, profile_option=None)[source]

Get the number of trainable parameters in the training network.

Parameters
  • network (Cell) – The training network.

  • profile_option (ProfileOption) – The profile option.

Returns

dict, the key is the option name, the value is the result of option.

class mindspore.profiler.ProfileOption[source]

Profile Option Enum which be used in Profiler.profile.