CANN/GE图导出格式规范
2026/9/10 4:26:13 网站建设 项目流程

GE Graph Dump Format Specification

【免费下载链接】geGE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力,并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge

Overview

GE (Graph Engine) supports exporting computation graphs in multiple formats, facilitating developers to view, debug and analyze graph structures. This document introduces three dump formats:ge_proto,onnxandreadable, and their characteristics and usage methods.


Dump Format Overview

FormatFile NamingMain Characteristics
ge_protoge_proto*.txtprotobuf text format,best information completeness, can be converted to JSON format file for convenient user problem localization
onnxge_onnx*.pbtxtBased on ONNX model description structure, supports Netron and othervisualizationtools. Detailed explanation see Netron Visualization Instructions
readablege_readable*.txtSimilar to Dynamo fx graph style,highest text readability. Detailed format specification please refer to readable_dump.md

Dump Usage Methods

Automatic Dump via Environment Variables

By setting environment variables, dump files can be automatically generated during graph execution:

# Set graph dump level export DUMP_GE_GRAPH=1 # Set dump path export DUMP_GRAPH_PATH=/path/to/dump/directory # Set dump format export DUMP_GRAPH_FORMAT="ge_proto|onnx|readable"

Environment Variable Explanation:

Environment VariableExplanationExample Value
DUMP_GE_GRAPHControl graph dump content granularity:
-1: Full dump including edge relationships and data information
-2: Basic version dump excluding weights and other data
-3: Simplified version dump showing only node relationships
1,2or3
DUMP_GRAPH_PATHdump file save path:
- Can be configured as absolute path or relative path to script execution directory
- Path supports uppercase/lowercase letters, numbers, underscores, hyphens, periods, Chinese characters
/path/to/dump
DUMP_GRAPH_FORMATdump format, supportsge_proto,onnx,readable, multiple formats separated by\|readableorge_proto\|onnx(default value)
DUMP_GRAPH_LEVELControl number of dump graph compilation stages:
-Numeric configuration:
-1: dump graphs from all stages
-2: dump graphs from whitelist stages (default value)
-3: dump final generated graph (after GE optimization and compilation)
-4: dump earliest generated graph (graph after GE parsing and mapping operators)
-String configuration: Use\|to separate, e.g."PreRunBegin\|AfterInfershape", means dump graphs whose names contain these strings
1,2,3,4or"PreRunBegin\|AfterInfershape"

Export via Graph API

C++
#include "ge/graph.h" // Create graph ge::Graph graph("my_graph"); // ... Build graph structure ... // Export to different formats graph.DumpToFile(ge::Graph::DumpFormat::kTxt, "suffix"); // ge_proto graph.DumpToFile(ge::Graph::DumpFormat::kOnnx, "suffix"); // onnx graph.DumpToFile(ge::Graph::DumpFormat::kReadable, "suffix"); // readable
Python
from ge.graph import Graph, DumpFormat # Create graph graph = Graph("my_graph") # ... Build graph structure ... # Method 1: Export to file graph.dump_to_file(format=DumpFormat.kTxt, suffix="suffix") # ge_proto graph.dump_to_file(format=DumpFormat.kOnnx, suffix="suffix") # onnx graph.dump_to_file(format=DumpFormat.kReadable, suffix="suffix") # readable # Method 2: Direct print (only readable format supported) print(graph) # Direct print readable format to console to view graph structure readable_str = str(graph) # Get readable format string, can be used for saving or further processing

For detailed explanation ofge.graph, please refer to graph module


Appendix

Netron Visualization Instructions

When openingge_onnx*.pbtxtfile in Netron:

  • Node representation: Each node in the graph represents an operator

  • Edge relationships: Edge relationships are represented by solid lines with arrows, arrow direction indicates data flow direction (from source node to target node)

  • Node information viewing: Click operator node to view operator detailed information, key information includes:

    Attribute NameExplanation
    typeOperator type
    nameOperator name
    input_desc_dtype:xData type of x-th input
    input_desc_layout:xData format of x-th input
    input_desc_shape:xShape of x-th input
    output_desc_dtype:xData type of x-th output
    output_desc_layout:xData format of x-th output
    output_desc_shape:xShape of x-th output

【免费下载链接】geGE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力,并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询