Overview

This section describes how to use APIs to perform profiling in offline inference scenarios. The following methods are supported.

Table 1 Profiling methods

Profiling Method

Description

Method 1: Collecting and flushing profile data

Write the collected profile data to a file, parse the file by using the msprof tool, and display the profile data analysis result.

Method 2: Using msproftx APIs to collect and flush profile data

To locate the performance bottleneck of your application or the upper-layer framework application, call the msproftx APIs during the profiling process (between the aclprofStart and aclprofStop calls). msproftx is used to record the time span of specific events during application running and write data to a profile data file. You can use msprof to parse the file and export the profile data.

Method 3: Subscribing to operator information

Parse the collected profile data and write it to a pipeline. Then, users read the data to the memory and call APIs to obtain it.

  • Before using the APIs to collect profile data, you need to develop, build, and run an application project. For details, see Application Development (C&C++).
  • If an operator is being executed during initialization (aclprofInit + aclprofStart), error logs may be generated because related resources have not been initialized. However, this does not affect service functions. You are advised to call aclrtSynchronizeStream or aclrtSynchronizeStreamWithTimeout to perform stream synchronization before enabling profiling.
  • Methods 1 and 2 cannot be used together with method 3.