尧图网络 高端网站定制 · 原创设计
免费咨询热线
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/11/20 19:24:31
智能体从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/10/8 6:01:44
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/10/6 16:37:27
MORE NEWS

更多资讯

📰

怎样去报考电工证多少钱 2025年最新政策避坑指南

怎样去报考电工证多少钱 2025年最新政策避坑指南 你是不是也遇到过这种情况:手上拿着电工证,但不知道怎么去报考?或者被中介忽悠了一大笔钱,结果证书还没拿到?别急,今天我就来给你讲讲【怎样去报考电工证】的全过程,包括多少钱、流程、注意事项,…

📰

综合施工电工证通过率揭秘:学历不高怕报不上名?这些真相你必须知道

综合施工电工证通过率揭秘:学历不高怕报不上名?这些真相你必须知道 你是不是也在担心,自己学历不高,连 综合施工电工证 都报不了名?别急,今天就给你扒一扒这个证书的真实门槛和通过率揭秘,帮你扫清所有报考顾虑。 综合施工电工证…

📰

营口哪里可以考电工证 2026河南最新政策怎么应对证书过期问题

营口哪里可以考电工证 2026河南最新政策怎么应对证书过期问题 证书过期了不知道怎么复审延期?你不是一个人。最近有朋友私信我说,他手里的低压电工证已经快到期了,但不知道怎么操作,怕一不小心耽误了工作机会。这其实是个很常见的问题,特别是在20…

📰

没有电工证别想上岗!天津电工作业试题怎么拿?全国通用证书拿在手

没有电工证别想上岗!天津电工作业试题怎么拿?全国通用证书拿在手 现在找工作,没特种作业证,连门都进不去。尤其是电工这个岗位,基本每个工地、工厂、维修单位都要求持证上岗。而天津电工作业试题,就是你拿下低压或高压电工证的关键一步。别再等了,现在…

📰

抚州中级电工证过期了不知道怎么复审?通过率揭秘帮你避坑

抚州中级电工证过期了不知道怎么复审?通过率揭秘帮你避坑 证书过期了不知道怎么复审延期,这事儿真让不少人头疼。尤其是像抚州中级电工证这类高含金量的证书,一旦过期就等于失去从业资格,直接影响收入甚至工作。今天就来揭秘抚州中级电工证的通过率,帮你…

📰

验电工证上哪里验 怎么报名不被中介坑

验电工证上哪里验 怎么报名不被中介坑 不知道去哪报名怕被中介坑,这事儿真不假。尤其是像你这样在信阳房建工程一线干活的,电工证缺了就等于不能上手干活,但一不小心就掉进中介的“报名陷阱”里。今天咱们就来说说 验电工证上哪里验 ,以及 怎么报名…

TODAY

今日更新

THIS WEEK

本周精选

THIS MONTH

本月热门

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

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

📞 💬