Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhoulong50 的贡献)变更摘要
本 PR 主要为 FakeQuantWithMinMaxVars 系列 4 个算子补齐 GE IR 的 C++ 调用 example,全部为新增示例代码。新增的 4 个示例文件分别对应 FakeQuantWithMinMaxVars、FakeQuantWithMinMaxVarsGradient、FakeQuantWithMinMaxVarsPerChannel 和 FakeQuantWithMinMaxVarsPerChannelGradient 算子,演示了基于 GE 接口构造算子图、设置输入输出与属性、创建 Session、执行 RunGraph,并将输入/输出数据落盘和打印结果的过程。
主要改动
- 新增 4 个 GE IR C++ 示例文件:分别新增
test_geir_fake_quant_with_min_max_vars.cpp、test_geir_fake_quant_with_min_max_vars_gradient.cpp、test_geir_fake_quant_with_min_max_vars_per_channel.cpp和test_geir_fake_quant_with_min_max_vars_per_channel_gradient.cpp,用于演示对应算子的 GE IR 调用方式。 - 通过宏构造算子输入输出与属性:各示例使用
ADD_INPUT、ADD_INPUT_ATTR、ADD_OUTPUT宏创建op::Data占位节点,设置num_bits、narrow_range属性,并为算子绑定输入、更新输出描述。 - 新增
CreateOppInGraph构图逻辑:分别实例化FakeQuantWithMinMaxVars、FakeQuantWithMinMaxVarsGradient、FakeQuantWithMinMaxVarsPerChannel、FakeQuantWithMinMaxVarsPerChannelGradient算子,配置x/min/max或gradients/x/min/max输入以及相应输出形状(如{16}或{4, 4})。 - 新增数据生成与落盘辅助函数:增加
GenRandomDataFloat32、GenOnesDataFloat32、WriteDataToFile、GetDataTypeSize、GetTime等辅助函数,用于生成测试数据、写入.bin文件并打印算子输入输出结果。 - 新增
main执行流程:使用ge::GEInitialize初始化、Session::AddGraph添加图、Session::RunGraph运行,并在结束前调用GEFinalize,同时通过aclgrphDumpGraphdump 图信息。


代码审查
审查总结
已完成对全部 4 个新增示例文件的审查,每个文件均发现同类问题(4 个文件结构几乎一致,缺陷同步复制)。
按优先级统计:
- P0:0
- P1:0
- P2:8
- P3:12
- 合计:20
各文件审查确认:
quant/fake_quant_with_min_max_vars/examples/test_geir_fake_quant_with_min_max_vars.cpp— 已审查,发现 5 处问题(argv[1] 无 argc 检查、Data 节点名指针运算、nothrow new 未校验/泄漏、Session 泄漏、fopen/fwrite 未校验)。quant/fake_quant_with_min_max_vars_gradient/examples/test_geir_fake_quant_with_min_max_vars_gradient.cpp— 已审查,发现同样 5 处问题。quant/fake_quant_with_min_max_vars_per_channel/examples/test_geir_fake_quant_with_min_max_vars_per_channel.cpp— 已审查,发现同样 5 处问题。quant/fake_quant_with_min_max_vars_per_channel_gradient/examples/test_geir_fake_quant_with_min_max_vars_per_channel_gradient.cpp— 已审查,发现同样 5 处问题。
整体风险判断: 中低风险。这些是文档性质的 C++ 调用示例,核心算子调用参数(输入/输出名、shape、dtype)与 proto 定义核对一致,不会导致编译错误或算子语义错误;主要问题集中在示例代码自身的健壮性(无参数运行时 UB、错误节点命名、内存泄漏、I/O 返回值未校验),建议修复 P2 项后合入。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 8 |
💬 仅评论


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| quant | ✅ 陈昊文, 苏跃明 (2/2) | ✅ 苏跃明, 陈昊文 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhoulong50_hw, thanks for your pull request. All authors of the commits have signed the CLA. 👍


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


补齐FakeQuantWithMinMaxVars系列4个算子的geir cpp调用example