CANN/GE ES API Relu普通输入示例

发布时间:2026/11/4 22:08:20

CANN/GE ES API Relu普通输入示例 Sample Usage Guide【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge1. Function DescriptionThis sample demonstrates graph construction using Relu operator normal input, aimed at helping graph developers quickly understand normal input definition and usage of this type of operators in graph construction.2. Directory Structurecpp/ ├── src/ | └── CMakeLists.txt // CMake build file | └── es_showcase.h // Header file | └── make_relu_add_graph.cpp // sample file ├── CMakeLists.txt // CMake build file ├── main.cpp // Program main entry ├── README.md // README file ├── run_sample.sh // Execution script ├── utils.h // Utility file3. Usage Instructions3.1. Prepare CANN PackageInstalltoolkitandopspackages correctly following Environment PreparationSet environment variables (assuming package is installed at /usr/local/Ascend/)source /usr/local/Ascend/cann/set_env.sh3.2. Build and Execute3.2.1 Generate ES Interfaces and Build Graph for DUMPSimply run the following command to clean, generate interfaces, construct graph and DUMP graph:bash run_sample.shCurrent run_sample.sh behavior: automatically clean old build, build sample and default execute sample dump. When you see the following message, it indicates successful execution:[Success] sample execution successful, pbtxt dump generated in current directory. The file starts with ge_onnx_ and can be opened in netron for display3.2.2 Output File DescriptionAfter successful execution, the following files will be generated in current directory:ge_onnx_*.pbtxt - protobuf text format of graph structure, can be viewed with netron3.2.3 Build Graph and ExecuteBesides basic graph construction and dump functionality, esb_sample supports building graph and actually executing computation.bash run_sample.sh -t sample_and_runThis command will:Automatically generate ES interfacesCompile sample programGenerate dump graph, run graph and output computation resultsAfter successful execution, you will see:[Success] sample_and_run execution successful, pbtxt and data output dump generated in current directoryYou can view computation results through data file3.3. Log PrintingIf you need log printing to assist debugging during executable program execution, you can set the following environment variables beforebash run_sample.shto 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 you need to DUMP graph to assist debugging graph compilation process during executable program execution, you can set the following environment variables beforebash run_sample.sh -t sample_and_runto DUMP graph to execution path:export DUMP_GE_GRAPH24. Core Concepts Introduction4.1. Graph Construction StepsCreate graph builder (provides context, workspace and construction-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 computation result endpoints)4.2. Normal InputConcept Explanation:Normal input refers to operator input that is mandatory input with fixed input count.Graph Construction API Features:Input type must match type constraint declared during operator registration, ES API will perform type checking during graph constructionFor example, Relu operator prototype is shown below, ES graph construction generated API is Relu(), supporting use in C and CREG_OP(Relu) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, DT_INT32, DT_INT16, DT_INT64, DT_UINT8, DT_UINT16, DT_QINT8, DT_BF16})) .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, DT_INT32, DT_INT16, DT_INT64, DT_UINT8, DT_UINT16, DT_QINT8, DT_BF16})) .OP_END_FACTORY_REG(Relu)Its corresponding function prototype is:Function name: Relu(C) or EsRelu(C)Parameters: 1 in total, which is xReturn value: output yC API:EsCTensorHolder *EsRelu(EsCTensorHolder *x);C API:EsTensorHolder Relu(const EsTensorLike x);Note: Use TensorLike type to express input, to support case where actual parameter can directly pass numeric values【免费下载链接】geGEGraph Engine是面向昇腾的图编译器和执行器提供了计算图优化、多流并行、内存复用和模型下沉等技术手段加速模型执行效率减少模型内存占用。 GE 提供对 PyTorch、TensorFlow 前端的友好接入能力并同时支持 onnx、pb 等主流模型格式的解析与编译。项目地址: https://gitcode.com/cann/ge创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
延伸阅读

更多相关文章

2026/11/5 1:16:05

中国式报表难在哪?观远BI如何破解复杂格式与自助分析难题

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

2026/11/2 4:31:55

CANN/ge HcomAllReduce多卡图构建示例

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

2026/11/3 9:00:49

无官网也能做GEO?一文搞懂生成式引擎优化的底层逻辑与落地路径

1. 先搞清楚一件事:GEO 到底优化的是什么先说个最常见的误解。很多人一听到“AI 搜索引擎优化”,第一反应就是“我得有个网站,然后让 ChatGPT、Perplexity 这些 AI 引擎能抓取到我的页面”。这个想法没错,但它只覆盖了一半场景——…

2026/11/5 12:14:29

Stimulsoft Reports 2019.2.2 落地指南:老系统兼容与版本陷阱规避

简介:Stimulsoft Reports 2019.2.2 是一款面向.NET开发者的专业报表控件,适用于WinForms、ASP.NET及WPF平台,帮助开发者快速构建数据可视化报表与打印输出功能,尤其适合中高级C#工程师在企业级管理系统、BI看板或财务报表模块中集…

2026/11/5 12:14:29

H110/B250主板BIOS魔改:CPU微码、ME与刷写校验全流程

简介:面向希望为 B150、B250、H110 等老主板扩展 Intel 8/9 代 CPU 兼容性的 DIY 玩家与装机爱好者,这份 BIOS 魔改工具包提供了一套较完整的固件修改辅助材料,适合具备一定硬件基础、了解刷写风险的用户在做好备份与稳定供电的前提下研究使用…

2026/11/5 12:14:29

GD32E10x官方例程入门:从点灯到外设调试全流程

简介:这份GD32E10x系列官方例程面向使用兆易创新GD32E10x系列MCU的嵌入式开发者与初学者,基于ARM Cortex-M3内核,集合了从基础外设到通信、电机控制等场景的示例代码,可用于快速理解芯片用法并搭建工程。压缩包共935个文件&#x…

2026/11/5 12:09:24

潍坊高纯氢氧化镁生产厂家怎么选:泽隆新材料靠谱商家测评排名

潍坊高纯氢氧化镁怎么选不踩坑:从产能、品控到定制能力,一篇讲透靠谱厂家的判断标准采购高纯氢氧化镁、阻燃级氢氧化镁,最怕的不是价格高,而是批次不稳、指标浮动、交期失控。尤其是做线缆料、橡胶制品、阻燃母粒的企业&#xff0…

2026/11/4 12:38:23

面向复杂光照与角度的宠物面部识别鲁棒性增强策略

在智慧养宠时代,基于视觉的宠物身份识别技术正逐步从实验室走向家庭应用。然而,与配合度高的人类不同,宠物是典型的“非合作生物识别对象”——它们不会主动配合摄像头调整姿态,更无法控制光照环境。实际应用中,我们常…

2026/11/4 21:04:25

SSM电子书店源码全解析:结构、原理、部署与排错实战

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

2026/11/5 0:02:07

多智能体协作系统架构设计与实践优化

1. 多智能体协作系统的时代背景2017年Transformer架构的诞生彻底改变了人工智能的发展轨迹。当行业还沉浸在单一大模型带来的性能突破时,Anthropic的研究团队已经将目光投向了更前沿的领域——如何让多个智能体通过协作产生超越单体能力的系统智能。这就像交响乐团中…

2026/11/5 0:02:07

大模型系统性入门实战指南:从原理到部署微调的全链路路线

提到大模型的系统性入门,我先说个结论:这事真不难,难的是资料太散、路线太多,今天这个框架明天那个工具,新人很容易在“收藏夹吃灰”和“教程看到一半放弃”之间反复横跳。市面上关于大模型的内容少说有几十万篇&#…

2026/11/5 0:02:07

鸿蒙文件系统沙箱机制解析与开发实践

1. 鸿蒙文件系统沙箱机制深度解析作为一名从Android转向鸿蒙开发的工程师,我深刻体会到文件系统访问是迁移过程中最先遇到的"拦路虎"。在Android上运行良好的文件读写代码,在鸿蒙真机环境却频频出现文件写入后神秘消失或直接抛出权限拒绝错误的…

2026/11/4 12:38:23

面向复杂光照与角度的宠物面部识别鲁棒性增强策略

在智慧养宠时代,基于视觉的宠物身份识别技术正逐步从实验室走向家庭应用。然而,与配合度高的人类不同,宠物是典型的“非合作生物识别对象”——它们不会主动配合摄像头调整姿态,更无法控制光照环境。实际应用中,我们常…

2026/11/4 21:04:25

SSM电子书店源码全解析:结构、原理、部署与排错实战

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

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑