Merged
fix: migrate L2Normalize and INTrainingReduceV2 inference #12515
fix: migrate L2Normalize and INTrainingReduceV2 inference #12515
Merged
raoliang_sacAdd on 20 days ago
raoliang_sacCollaborators
20 days ago

描述

从 https://gitcode.com/cann/ops-nn/pull/12376 独立拆出L2Normalize与INTrainingReduceV2的全部18个变更文件;原PR保留SGD、Relu6Grad、NormalizeBBox。本PR直接基于主仓master,不需要先合入#12376。

L2Normalize

  • 删除原生V1 InferShape注册,保留VERIFY_FUNC_REG;在推导覆盖前验证原始输出shape、dtype、输入rank及ND格式。
  • V2 shape增加空context/描述及ND校验,允许覆盖空的或前次残留的输出缓冲;保留动态维、未知rank及空Tensor处理;dtype推导返回输出写入状态。
  • 新增Graph UT、调整Host UT,并提供GEIR回归CSV。
  • GE示例检查唯一输出的shape、dtype、256字节缓冲及全部64个数值;全1输入期望0.25,拒绝非有限值及误差超出1e-6的结果。
  • 修复独立GE示例CMake被add_op_subdirectory()自动带入生产Host配置的问题:在文件开头判断是否作为顶层工程配置,嵌套加载时直接返回;独立示例继续检查并链接GE库。解决源码集成Host配置意外查找已安装libgraph.so的报错,不修改公共扫描宏。

INTrainingReduceV2

  • 删除op_graph中自带的V1 shape实现和注册,保留现有V2 shape/dtype及公共推导逻辑。
  • 补充注册入口的格式/rank、动态维、非法输入、重复推导输出覆盖等Graph UT。
  • Tiling、Kernel和UT中清理不存在的DESIGN/spec引用,保留有效的分块、UB和归约说明;tests/CMakeLists.txt注释改为实际golden与ops-test-kit入口。Tiling/Kernel算法不变。

L2Normalize的canndev旧注册隔离依赖 https://gitcode.com/cann/canndev/pull/82602;INTrainingReduceV2的canndev隔离已在主线,本PR删除其原生V1。需要在包含配套修改的CANN中验证,不要求等待官方发布包。

关联的Issue

https://gitcode.com/cann/ops-nn/issues/6956

测试

  • 拆分前完整提交:fcf476d309601677497a93823edbeff8c8e5dbfb。按路径分割后,两个分支重组的Git tree和完整binary diff与原提交一致,没有丢失或增加改动。
  • 拆分分支rebase到本次获取的主仓master 579aede0519a1c70364ec49c5c78591f6fb7eff4,拆分时各自patch不变。随后仅对L2示例CMake增加5行入口隔离保护;当前单提交为c58fe381c3e87fff5cddf938fae27171f41f61c0。pre-commit/OAT及diff检查通过。
  • 用仓库真实add_op_subdirectory()宏构造配置探针:旧CMake在未提供安装CANN的目录下复现GRAPH_LIBRARY/libgraph.so首错;修复后同条件配置通过,未产生示例目标。该探针隔离了源码收集函数,不作为完整Host编译结果。
  • 在July CANN_Revise中以干净构建目录配置、编译、链接独立L2示例通过,构建并行度8;未执行示例二进制或NPU/TTK。此次只修改构建入口,未修改示例源码或链接方式。
  • CI-skills已补充Host隔离检查并推送master 72537d736a7d3d9a06f231c17cd613404f7cd9ed:加载真实本地CANN时,新增检查仍拦住旧代码、允许修复代码;56项Python回归及完整工具shell回归通过。独立构建缺GE库仍正确失败,保护不会让独立示例空跑。
  • 本轮完成上述必要构建回归,没有重跑拆分后两PR的完整本地CI或算子UT;原完整提交的950/A2本地CI通过仅作为历史记录,不计作当前SHA或线上CI的通过结果。
  • 既有设备证据:July兼容提交0415d02e的INTrainingReduceV2 6条、L2Normalize 7条GEIR用例,各执行静态/动态路径;L2的2条空Tensor只计执行/shape。L2原始声明shape不一致和标量输入均由真实GE校验拒绝。该历史结果不能代替当前完整迁移的配套CANN集成验证。
  • 仍有已知事项:配套canndev修改尚未安装进入受测CANN;另一设备INTrainingReduceV2仍受安装包Tiling芯片不支持限制;本次修改的线上CI结果尚未确认。上述构建修复不代替配套CANN集成验证。

文档更新

仅带走这两个算子的相关源码/测试注释,无README新增章节或冗余编译命令。

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for raoliang_sac's contribution.)
Rraoliang_sacCollaborators
20 days ago Created pull request, commit 2aa122aa
Rraoliang_sacCollaborators
20 days ago Associated issue: [Bug-Report|缺陷反馈]: 完成原生推导注册迁移及正式包集成验证
atomgit-bot
atomgit-bot
20 days ago Comments:

变更摘要

本 PR 将 L2Normalize 与 INTrainingReduceV2 两个算子的图推导迁移从原 PR 中拆出,核心是把图编译期的推导职责从旧式 V1 注册改为 Runtime 2.0 接口:L2Normalize 删除 COMMON_INFER_FUNC_REG,改由 VERIFY_FUNC_REG 承载声明阶段校验,并在 InferShape 中补充格式与空 context 校验;INTrainingReduceV2 删除 op_graph 中自带的 V1 shape 实现与注册,仅保留 Runtime 2.0 的 shape/dtype 推导。配套清理了 tiling/kernel 中对已不存在的 DESIGN/spec 引用,并新增/调整 Graph UT、Host UT 及 GEIR 示例的数值校验。

主要改动

  • L2Normalize 推导入口由 V1 改为 Verify:l2_normalize_graph_infer.cpp 删除 L2NormalizeGraphInferFunc 与 COMMON_INFER_FUNC_REG 注册,改为实现 VerifyL2Normalize 并注册 VERIFY_FUNC_REG,在推导覆盖输出描述前校验原始声明的 shape、dtype、rank 与 ND 格式。
  • L2Normalize InferShape 增加格式与空 context 校验:l2_normalize_infershape.cpp 新增 IsSupportedFormat 判断,要求输入/输出为 FORMAT_ND 或 FORMAT_RESERVED,并对 context 及输入输出 tensor desc 做空检查;InferDataTypeForL2Normalize 增加空 context 返回 GRAPH_FAILED。
  • INTrainingReduceV2 删除旧式 V1 shape 实现:in_training_reduce_v2_graph_infer.cpp 移除 INTrainingReduceV2LegacyV1InferShape 及对应 COMMON_INFER_FUNC_REG,仅保留 Runtime 2.0 推导逻辑。
  • 补充与调整 UT 覆盖新推导行为:新增 test_l2_normalize_graph_infer_pass.cpp 验证 dtype 透传、输出描述覆盖及 Verify 对冲突 shape/dtype/非 ND 格式/标量或超 8 维的拒绝;test_in_training_reduce_v2_graph_infer_pass.cpp 新增注册入口的格式/rank、动态维、非法输入与重复推导覆盖用例;Host UT 增加重复输出 shape、未知/部分 shape 及非 ND 格式用例。
  • GE 示例与注释清理:test_geir_l2_normalize.cpp 新增 CheckOutput,校验唯一输出的 shape、dtype、缓冲区大小与全部数值(全 1 输入期望 0.25,拒绝非有限值及误差超 1e-6);tiling/kernel 与 UT 注释中删除 DESIGN/spec 引用并改为描述实际实现。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
20 days ago Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
20 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
20 days ago Comments:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
norm ✅ 陈展熹, 钱泽洪 (2/2) ✅ 陈展熹, 钱泽洪 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

raoliang_sac, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
20 days ago Set zengjuan,u010470851,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,wangrui_,renruhai,su-yueming,zhajianqing123,yourealize,chenqi317,wang-xing001,liubo75,tangweiwei2,chenxingyu18,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong as approver
6 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
20 days ago Added label: cann-cla/yes
raoliang_sacCollaborators
20 days ago Comments:

compile

likedislike
Rraoliang_sacCollaborators
20 days ago Pre merge succeeded (commit_id: 1e41012f09f65db25017cf1282e558198e8e0f29)
CANN-robot
CANN-robotCollaborators
20 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
20 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
20 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
20 days ago Added label: ci-pipeline-passed
yuning_chen
yuning_chenCollaborators
20 days ago Comments:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@fanqirui @u010470851 @wang-xing001 @wangrui_ @yangyang016 @kevin_huang1234 @qianzehong @liujie12345678

likedislike
陈展熹Collaborators
20 days ago Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
20 days ago Added label: approved
qianzehongCollaborators
19 days ago Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
19 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
19 days ago Merged pull request