已合并
修复matmul ut 编译失败的问题 #8409
yang-di52创建于 19 天前
修复matmul ut 编译失败的问题 #8409
已合并
yang-di52创建于 19 天前
yang-di52成员
19 天前

描述

  1. 删除冗余的测试代码
  2. build.sh build ut 增加-k,即使ut失败,任可以继续构建,最后报错

关联的Issue

#4734

测试

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yang-di52 的贡献)
Yyang-di52成员
19 天前 创建了 pull request,commit f4fe979b
atomgit-bot
atomgit-bot
19 天前 评论:

变更摘要

该 PR 旨在解决 ophost 单元测试在 910b 平台上全量执行失败的问题。核心思路是清理项目中的冗余 CMakeLists.txt 文件,并完整移除已废弃的 ophost_metric_managerophost_metric_loader 模块。变更涉及 20 个文件,均为删除操作(共删除 224 行,无新增),主要包括:删除 ophost_metric_manager 的所有源文件(.cpp.h.proto)及其 CMake 构建入口;删除 ophost_metric_loader 插件及其构建配置;清理 operators/python/plugins/ 下多个子目录的冗余 CMakeLists.txt;从 collect_data.c 中移除 ophost_metric_loader 的动态加载与初始化逻辑;同步调整 Python 单元测试用例以适配上述模块的移除。

主要改动

  • 移除 ophost_metric_manager 模块:完整删除 source/managers/host/internal/ophost_metric_manager/ 目录下的 6 个文件(collect_metric_data.cpp/.hhost_metric_data.cpp/.hophost_metric_manager.cpp/.hophost_metric_manager.proto)以及 source/managers/host/ophost_metric_manager/ 下的 CMakeLists.txtophost_metric_manager.h,同时从 source/managers/host/internal/CMakeLists.txt 中移除对应的 add_subdirectory 指令。

  • 移除 ophost_metric_loader 插件:删除 operators/python/plugins/ophost_metric_loader/CMakeLists.txt 构建文件,并从父级 operators/python/plugins/CMakeLists.txt 中移除 add_subdirectory(ophost_metric_loader) 调用,彻底解除该插件的编译。

  • 清理 collect_data.c 中的 metric 集成逻辑:在 source/manager/host/collect_data.c 中删除 ophost_metric_manager.h 头文件引用、ophost_metric_loader 动态库的加载代码以及对 OphostMetricInit/OphostMetricDestroy 的调用,同时移除 source/manager/host/CMakeLists.txt 中与 ophost_metric_loader 相关的链接配置和安装步骤。

  • 清理 operators/python/plugins/ 下的冗余 CMakeLists:删除 tf_adaptercmytf_adapterophosthv_mmu_gda 四个子目录的独立 CMakeLists.txt 文件,并精简父级 CMakeLists.txt 中的 add_subdirectory 条目;同步从 ascend_npu/CMakeLists.txt 中移除 add_subdirectory(ophost)

  • 调整 Python 单元测试用例:在 tests/ut/test_ascend_npu/ 下的多个测试文件中移除 'ophost' 相关测试参数、删除 ophost_metric 相关测试用例,并调整 test_npu_profile.py 中部分测试的预期行为(如将 assertRaises 替换为直接断言),以适配上述模块的删除。

likedislike
atomgit-bot
atomgit-bot
19 天前 评论:

代码审查

我已经完成了全面的分析。以下是审查摘要。


审查摘要

发现的问题

优先级 数量 说明
P2 1 五个操作符的 arch35 tiling 单元测试因 CMakeLists.txt 删除而永久丢失

详细分析

删除分类:

  • 15 个文件:删除操作安全。这些文件要么是真正的冗余文件(父级 add_modules_ut_sources 已处理),要么已经是死代码(父级无 add_subdirectory 遍历导致从未被包含),要么是空/无操作文件。

  • 5 个文件存在问题(已报告的 P2 发现项):norm/lp_norm_updateoptim/apply_adam_v2optim/fused_mul_apply_momentumoptim/inplace_apply_keras_momentumloss/soft_margin_loss_grad。这些操作符的父级 op_host/CMakeLists.txt 没有调用 add_modules_ut_sources(),完全依赖 add_subdirectory 遍历来包含其 arch35 测试。删除后,这些测试将永远不会被编译——即使在显式设置 ASCEND_COMPUTE_UNIT=ascend950 的情况下也是如此。

总体风险评估

对于修复 910b 上 ophost UT 全部执行失败的主要目标,此更改是正确且有效的。根本原因是:当在未设置 ASCEND_COMPUTE_UNIT 的情况下构建时,add_subdirectory 遍历会无条件地包含所有 arch 目录的 CMakeLists.txt 文件,导致仅适用于 ascend950 的 arch35 测试在 910b(arch22)上编译并运行,从而引发空指针崩溃。删除这些 CMakeLists.txt 文件后,arch35 测试仅在通过父级 add_modules_ut_sourcestarget_dir glob 机制显式设置 ASCEND_COMPUTE_UNIT 时才会被包含。

然而,有五个操作符的 tiling 测试没有通过父级的 add_modules_ut_sources 覆盖——它们将完全丢失。这些测试需要在父级 CMakeLists.txt 中恢复,并添加合适的架构守卫,或者恢复其 arch35 CMakeLists.txt 并添加 ASCEND_COMPUTE_UNIT 守卫。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
19 天前 评论:

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
matmul 范其瑞, 陈琦 (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

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

likedislike
CANN-robotCANN-robot成员
19 天前 将zengjuan,sxb154714,chenfeng61,chaotang233,kevin_huang1234,FelixTang7,crystalhu,yu-xinjie62,yangyang016,fanqirui,renruhai,su-yueming,zhajianqing123,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,liuyang_806,liuchuangdev设为评审人
此处折叠了14条事件消息 查看更多
Yyang-di52成员
14 天前 修改标题为 “修复matmul ut 编译失败的问题”,原标题为“删除冗余的CMakeList文件,解决ophost ut 910b全量执行失败的问题”
yang-di52成员
14 天前 评论:

compile

likedislike
Yyang-di52成员
14 天前 update merge request[project id: 7665709, iid: 8409, commit_id: 6a3f2a9867ec48338757b4fe36a671b709f13899] virtual merging success
CANN-robotCANN-robot成员
14 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
14 天前 评论:

流水线任务触发成功
任务链接 [805947498d984cf4bf76b39034516924][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_harmony-infer-chs-nn ✅ SUCCESS
UT_Test_harmony-infer-chs-nn-1 ✅ SUCCESS
UT_Test_harmony-infer-cpro-nn ✅ SUCCESS
UT_Test_report_lcov ✅ SUCCESS >>>>>

[2026-08-12 10:41:49]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
14 天前 评论:

流水线任务触发成功
任务链接 [bcbd6c9178fc454db8e7442fb1c0c26e][流水线指导]

任务名称状态日志下载链接
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>

[2026-08-12 10:20:57]    CI执行结束

likedislike
CANN-robotCANN-robot成员
14 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
14 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
14 天前 添加了label:ci-pipeline-passed
Yyang-di52成员
14 天前 修改了pull request 的描述
Yyang-di52成员
14 天前 修改了pull request 的描述
chenqi317成员
14 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
14 天前 添加了label:approved
范其瑞
范其瑞成员
14 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
14 天前 添加了label:lgtm
CANN-robotCANN-robot成员
14 天前 关闭了关联的issue
CANN-robotCANN-robot成员
14 天前 合入了pull request