CANN/ge图转储格式规范

📅 2026/7/4 6:59:08
CANN/ge图转储格式规范
GE Graph Dump Format Specification【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/geOverviewGE (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 OverviewFormatFile NamingMain Characteristicsge_protoge_proto*.txtprotobuf text format,best information completeness, can be converted to JSON format file for convenient user problem localizationonnxge_onnx*.pbtxtBased on ONNX model description structure, supports Netron and othervisualizationtools. Detailed explanation see Netron Visualization Instructionsreadablege_readable*.txtSimilar to Dynamo fx graph style,highest text readability. Detailed format specification please refer to readable_dump.mdDump Usage MethodsAutomatic Dump via Environment VariablesBy setting environment variables, dump files can be automatically generated during graph execution:# Set graph dump level export DUMP_GE_GRAPH1 # Set dump path export DUMP_GRAPH_PATH/path/to/dump/directory # Set dump format export DUMP_GRAPH_FORMATge_proto|onnx|readableEnvironment Variable Explanation:Environment VariableExplanationExample ValueDUMP_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 relationships1,2or3DUMP_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/dumpDUMP_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 strings1,2,3,4orPreRunBegin\|AfterInfershapeExport via Graph APIC#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); // readablePythonfrom ge.graph import Graph, DumpFormat # Create graph graph Graph(my_graph) # ... Build graph structure ... # Method 1: Export to file graph.dump_to_file(formatDumpFormat.kTxt, suffixsuffix) # ge_proto graph.dump_to_file(formatDumpFormat.kOnnx, suffixsuffix) # onnx graph.dump_to_file(formatDumpFormat.kReadable, suffixsuffix) # 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 processingFor detailed explanation ofge.graph, please refer to graph moduleAppendixNetron Visualization InstructionsWhen openingge_onnx*.pbtxtfile in Netron:Node representation: Each node in the graph represents an operatorEdge 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 NameExplanationtypeOperator typenameOperator nameinput_desc_dtype:xData type of x-th inputinput_desc_layout:xData format of x-th inputinput_desc_shape:xShape of x-th inputoutput_desc_dtype:xData type of x-th outputoutput_desc_layout:xData format of x-th outputoutput_desc_shape:xShape of x-th output【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考