Closed
[Bug-Report|缺陷反馈]: 910C(A3) 按《源码构建》执行 add_example 的 kernel UT 无任何用例运行(AddOpTestCase 未注册) #8321
HuangRZzzzAdd on 15 days agoClosed at 12 days ago
15 days ago Associated pull request
HuangRZzzz
15 days ago Comments:
15 days ago Comments:
已提交修复 PR:#13839(https://gitcode.com/cann/ops-nn/pulls/13839)——`cmake/func.cmake` 在加载 examples 前清理残留的 OP_DIR/OP_NAME;examples/add_example/tests/ut/op_kernel/CMakeLists.txt 注册补齐 Ascend910_9391(A3)与 ascend950pr_9599(950)。本地验证:--soc=ascend910_93/ascend910b/ascend950 均 [ PASSED ] 1 test。


15 days ago Modify description of issue
15 days ago Assign HuangRZzzz as responsible person
12 days ago Close issue
12 days ago changed custom state from 进行中 to 已完成
12 days ago Added label: resolved
5 days ago Deleted associated pull request: fix(cmake): 修复 examples 下 AddOpTestCase 未注册并补齐 add_example UT 的 SOC
5 days ago Deleted associated pull request: fix(cmake): 修复 examples 下 AddOpTestCase 未注册并补齐 add_example UT 的 SOC
Describe the current behavior / 问题描述
在 910C(Atlas A3,
--soc=ascend910_93)按《源码构建》(docs/zh/install/compile.md「本地验证」)执行 add_example 的 kernel 侧 UT:构建成功(
Built target nn_op_kernel_ut),但没有任何用例被执行(无 gtest 输出、build 目录下无 UT 可执行文件),fastOpTestSocVersions为空。根因分析
cmake/func.cmake的add_category_subdirectory()中,examples 相关目录是在算子循环之外通过add_subdirectory(examples)加载的;此时宏作用域内OP_DIR/OP_NAME仍残留循环最后一次迭代的算子(实测为control/update_tensor_desc)。examples 下的AddOpTestCase(add_example ...)因而走OP_NAME_DIR=${OP_DIR}分支,list(FIND ASCEND_OP_NAME update_tensor_desc)在--ops=add_example过滤下得到 INDEX=-1,直接return(),用例注册被静默跳过(该问题对所有 SOC 均存在)。examples/add_example/tests/ut/op_kernel/CMakeLists.txt仅注册ascend910B1;而examples/add_example/op_host/add_example_def.cpp的AddConfig与 README 均声明支持 A2(ascend910b)/A3(ascend910_93)/950(ascend950)。即使问题 1 修复,A3/950 上仍无法命中用例。复现与证据(CANN 9.2.0 / aarch64 / master b5949092)
bash build.sh -u --opkernel --ops=add_example --soc=ascend910_93 -j40 grep fastOpTestSocVersions build/CMakeCache.txt # 为空 find build -name "nn_op_kernel_ut*" # 无 UT 可执行文件 # 在 examples/add_example/tests/ut/op_kernel/CMakeLists.txt 增加调试打印可见残留值: # OP_NAME=update_tensor_desc OP_DIR=.../control/update_tensor_descDescribe the expected behavior / 预期结果
--soc=ascend910_93(910C/A3)上能注册并执行 add_example 的 kernel UT 用例;add_example_def.cpp/README 声明的 A2/A3/950 支持范围一致。修复建议
cmake/func.cmake的add_category_subdirectory()在add_subdirectory(examples)前unset(OP_DIR)/unset(OP_NAME);examples/add_example/tests/ut/op_kernel/CMakeLists.txt的注册补齐 A3/950(注意 tikicpulib 目标名大小写):AddOpTestCase(add_example "ascend910B1;Ascend910_9391;ascend950pr_9599" "")。本地验证(已按上述修复):
--soc=ascend910_93→fastOpTestSocVersions=Ascend910_9391,[ PASSED ] 1 test;--soc=ascend910b→ascend910B1,PASS;--soc=ascend950→ascend950pr_9599,PASS。(若某算子确实不支持当前硬件,建议在 UT 注册处或文档显式说明;本 issue 中 add_example 属于“支持但未注册”。)