已合并
refactor(aicpu_common): 头文件源码目录整改 #710
refactor(aicpu_common): 头文件源码目录整改 #710
已合并
Ding_Jing创建于 19 天前
Ding_Jing
Ding_Jing成员
19 天前

描述

pkg_inc/op_common/aicpu_common/context35 个头文件按「谁在用」拆分到两处,使对外契约面与 opbase 内部实现在源码目录上物理隔离。头文件内容零改动,全部为 git mv 重命名。

分类 数量 新位置
opbase 私有 17 aicpu_common/context/{common,cpu_proto}/(与对应 .cc 同级)
对外公开 18 include/op_common/aicpu_common/context/{common,cpu_proto,cust_op,utils}/

公开集 18 = 15 个被 ops-cv/ops-math/ops-nn/ops-transformer 直接 include + 3 个传递依赖(cpu_kernel_register.hdevice_cpu_kernel.hnode_def_builder.hlog_weak.hlog.h)。已验证该集合闭合:没有任何公开头 include 私有头,依赖方向单向为 私有 → 公开。

硬约束:装包产物零变化。 装包目的地路径一律不动,cmake/package.cmake 只改 install 的源路径opbase.xml / AicpuCommonInc.xml 无需改动,下游四仓零感知。

配套构建改动(2 个文件):

  • aicpu_common/context/CMakeLists.txtaicpu_context_headers 的 include 目录 4 → 8。必需——.cc 里的 include 全是裸文件名,跨目录必须显式在 path 上。
  • cmake/package.cmake 三处:
    1. pkg_inc/aicpu_common 装包拆为「公开侧整目录 install + 私有 17 头 install(FILES ... PERMISSIONS)」,合并回同一目的地。私有侧不能整目录装——该目录下还有 .cc/.cpp/.proto/CMakeLists.txt,以及不属于交付集、原本就不打包的 cust_op/cust_dlog_record.h
    2. aicpu_headers_src 那 8 个路径前缀改为 include/op_common/aicpu_common/context/
    3. include/op_common 整目录 install 新增 PATTERN "aicpu_common" EXCLUDE。必需——否则 18 个公开头会被扫进 $(TARGET_ENV)/include/op_common/aicpu_common/** 产生冗余副本,且 opbase.xml<copy_all>true</copy_all> 会让它们进 .run 包。

关联的Issue

#298

测试

验证环境:远端 aarch64 + CANN 9.2.0(V100R001C11B134),gcc 13.3.0。

1. 完整 .run 编包双向比对(核心验收)

先编改动后版本,再 git reset --hard 回基线提交重编,比对两次 CPack makeself_staging(即打进 .run 的完整文件树):

$ diff -rq baseline after | grep "^Only in"
(无输出:两侧文件集合完全相同)

$ diff baseline.perm after.perm
差异行数: 0

211 个文件中 208 个逐字节一致,其余 3 个全部是构建时间戳产物(.run 自解压包自身、opp/version.infoshare/info/opbase/version.infotimestamp= 行)。权限位 0 差异。

四项重点核对(在真实 .run 内容上):

检查项 期望 实测
pkg_inc/aicpu_common/** 头文件数 35 35 ✅
include/aicpu/ 头文件数 8 8 ✅
include/op_common/ 下无 aicpu_common 实际 log op_graph op_host op_kernel
cust_op/ 未混入 cust_dlog_record.h 实际只有 cust_cpu_utils.h

2. opbase aicpu 编译

目标 强制重编文件数 错误
host aicpu_context_host + aicpu_nodedef_host 30 0
device aicpu_context + aicpu_nodedef + aicpu_cust_log 54 0

(首次 make 报 "Built target" 未真正重编会使验证失效,已 touch 全部 .cc/.cpp 强制重编,上表为强制重编后结果——84 个源文件真实走过新的 8 条 include 路径。)

3. 下游四仓编包,全部通过

产物
ops-math cann-910b-ops-math_9.1.0_linux-aarch64.run
ops-nn cann-910b-ops-nn_9.1.0_linux-aarch64.run
ops-cv cann-910b-ops-cv_9.1.0_linux-aarch64.run
ops-transformer cann-910b-ops-transformer_9.1.0_linux-aarch64.run(全量 --pkg,574 MB)

未覆盖项(如实说明):改动后的 opbase 包未安装进远端 CANN(本包版本 9.0.0、远端 CANN 9.2.0,覆盖安装有降级风险),因此下游四仓构建并未真正消费本次改动的 opbase——但由上述产物零变化的结论,功能上等价。UT / example 未执行;CANN 内部 XML 装包链路未在内部构建上实测。

文档更新

无。本次仅调整源码目录结构与 install 源路径,未涉及对外文档。

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Ding_Jing 的贡献)
Ding_JingDing_Jing成员
19 天前 创建了 pull request,commit 705c1419
Ding_JingDing_Jing成员
19 天前 关联了issue:[Requirement|需求建议]: aicpu_common 头文件按对外可见性拆分源码目录
atomgit-bot
atomgit-bot
19 天前 评论:

变更摘要

本次 PR 将 pkg_inc/op_common/aicpu_common/context 下的 35 个头文件按对外可见性物理拆分到两处目录,实现源码层面 opbase 私有实现与对外公开 API 的隔离。所有头文件内容零改动,均为 git mv 重命名:17 个 opbase 私有头移至 aicpu_common/context/{common,cpu_proto}/ 与对应 .cc 同级,18 个公开头移至 include/op_common/aicpu_common/context/{common,cpu_proto,cust_op,utils}/。配套调整了 CMakeLists.txt 的 include 路径(4→8 条)与 cmake/package.cmake 的 install 源路径,确保装包产物与下游四仓完全零感知。

主要改动

  • 头文件目录按可见性物理拆分:17 个 opbase 私有头(如 async_cpu_kernel.hdevice.hnode_def_impl.h 等)移至 aicpu_common/context/{common,cpu_proto}/ 内部目录,18 个对外公开头(如 cpu_context.hcpu_kernel.hlog.hbcast.h 等)移至 include/op_common/aicpu_common/context/{common,cpu_proto,cust_op,utils}/,依赖方向单向为私有→公开,无公开头 include 私有头。

  • aicpu_common/context/CMakeLists.txt include 路径扩展aicpu_context_headers 的 include 目录从 4 条增加到 8 条,确保 .cc 源文件中的裸文件名 #include 能跨新目录正确解析。

  • cmake/package.cmake 装包源路径适配pkg_inc/aicpu_common 装包拆为公开侧整目录 install(DIRECTORY ...) 与私有侧 17 个头文件的 install(FILES ... PERMISSIONS) 逐个安装,合并回同一目的地,避免私有目录下的 .cc/.cpp/.proto 及原本不打入交付集的 cust_dlog_record.h 被误打包。

  • include/op_common 整目录 install 新增排除规则:新增 PATTERN "aicpu_common" EXCLUDE,防止 18 个公开头被扫入 $(TARGET_ENV)/include/op_common/aicpu_common/** 产生冗余副本,同时避免 <copy_all>true</copy_all>opbase.xml 将它们带入 .run 包。

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

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
19 天前 添加了label:cann-cla/yes
此处折叠了76条消息 查看更多
CANN-robotCANN-robot成员
8 天前 添加了label:approved
sunday成员
8 天前 评论:

/lgtm
/approve

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