已合并
DynamicQuant 字面常量修改 #8346
dongfei创建于 8月6日
DynamicQuant 字面常量修改 #8346
已合并
dongfei创建于 8月6日
dongfei
dongfei成员
8月6日

描述

DynamicQuant 字面常量修改

关联的Issue

https://gitcode.com/cann/ops-nn/issues/4615

测试

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 dongfei 的贡献)
dongfeidongfei成员
8月6日 创建了 pull request,commit 00adcb09
dongfeidongfei成员
8月6日 关联了issue:dynamic_quant_tiling_arch35.cpp存在字面常量
atomgit-bot
atomgit-bot
8月6日 评论:

变更摘要

此 PR 主要对 dynamic_quant_tiling_arch35.cpp 中的 DynamicQuantRegbaseTiling 类进行代码质量改进:将分散在各处的字面常量(魔数)替换为有意义的命名常量,涉及对齐大小、UB 队列系数、位掩码和调度模式等,提升代码可读性和可维护性,不改变任何运行时行为。

主要改动

  • 新增对齐与队列相关常量:在文件顶部定义 ROW_ALIGN_SIZE(16)、SMOOTH_QUEUE_FACTOR(2)、MAIN_QUEUE_FACTOR(4)、EVEN_ALIGN_MASK(1)和 BATCH_SCHEDULE_MODE(1),将原本硬编码的数字提取为语义明确的常量。
  • 对齐计算使用命名常量:CalculateTilingData 中将 AlignUp<16>(rowLen) 改为 AlignUp<ROW_ALIGN_SIZE>(rowLen),使行对齐逻辑更清晰。
  • UB 队列缓冲区计算公式重构:两处 calcLargeBuf / calcBuf 计算中,将 2UL * (... * 2UL + 4UL) 替换为 DOUBLE * (... * SMOOTH_QUEUE_FACTOR + MAIN_QUEUE_FACTOR),明确各系数含义。
  • INT4 偶数对齐与核心数常量化:CalculateTilingForPertenLargeMulticore 中核心数下限 2 改用 DOUBLE,INT4 偶数对齐掩码 ~1U 改为 ~EVEN_ALIGN_MASK,偏移量 + 2 改为 + DOUBLE。
  • 调度模式设置常量化:RunFusionKernelTiling 中 SetScheduleMode(1) 改为 SetScheduleMode(BATCH_SCHEDULE_MODE),使 batch mode 的语义一目了然。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月6日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月6日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月6日 评论:

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
quant ✅ 王星, 唐玮玮 (2/2) ✅ 王星 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
8月6日 将zengjuan,sxb154714,chenfeng61,chaotang233,crystalhu,yangyang016,fanqirui,su-yueming,zhajianqing123,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,liuyang_806设为评审人
CANN-robotCANN-robot成员
8月6日 将sxb154714,chenfeng61,su-yueming,zhajianqing123,LinPX,wang-xing001,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,liuyang_806设为审查人
dongfei
dongfei成员
8月6日 评论:

compile

likedislike
dongfeidongfei成员
8月6日 预合并成功(commit_id: 5904c95f25ba0f7cf1e1470a8c26311dfe7ef7f4)
CANN-robotCANN-robot成员
8月6日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
8月6日 评论:

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

任务名称状态日志下载链接
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 ⚠️ WARNING >>>>>

[2026-08-06 15:48:06]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
8月6日 评论:

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

任务名称状态日志下载链接
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-06 15:33:50]    CI执行结束

likedislike
CANN-robotCANN-robot成员
8月6日 添加了label:api-check-pass
CANN-robotCANN-robot成员
8月6日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
8月6日 添加了label:ci-pipeline-passed
dongfeidongfei成员
8月6日 修改了pull request 的描述
tangweiwei2成员
8月7日 评论:

/lgtm
/approve

likedislike
wang-xing001成员
8月7日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月7日 添加了label:lgtmapproved
CANN-robotCANN-robot成员
8月7日 关闭了关联的issue
CANN-robotCANN-robot成员
8月7日 合入了pull request