已合并
修复prof开关写死问题 #3583
chenweiheng创建于 7 天前
修复prof开关写死问题 #3583
已合并
chenweiheng创建于 7 天前
chenweiheng成员
7 天前

修复prof开关写死问题

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 chenweiheng 的贡献)
Cchenweiheng成员
7 天前 创建了 pull request,commit 2fb4e3b8
atomgit-bot
atomgit-bot
7 天前 评论:

变更摘要

本 PR 修复了 prof(profiling)开关在代码生成阶段被写死的问题。此前生成的 wrapper 代码把 prof_enabled 作为编译期常量(static const bool prof_enabled = ...)在生成时固化,导致运行期无法反映 profiler 的实际状态;本次改为在生成的代码中提供运行时可变全局变量 prof_enabled(默认 false)并通过导出的 set_prof_enabled 接口动态更新,同时在 Python 侧新增同步逻辑,在加载与每次运行时将当前 profiler 状态同步到动态库中,并补充了对应的代码生成测试断言。

主要改动

  • prof 开关改为运行时可变: 在 _asc_codegen.py 中,删除生成期根据 ProfPathCreator().is_prof_inited 拼装的编译期常量,改为 static bool prof_enabled = false;,并新增导出的 extern "C" void set_prof_enabled(uint8_t enabled) 用于运行时修改该开关。
  • 新增 prof 状态同步逻辑: 在 _kernel.py 中新增 _sync_prof_enabled(dl, lib_wrapper),通过 ProfPathCreator().is_prof_inited 获取当前 prof 状态并调用 dl.set_prof_enabled,用按 lib_wrapper 缓存的 _prof_enabled_cache 避免重复设置;该函数在 NpuInductorKernel 的初始化(__init__)和每次运行(run)时都会被调用。
  • 自动调优内核同步 prof 状态: 在 _autotune.py 中,NpuInductorAutoTuneKernel 引入 _sync_prof_enabled 并在其 __init__run 中调用,确保自动调优路径下的内核同样能在运行时同步 prof 开关。
  • 补充代码生成测试断言: 在 test_profiling_codegen.py 中新增断言,验证生成的源码包含 set_prof_enabled 导出,且不再包含编译期常量 static const bool prof_enabled
likedislike
atomgit-bot
atomgit-bot
7 天前 评论:

代码审查

✅ 未发现问题

likedislike
ascend-robotascend-robot成员
7 天前 添加了label:smoke-pipeline-running
ascend-robotascend-robot成员
7 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
7 天前 评论:

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-Ascend/torchair fu-hao-huawei, dingdairong (2/2) fu-hao-huawei (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
chenweiheng成员
7 天前 评论:

compile

likedislike
ascend-robotascend-robot成员
7 天前 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
7 天前 删除了label:smoke-pipeline-running
ascend-robotascend-robot成员
7 天前 添加了label:smoke-pipeline-passed
ascend-robot
ascend-robot成员
7 天前 评论:
流水线 PR-pipeline_torchair_smoke#454 [ commitID:16e3017b ] 已完成
阶段 任务名 状态 详情
编译构建 Build_x86 >>>
Build_ARM >>>
开发者测试 smoke_npugraph_ex >>>
流水线 PR-pipeline_torchair_smoke >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • smoke : 运行流水线
likedislike
ascend-robot
ascend-robot成员
7 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7 天前 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
7 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
7 天前 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7 天前 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7 天前 添加了label:ci-pipeline-failed
ascend-robot
ascend-robot成员
7 天前 评论:
流水线 PR-pipeline_torchair#3764 [ commitID:16e3017b ] 运行失败
>>>代码风格自动修复执行失败,具体请查看日志,不影响流水线执行及PR合入
阶段 任务名 状态 详情
编译构建 Build_x86 >>>
Build_ARM >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 codecheck_pre-commit >>>
pre-commit >>>
开源片段检查 SCA >>>
流水线 PR-pipeline_torchair >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
ascend-robot
ascend-robot成员
7 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7 天前 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
7 天前 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
7 天前 删除了label:docs-ci-pipeline-running
此处折叠了7条事件消息 查看更多
ascend-robotascend-robot成员
6 天前 添加了label:ascend-cla/yes
chenweiheng成员
6 天前 评论:

compile

likedislike
ascend-robotascend-robot成员
6 天前 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
6 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
6 天前 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
6 天前 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
6 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robot
ascend-robot成员
6 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
6 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
6 天前 添加了label:docs-ci-pipeline-success
ascend-robot
ascend-robot成员
6 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
6 天前 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
6 天前 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
6 天前 评论:
流水线 PR-pipeline_torchair#3765 [ commitID:e638a074 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_x86 >>>
Build_ARM >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 codecheck_pre-commit >>>
pre-commit >>>
开源片段检查 SCA >>>
流水线 PR-pipeline_torchair >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
dingdairong成员
6 天前 评论:

/lgtm

likedislike
fu_hao
fu_hao成员
6 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
6 天前 添加了label:approvedlgtm
ascend-robotascend-robot成员
6 天前 合入了pull request