Merged
fix(cmake): 修复 examples 下 AddOpTestCase 未注册并补齐 add_example UT 的 SOC #13839
fix(cmake): 修复 examples 下 AddOpTestCase 未注册并补齐 add_example UT 的 SOC #13839
Merged
HuangRZzzzAdd on 15 days ago
HuangRZzzz
HuangRZzzzCollaborators
15 days ago

描述

修复 bash build.sh -u --opkernel --ops=add_example 无任何 UT 用例运行的问题(#8321):

  1. cmake/func.cmake:add_category_subdirectory() 中 examples 在算子循环外通过 add_subdirectory(examples) 加载时,宏作用域内 OP_DIR/OP_NAME 仍残留循环最后一次的算子目录,导致 examples 下 AddOpTestCase 误用该目录、在 --ops 过滤时提前 return(),用例注册被静默跳过(所有 SOC 均受影响)。在 add_subdirectory(examples) 前 unset(OP_DIR)/unset(OP_NAME)。
  2. examples/add_example/tests/ut/op_kernel/CMakeLists.txt:注册补齐 Ascend910_9391(A3,注意 tikicpulib 目标名大小写)与 ascend950pr_9599(950),与 add_example_def.cpp 的 AddConfig、README 声明的 A2/A3/950 支持范围一致。

关联的Issue

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

测试

  • 修复前:bash build.sh -u --opkernel --ops=add_example --soc=ascend910_93 -j40 → fastOpTestSocVersions 为空、无 UT 可执行文件、无用例执行(CANN 9.2.0 / aarch64 / master b5949092)。
  • 修复后(同一环境):
    • --soc=ascend910_93 → fastOpTestSocVersions=Ascend910_9391,[ PASSED ] 1 test;
    • --soc=ascend910b → ascend910B1,PASS;
    • --soc=ascend950 → ascend950pr_9599,PASS。
  • kernel UT 为 CPU 仿真(tikicpulib),无需 NPU。

文档更新

无。

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for HuangRZzzz's contribution.)
HuangRZzzzHuangRZzzzCollaborators
15 days ago Created pull request, commit 6b5eaf0c
HuangRZzzzHuangRZzzzCollaborators
15 days ago Associated issue: [Bug-Report|缺陷反馈]: 910C(A3) 按《源码构建》执行 add_example 的 kernel UT 无任何用例运行(AddOpTestCase 未注册)
atomgit-bot
atomgit-bot
15 days ago Comments:

变更摘要

本 PR 修复了在执行 bash build.sh -u --opkernel --ops=add_example 时,examples 下的 kernel UT 用例未被注册、没有任何用例运行的问题。核心原因是 cmake/func.cmake 中 add_category_subdirectory() 在算子循环之外单独加载 examples 时,宏作用域内的 OP_DIR 与 OP_NAME 仍保留循环最后一次的算子目录,导致 AddOpTestCase 复用了错误目录,并在 --ops 过滤时提前 return(),用例注册因此被静默跳过;同时在 add_example 的 UT 配置中补齐了缺失的 SOC 版本注册,使 A2/A3/950 的用例都能被正确构建与执行。

主要改动

  • 清理残留的算子目录变量:在 add_category_subdirectory() 中 add_subdirectory(examples) 之前新增 unset(OP_DIR) 与 unset(OP_NAME),避免 examples 继承算子循环最后一轮的目录与名称而误过滤用例。
  • 恢复 AddOpTestCase 用例注册:变量清理后,examples 下的 AddOpTestCase 不再错误匹配 --ops 过滤条件,kernel UT 能够正常注册并生成可执行用例。
  • 补齐 add_example UT 的 SOC 注册:examples/add_example/tests/ut/op_kernel/CMakeLists.txt 增加 Ascend910_9391(A3,需与 tikicpulib 目标名大小写一致)与 ascend950pr_9599(950)两个 SOC 版本,与 add_example_def.cpp 中的 AddConfig 及 README 声明的 A2/A3/950 支持范围对齐。

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

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

代码审查

✅ 未发现问题


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

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
15 days ago Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
15 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
15 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
cmake ✅ 刘波, 杨阳 (2/2) ✅ 刘波, 杨阳 (2/1)
repo-cann/ops-nn ✅ 刘波, 杨阳 (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

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

likedislike
CANN-robotCANN-robotCollaborators
15 days ago Set zengjuan,sxb154714,chaotang233,crystalhu,yangyang016,fanqirui,chenqi317,LinPX,liubo75,tangweiwei2,pingchuantang as approver
CANN-robotCANN-robotCollaborators
15 days ago Set zengjuan,sxb154714,chaotang233,crystalhu,yangyang016,fanqirui,chenqi317,LinPX,liubo75,tangweiwei2,pingchuantang as approver
HuangRZzzzHuangRZzzzCollaborators
15 days ago Modify description of pull request
HuangRZzzz
HuangRZzzzCollaborators
15 days ago Comments:

compile

likedislike
HuangRZzzzHuangRZzzzCollaborators
15 days ago Pre merge succeeded (commit_id: 3dc06855b6b548795206cc760c8dd0a383d9e810)
CANN-robot
CANN-robotCollaborators
15 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
15 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
15 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
15 days ago Added label: ci-pipeline-failed
HuangRZzzz
HuangRZzzzCollaborators
15 days ago Comments:

compile

likedislike
HuangRZzzzHuangRZzzzCollaborators
15 days ago Pre merge succeeded (commit_id: ec96a2637b8687f56e12c6d4081fa65462a2072c)
HuangRZzzzHuangRZzzzCollaborators
15 days ago Pre merge succeeded (commit_id: f52ea4ec77c2b726f057ddec7d877dd92e2fd69c)
HuangRZzzzHuangRZzzzCollaborators
15 days ago Pushed 1 commits:f51fc78c-style(precommit): 清理 add_example UT CMakeLists 行尾空格并补齐末尾换行
HuangRZzzzHuangRZzzzCollaborators
15 days ago Pre merge succeeded (commit_id: 301160960d965040be3fdec7f6dbd95f5b62bd45)
CANN-robotCANN-robotCollaborators
15 days ago Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
15 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
15 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
15 days ago Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
15 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
15 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
15 days ago Added label: ci-pipeline-passed
yuning_chen
yuning_chenCollaborators
15 days ago Comments:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@chaotang233 @yangyang016 @sxb154714 @LinPX @fanqirui @liubo75 @pingchuantang @zengjuan

likedislike
liubo75
liubo75Collaborators
15 days ago Comments:

/lgtm
/approve
by agent

likedislike
CANN-robotCANN-robotCollaborators
15 days ago Added label: approved
yangyang016
yangyang016Collaborators
12 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
12 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
12 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
12 days ago Merged pull request
丛吉钰丛吉钰Collaborators
5 days ago Deleted associated issue: [Bug-Report|缺陷反馈]: 910C(A3) 按《源码构建》执行 add_example 的 kernel UT 无任何用例运行(AddOpTestCase 未注册)
丛吉钰丛吉钰Collaborators
5 days ago Associated issue: [Bug-Report|缺陷反馈]: add_example kernel UT 在 ascend910_93 上静默零执行且无提示