恒美微站 Logo 恒美微站
  • 首页
  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心
  • 联系我们

GE图引擎AddZeroPass Python示例指南

  • 首页
  • 资讯中心
  • /
  • GE图引擎AddZeroPass Python示例指南

相关资讯

CANN/ge GraphProcessPoint API文档 2026/9/10 4:40:14
Astra循环推理:用时间换空间的潜空间精修范式 2026/9/10 4:40:14
Agentic Engineering实战指南:从Demo到高可用生产的全套装备 2026/9/10 4:35:14

最新资讯

.NET 6 Web API生产级项目结构与容器化部署指南
数字后端CTS实战:时钟信号物理建模与skew控制全解析
Vue3生产级项目搭建:调试、部署与权限系统实战
Reflex 生产部署实战:基于 Caddy 单端口静态导出与多阶段构建(production-one-port)
OpenHuman 模型层迁移 Phase 3:RouterProvider 到 crate ModelRegistry 的设计、验证与落地全解
Qt构建AGV调度系统:高性能地图渲染与实时路径规划

今日推荐

AI搜索重构内容生态:企业从“流量争夺”转向“答案共建”
AI搜索的信任缺口:企业内容如何在答案时代自证可信
Spring Boot+Vue+Node.js售后服务系统开发实战

本周热门

超人会飞不算本事:系统稳定依赖清晰规则与边界设计
超人VS蜘蛛侠:拆解超级IP的影响力与传播方法论
基于CNN的调制信号识别:MATLAB实现时频图分类实战

本月精选

自研推理加速器Redwood:两周内实现PyTorch模型高效部署的实战教程
V4L2摄像头采集实战:从camera_client.rar到出图全流程解析
从“谁发明了钢琴键”到知识问答智能体:RAG与记忆工程实践

GE图引擎AddZeroPass Python示例指南

发布时间:2026/9/10 4:40:14
GE图引擎AddZeroPass Python示例指南 AddZeroPass Python Sample Usage Guide【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/geFeature DescriptionThis directory provides two pure PythonPatternFusionPasssamples:src/python_add_zero_pass_const_value_match.pysrc/python_add_zero_pass.pyThe two samples have different purposes:python_add_zero_pass_const_value_match.pyDemonstrates Python V1PatternMatcherConfigBuilder.enable_const_value_match()Front-loadsAdd(x, 0.0f)to matcher phase via strict const-value-matchpatternmethod uses Python expression to describe strictly matchedAdd(x, 0.0f), e.g.,return inputs[0] 0.0CurrentConstantMatcher::IsMatchvalue matching is strict binary match without floating-point tolerance or cross-dtype normalizationBetter suited as matcher_config example than fully equivalent version of C samplepython_add_zero_pass.pyMain logic aligned with C pass samplepatternmethod uses Python expression to describeData Consttopology, e.g.,return inputs[0] 0Multi-input pattern can explicitly declare input count viax, y, z inputs[:3]Multi-pattern pass can declare multiplepatternmethods; legacypatterns(self)returning multiplePattern/Graphstill compatiblepatternmethod cannot be used simultaneously withpatterns(self)to avoid ambiguous pattern declaration sourcesPython pass framework automatically createsGraphBuilder, sets graph outputs, and auto-captures in visited inputs,returnoutputs order; legacy explicitGraphBuildersyntax still compatiblemeet_requirements()explicitly reads matchedConst.valueand judges zero value per same rules as C sampleCurrently supportsDT_FLOAT,DT_DOUBLE,DT_INT32consistent with C sampleRecommended expression pattern syntax:from ge.passes import PatternFusionPass, pattern class PythonAddZeroPass(PatternFusionPass): pattern def add_zero(self, inputs): return inputs[0] 0 def replacement(self, inputs): return inputs[0]Directory Structurepython/ ├── README.md // Python sample documentation ├── CMakeLists.txt // Build script for generating es_all Python ES API ├── src │ ├── python_add_zero_pass.py // Python pass implementation file │ ├── python_add_zero_pass_const_value_match.py // const value match examplePrerequisitesCANN environment variables configured viasource ${ASCEND_PATH}/set_env.sh, see C sample README environment configuration stepsCANN software package installation per Environment preparationGraph compilation flow Python dependencies installed:attrs,decorator,sympy,numpy,psutil,scipyrun package includes GE Python runtimege_pywheel, no need to install separatege_py-*.whl. Python pass runtime loadspybind11-based precompiled binary components. CANN package provides artifacts matching current Python version; if no match, fallback compilation occurs automatically. Fallback compilation requirespybind11installed in current Python environment.UsageSet Python pass plugin path:export ASCEND_GE_PY_PASS_PATH$(pwd)/src/python_add_zero_pass_const_value_match.pyFor version aligned with C main logic:export ASCEND_GE_PY_PASS_PATH$(pwd)/src/python_add_zero_pass.pyFollow C sample README program execution section for verification. For offline scenarios, replaceatccommand in C README withpyatc; both have identical command-line parameters,pyatcruns in current Python interpreter process.Notes:These two samples are not standalone execution scripts, directly runningpython src/python_add_zero_pass.pyorpython src/python_add_zero_pass_const_value_match.pywont trigger pass executionExpected output prints after GE compilation flow actually loads this Python passExpected LogsAfter successful execution, logs show similar output (actual input_0 name may differ):[PythonAddZeroConstValueMatchPass] matchedPythonAddZeroConstValueMatchPass_add_zero_pattern capturedinput_0:0 [PythonAddZeroPass] matchedPythonAddZeroPass_add_zero_pattern capturedinput_0:0 const_dtypeDT_FLOAT zeroTrue【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

关于恒美微站

恒美微站专注于为个体商户、工作室提供极简自助建站服务,让每个人都能轻松拥有专业网站。

快速链接

  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心

服务项目

  • 可视化建站
  • 拖拽编辑
  • 主题定制
  • SEO 优化
  • 网站托管

联系方式

  • 📍 地址:北京市朝阳区建国路 88 号
  • 📞 电话:400-888-8888
  • ✉️ 邮箱:info@hmyw.cn
  • 🕐 时间:周一至周日 9:00-18:00

© 2024 恒美微站 hmyw.cn 版权所有 | 京 ICP 备 12345678 号