GraphDebugJSONPrint
Header File/Library File
- Header file: #include <ge/ge_api_v2.h>
- Library file: libge_runner_v2.so
Function Usage
In debugging scenarios, after a graph is loaded, this API is used to export the running task information in the graph in JSON format, including the stream ID, task ID, and task type. Then, you can view the visualized task information in tracing mode (for example, chrome://tracing/).
If the GraphDebugJSONPrint API is not called, when LoadGraph is called, set the following environment variables to generate the JSON file of the running task information:
export DUMP_GE_GRAPH=1
The directory of the generated JSON file complies with the following rules. The file name is in the format of debug_graph_{graph_id}_{time}_{pid}_{seq}.
- If the environment variable NPU_COLLECT_PATH is specified, the generated JSON file is stored in the ${NPU_COLLECT_PATH}/extra-info/ directory.
- If the environment variable DUMP_GRAPH_PATH is specified, the generated JSON file is stored in the ${DUMP_GRAPH_PATH}/ directory.
- If no environment variable is specified, the generated JSON file is stored in the current script execution directory.
For details about the environment variables, see Environment Variables.
Prototype
1 | Status GraphDebugJSONPrint(const uint32_t graph_id, uint32_t flags, AscendString &json_result) const |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
graph_id |
Input |
ID of the graph to be exported. |
flags |
Input |
Reserved. The value is fixed at 0. |
json_result |
Output |
Task information in the graph. The value is a character string in JSON format. |
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
Status |
GE_RTI_MODEL_NOT_LOADED: The graph is not loaded. SUCCESS: The information is successfully exported. FAILED: The information fails to be exported. |
Restrictions
- The memory allocated to the device must be determined before this API is called.
- The CompileGraph and LoadGraph processes must be completed before this API is called.
Example
1 2 3 4 5 | ge::GeSession session; uint32_t graph_id = 1; // Assume that the graph has been loaded. uint32_t flags = 0; ge::AscendString json_result; ge::Status ret = session.GraphDebugJSONPrint(graph_id, flags, json_result); |