已合并
【PR】feat: sync develop to master 20260708 #1235
zhanj创建于 7月8日
【PR】feat: sync develop to master 20260708 #1235
已合并
zhanj创建于 7月8日
develop合入到master
zhanj
zhanj成员
7月8日

Pull Request

描述

【PR】feat: sync develop to master 20260708

变更类型

请选择本次引入的变更类型:

关联的Issue

如何测试

描述测试此变更的步骤和前提条件:
1.
2.

核对清单

其他信息

在此添加任何其他关于本次 PR 的说明。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhanj 的贡献)
zhanjzhanj成员
7月8日 添加了label:enhancement
zhanjzhanj成员
7月8日 创建了 pull request,commit 3dbc49ee
atomgit-bot
atomgit-bot
7月8日 评论:

变更摘要

本次 PR 是一个从 developmaster 的同步合并,主要引入了一个 is_default_enabled 平台属性机制,用于标识平台是否为默认启用状态。改动涉及 BasePlatform/PlatformV1/PlatformV2 的构造函数与配置结构体、BackendSpecAutofuseBackendSpec 的数据结构、平台注册宏的重构、GetPlatformConfig() 方法从子类提升到基类,以及脚本权限和文案的修正。同时新增了覆盖多平台、多个测试套件的相关单元测试和系统测试。

主要改动

  • 新增 is_default_enabled 字段贯通整个平台配置链:在 PlatformConfigBackendSpecAutofuseBackendSpec 中均增加了 bool is_default_enabled 字段,并由 PlatformV1/PlatformV2 的构造函数接收该参数,分别传递至三个层级,使上层 API(如 GetAutofuseBackendSpec())也能获取平台默认启用状态。
  • 平台注册机制重构PlatformCreator 类型从原始函数指针改为 std::function<std::unique_ptr<BasePlatform>()>PlatformRegistrar 构造函数新增 is_default_enabled 参数并转发给平台构造函数;注册宏 REGISTER_PLATFORM_V1/REGISTER_PLATFORM_V2 同步增加该参数,最终将 22015102 设为默认不启用、3510 设为默认启用。
  • GetPlatformConfig() 从子类上移至 BasePlatform 基类BasePlatform 新增 protected 成员 PlatformConfig config_GetPlatformConfig() 由纯虚函数改为基类实现的非虚函数直接返回 config_,移除了 PlatformV1PlatformV2 中的重复实现与私有成员。
  • BackendSpec::GetInstance() 容错行为调整:当 PlatformFactory::GetPlatform() 返回 nullptr 时,由原来的 GE_ASSERT_NOTNULL(中止)改为直接返回 nullptr;同时 PlatformFactory::GetPlatform() 在找不到平台时将 GELOGE 降级为 GELOGW,避免误报严重错误。
  • 安装脚本权限与文案修正__pycache__ 目录权限从 550 改为 555(去除属主写权限),安装日志中修正了拼写错误(faiedfailedtegraph_autofusion)。
likedislike
atomgit-bot
atomgit-bot
7月8日 评论:

代码审查

以下是审查总结。

审查总结

我逐一审查了所有 19 个变更文件,以下是结果:

  • autofuse/common/autofuse_backend_spec_api.cpp:在 GetAutofuseBackendSpec() 中新增 is_default_enabled 字段的赋值,与现有模式一致,无问题。
  • autofuse/common/autofuse_backend_spec_api.h:在 AutofuseBackendSpec 中新增 bool is_default_enabled = false;,提供了默认值,正确。
  • autofuse/inc/backend/backend_spec.h:新增 bool is_default_enabled; 字段,缺少默认初始化值(已报告为 P3 建议)。虽然遵循了该结构体的现有模式且所有构造函数路径都会设置该字段,但作为新增字段应当采用更佳实践。
  • autofuse/optimize/platform/backend_spec.cpp:将 GE_ASSERT_NOTNULL(platform) 替换为 nullptr 检查并返回。已验证所有调用方(codegen_tiling.cppcodegen_kernel.cppconcat_group_partitioner.cppconcat_schedule_case_generator.cppschedule_case_generator.h)均通过显式的 nullptr 检查或 GE_ASSERT_NOTNULL 妥善处理,无破坏性变更。
  • autofuse/optimize/platform/base_platform.h:将 GetPlatformConfig() 从纯虚函数提升为基类实现,并将 config_ 移至 protected 区域。PlatformV1PlatformV2 均已移除重复代码,重构合理。
  • autofuse/optimize/platform/platform_factory.cpp:将 GELOGE 改为 GELOGW,降低了未知平台的日志严重等级。返回值(nullptr)保持不变,调用方均处理 null 路径,影响有限。
  • autofuse/optimize/platform/platform_factory.hPlatformCreator 从函数指针改为 std::functionPlatformRegistrar 新增 is_default_enabled 参数,一致性良好。
  • autofuse/optimize/platform/v1/platformv1.cpp:构造函数新增 is_default_enabled 参数;GetBackendSpec() 设置 is_default_enabled;移除了重复的 GetPlatformConfig()REGISTER_PLATFORM_V1 宏新增参数,所有注册均已更新。无问题。
  • autofuse/optimize/platform/v1/platformv1.h:移除了重复的 GetPlatformConfig() 声明和 config_ 成员,与基类重构一致。无问题。
  • autofuse/tests/st/optimize/CMakeLists.txt:新增 autofuse_backend_spec_api.cpp 源文件;文件末尾补全换行符。无问题。
  • autofuse/tests/st/optimize/optimize_st.cpp:新增 platform_config_test(第 3642 行)、BackendSpec 中新增断言(第 4085 行)、新增 AutofuseBackendSpecTest(第 4088 行)。测试逻辑正确,对 GetPlatform()nullptr 返回路径有适当检查。
  • autofuse/tests/ut/optimize/CMakeLists.txt:新增 autofuse_backend_spec_api.cpp 源文件。无问题。
  • autofuse/tests/ut/optimize/test_optimizer.cpp:新增 platform_config_test(第 7220 行)、BackendSpec 中新增断言(第 7255 行)、新增 AutofuseBackendSpecTest(第 7258 行)。SetUp() 调用 Reset() 可防止测试间平台状态残留。无问题。
  • autofuse/tests/v35/st/optimize/optimize_st_v2.cpp:新增 platform_config_test(第 112 行)、BackendSpec 中新增断言(第 1110 行)、新增 AutofuseBackendSpecTest(第 1113 行)。SetUp() 调用 Reset()。无问题。
  • autofuse/tests/v35/ut/optimize/test_optimizer_v2.cpp:新增 platform_config_test(第 107 行)、BackendSpec 中新增断言(第 3201 行)、新增 AutofuseBackendSpecTest(第 3204 行)。SetUp() 调用 Reset()。无问题。
  • autofuse/v35/optimize/platformv2.cpp:构造函数新增 is_default_enabled 参数;GetBackendSpec() 设置 is_default_enabled;移除了重复的 GetPlatformConfig();两个注册宏均已更新正确值("3510" 为 true,"5102" 为 false)。无问题。
  • autofuse/v35/optimize/platformv2.h:移除了重复的 GetPlatformConfig() 声明和 config_ 成员。无问题。
  • scripts/package/graph_autofusion/rpm_deb/custom_postinst.shchmod 550chmod 555。无问题。
  • scripts/package/graph_autofusion/scripts/graph_autofusion_custom_install.sh:修复拼写错误("faied" → "failed","te" → "graph_autofusion");chmod 550chmod 555。无问题。

问题统计:P0: 0、P1: 0、P2: 0、P3: 1

整体风险评估:低。 该 diff 引入了一个新的 is_default_enabled 配置标志,贯穿平台配置、后端规格及对外 API 等各层,并配有全面的测试覆盖。一个结构体字段缺少默认初始化值(遵循现有模式),仅为轻微风格问题。将 BackendSpec::GetInstance() 从崩溃改为返回 nullptr 的变更,所有调用方均已妥善处理。无逻辑、安全或可靠性回归。

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

💬 仅评论

likedislike
CANN-robotCANN-robot成员
7月8日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
7月8日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7月8日 评论:

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
repo-cann/graph-autofusion yangyongqiang0606, 盛楠, wangxiaotian995 (3/2) yangyongqiang0606 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
7月8日 将yangyongqiang0606,xchu42,zhang_shengjie,wqtshg_wt,peiyang,shengnan666,XuebinYang,sjtulxh,zhujingjing,xuyafei,wangxiaotian995设为评审人
CANN-robotCANN-robot成员
7月8日 将yangyongqiang0606,xchu42,zhang_shengjie,wqtshg_wt,peiyang,shengnan666,XuebinYang,sjtulxh,zhujingjing,xuyafei,wangxiaotian995设为审查人
atomgit-bot
atomgit-bot7月8日进行代码检视1
scripts/package/graph_autofusion/scripts/graph_autofusion_custom_install.sh
@@ -370,3 +370,3 @@
370370 log "INFO" "pre-compiling autofuse python scripts..."
371371 python3 -m compileall -q "${autofuse_python_dir}" 2>/dev/null || true
372- chmod -R 550 "${autofuse_python_dir}/__pycache__" 2>/dev/null || true
372+ chmod -R 555 "${autofuse_python_dir}/__pycache__" 2>/dev/null || true
atomgit-bot
atomgit-bot7月8日评论:

🟡 Medium Priority

custom_postinst.sh:61 相同的问题:chmod -R 550 改为 chmod -R 555,使 __pycache__ 目录及其中 .pyc 字节码文件对 "other" 用户变为可读可执行。安装脚本中对源码目录的权限管理(chmod_recur 使用 750/550)限制 other 用户访问,但此变更使编译后的字节码绕过该限制。

建议:与 custom_postinst.sh 的建议相同:将权限改回 550 以保持与源码目录权限策略一致。

likedislike
atomgit-bot
atomgit-bot7月8日进行代码检视1
scripts/package/graph_autofusion/rpm_deb/custom_postinst.sh
@@ -59,3 +59,3 @@
5959if [ -d "${autofuse_python_dir}" ]; then
6060 python3 -m compileall -q "${autofuse_python_dir}" 2>/dev/null || true
61- chmod -R 550 "${autofuse_python_dir}/__pycache__" 2>/dev/null || true
61+ chmod -R 555 "${autofuse_python_dir}/__pycache__" 2>/dev/null || true
atomgit-bot
atomgit-bot7月8日评论:

🟡 Medium Priority

两个 shell 脚本中对 __pycache__ 目录的权限从 550r-xr-x---,仅 owner 和 group 可读/可执行)改为 555r-xr-xr-x,所有用户可读/可执行)。

__pycache__ 目录包含 Python 编译后的 .pyc 字节码文件,可以通过反编译工具还原出近似源码。而同一安装脚本中对 Python 源码目录的权限控制为 750chmod_recur "${sourcedir}/python" 750 dir),即仅 owner+group 可访问。此变更使 .pyc 字节码的访问权限比源码目录更宽松,在多用户系统中,未授权的 "other" 用户可读取并反编译这些字节码,从而绕过源码目录的权限限制。

影响范围:custom_postinst.sh 第 61 行(rpm/deb 安装后脚本)和 graph_autofusion_custom_install.sh 第 372 行(自定义安装脚本)。

建议:建议保持与源码目录一致的权限策略。若 __pycache__ 需要可执行权限以支持 Python import 机制,可将权限设为 550(owner+group 可读可执行,other 无权限),与源码目录的权限模型一致。若确实需要放宽权限,请确认无安全风险并添加注释说明原因。

likedislike
shengnan成员
7月9日 评论:

/lgtm

likedislike
贾昭阳
贾昭阳
7月9日 评论:

/compile

likedislike
zhanjzhanj成员
7月9日 virtual merging failed, update merge request[project_id: 8005834, iid: 1235, target_commit_sha: 4f19aaf0a82c2970b47efe270bdbae9af2f0683a], message: You are not allowed to merge to this ref
CANN-robotCANN-robot成员
7月9日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月9日 评论:

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-07-09 11:51:47]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

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

任务名称状态日志下载链接
UT_Test_Python_superkernel ✅ SUCCESS >>>>>
ST_Test_Python_superkernel ✅ SUCCESS >>>>>
UT_Test_superkernel ✅ SUCCESS >>>>>
UT_Test_autofuse_framework ✅ SUCCESS >>>>>
ST_Test_autofuse_framework ✅ SUCCESS >>>>>
UT_Test_autofuse_ascendc_api ✅ SUCCESS >>>>>
ST_Test_autofuse_ascendc_api ✅ SUCCESS >>>>>
ST_Test_autofuse_e2e ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>

[2026-07-09 12:22:03]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
7月9日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
codecheck_codestyle ⚠️ WARNING >>>>>
codecheck_precommit ✅ SUCCESS >>>>>

[2026-07-09 11:48:24]    CI执行结束

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:api-check-pass
CANN-robotCANN-robot成员
7月9日 删除了label:api-check-pass
CANN-robotCANN-robot成员
7月9日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7月9日 添加了label:ci-pipeline-passed
wangxiaotian995成员
7月9日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:lgtm
Wwangxiaotian995成员
7月9日 解决了最后一个问题
yangyongqiang
yangyongqiang成员
7月9日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:approved
CANN-robotCANN-robot成员
7月9日 合入了pull request