尧图网络 高端网站定制 · 原创设计
免费咨询热线
400-888-6620
免费获取方案
CANN/GE图融合Pass示例
MoveReluBeforeConcatPass Python Example Usage Guide【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/geThis directory provides apure Pythonversion example ofgraph_base_pass/2_move_relu_before_concat_pass, with logic identical to the C version:ScanConcatV2 - RelustructureBuild replacement subgraph (move Relu to each input of Concat)UseSubgraphBoundarySubgraphRewriter.replace()for subgraph replacementFusionBasePass vs PatternFusionPassThe pass in this example inherits FusionBasePass. Unlike PatternFusionPass, here pass logic is implemented by overridingrun()function.run()function input contains reference to graph object. In this example scenario, Concat node input count is not fixed, difficult to represent with fixed pattern. Inrun()function can dynamically build Boundary based on matched Concat node in target graph, achieving higher flexibility.Directory Structurepython/ ├── README.md // Python example description ├── CMakeLists.txt // Build script for generating es_all Python ES API ├── src │ ├── python_move_relu_before_concat_pass.py // Python pass implementation filePrerequisitesCompleted CANN environment variable setup viasource ${ASCEND_PATH}/set_env.sh. For more guidance, refer to C Example README environment variable configuration stepPython environment can import ES API (usually from run package/ops package):ge.es.math.ConcatV2ge.es.nn.Relu(if this symbol is unavailable, confirm ES Python API installation is complete)Can import GE Python package (containsge.graph,ge.passesand pass loading chain)Python pass runtime loads precompiled binary components based onpybind11. CANN package prioritizes providing artifacts matching current Python version; if no matching artifact, automatically enters fallback compilation flow. Fallback compilation requirespybind11installed in current Python environment. If execution reports missingConcatV2,Reluetc. ES API, follow ES API Missing Handling (Optional) below to generate and loades_all.UsageThe following commands are executed in2_move_relu_before_concat_passdirectory by default.Configure environment variables:source ${ASCEND_PATH}/set_env.sh export DUMP_GE_GRAPH1 export ASCEND_GE_PY_PASS_PATH$PWD/python/src/python_move_relu_before_concat_pass.pyGenerate AIR model:cd cpp/data python es_gen_air.pyUsepyatcoffline compilation to trigger Python pass, modifysoc_versionper actual environment:pyatc --model./graph.air --framework1 --soc_versionxxx --output./model cd ../..Notes:pyatccommand line parameters are identical toatc, but run in current Python interpreter processIf execution reports missingConcatV2,Reluetc. ES API, first generate and loades_allper instructions below, then rerunES API Missing Handling (Optional)If execution reports missingConcatV2,Reluetc. ES API, can generatees_allviaCMakeLists.txtin this Python directory:cd python cmake -S . -B build cmake --build build --target build_es_all -j$(nproc)Install generated Python package and let current Python process find the package and corresponding dynamic library:pip install --force-reinstall --upgrade --target ./build/whl_package ./build/es_output/whl/es_all-1.0.0-py3-none-any.whl export PYTHONPATH$PWD/build/whl_package:${PYTHONPATH:-} export LD_LIBRARY_PATH$PWD/build/es_output/lib64:${LD_LIBRARY_PATH:-} cd ..Expected ResultSimilar log output:PythonMoveReluBeforeConcatPass Replacement of PythonMoveReluBeforeConcatPass succeeded【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
RELATED

相关推荐

GE/CANN融合模式传递示例

GE/CANN融合模式传递示例

Fusion Pass Examples 【免费下载链接】ge GE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、Tens…

📅 2026/9/10 3:09:02
智能体从Demo到生产:隔离、集成与治理的架构实践指南

智能体从Demo到生产:隔离、集成与治理的架构实践指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📅 2026/9/10 3:09:02
curl 限速指南:使用 `--limit-rate` 精确控制上传与下载带宽

curl 限速指南:使用 `--limit-rate` 精确控制上传与下载带宽

curl 限速指南:使用 --limit-rate 精确控制上传与下载带宽 【免费下载链接】curl A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, MQ…

📅 2026/9/10 3:04:02
MORE NEWS

更多资讯

📰

Metabase 缺陷复现策略全指南:为每个 Issue 类型选择最快的验证路径

Metabase 缺陷复现策略全指南:为每个 Issue 类型选择最快的验证路径 【免费下载链接】metabase The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart: 项目地址: https://gitcode.com/…

📰

Fiber v3 Recover 中间件指南:拦截 Panic、转换错误并输出堆栈

Fiber v3 Recover 中间件指南:拦截 Panic、转换错误并输出堆栈 【免费下载链接】fiber ⚡️ Express inspired web framework written in Go 项目地址: https://gitcode.com/GitHub_Trending/fi/fiber 本指南以 Fiber 官方文档 docs/middleware/recover.md 为…

📰

PyTorch环境配置从入门到实战:CUDA验证与VSCode调试避坑指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

Generative AI for Beginners:提示工程(Prompt Engineering)核心原理与实战指南

Generative AI for Beginners:提示工程(Prompt Engineering)核心原理与实战指南 【免费下载链接】generative-ai-for-beginners 21 Lessons, Get Started Building with Generative AI 项目地址: https://gitcode.com/GitHub_Trending/ge/…

📰

VSG序阻抗扫频实战:双闭环控制下并网逆变器稳定性分析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

MCP+A2A协议驱动的企业级多智能体架构实战

1. 项目概述:这不是又一个“智能体玩具”,而是一套可落地的企业级业务中枢架构你最近是不是也刷到过“DeepAgents”这个词?不是在某个AI技术分享会上,就是在GitHub trending榜上突然冒出来,还带着一串让人眼花缭乱的缩…

TODAY

今日更新

THIS WEEK

本周精选

THIS MONTH

本月热门

读完文章,想聊聊您的网站?

告诉我们您的行业与需求,资深顾问一对一梳理方案与报价,全程免费。

📞 💬