ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

CANN/GE ES私有属性构图Python示例

CANN/GE ES私有属性构图Python示例 Sample Usage Guide【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge1. Function DescriptionThis sample uses Sigmoid private attributes for graph construction, aiming to help graph construction developers quickly understand the definition of private attributes and how to use private attributes for graph construction.2. Directory Structurepython/ ├── src/ | └── make_sigmoid_graph.py // Sample file ├── run_sample.sh // Execution script ├── CMakeLists.txt // Build script ├── README.md // README file3. Usage3.1 Prepare CANN PackageCorrectly installtoolkitandopspackages following the installation guide Environment PreparationSet environment variables (assuming the package is installed in /usr/local/Ascend/)source /usr/local/Ascend/cann/set_env.sh3.2 Build and ExecuteNote: Compared with C/C graph construction, Python graph construction requires additional LD_LIBRARY_PATH and PYTHONPATH settings (refer to the configuration in sample)bash run_sample.sh -t sample_and_run_pythonThis command will:Automatically generate ES interfaceCompile sample programGenerate dump graph and run the graphAfter successful execution, you will see:[Success] sample executed successfully, pbtxt dump has been generated in current directory. This file starts with ge_onnx_ and can be opened in netron for displayOutput File DescriptionAfter successful execution, the following file will be generated in current directory:ge_onnx_*.pbtxt- Protobuf text format of graph structure, can be viewed with netron3.3 Log PrintingIf log printing is needed during executable program execution to assist debugging, set the following environment variables before bash run_sample.sh -t sample_and_run_python to print logs to screen:export ASCEND_SLOG_PRINT_TO_STDOUT1 #Print logs to screen export ASCEND_GLOBAL_LOG_LEVEL0 #Log level set to debug level3.4 DUMP Graph During Graph CompilationIf DUMP graph is needed during executable program execution to assist graph compilation debugging, set the following environment variables before bash run_sample.sh -t sample_and_run_python to DUMP graph to execution path:export DUMP_GE_GRAPH24. Core Concept Introduction4.1 Graph Construction StepsCreate graph builder (to provide context, workspace and build-related methods needed for graph construction)Add starting nodes (starting nodes refer to nodes without input dependencies, usually including graph inputs (like Data nodes) and weight constants (like Const nodes))Add intermediate nodes (intermediate nodes are computation nodes with input dependencies, usually generated by user graph construction logic, and connected using existing nodes as inputs)Set graph output (explicitly specify graph output nodes as endpoints of computation results)4.2 Concept DescriptionPrivate attributes refer to custom attributes that dont exist in IR definition, ES graph construction provides corresponding interfaces to complete custom attribute settings; Private attributes in this sample will be displayed in thege_proto_*.txtfile generated by default in current directory【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表