已合并
cleancode fix #3601
yangjinwen创建于 6月27日
cleancode fix #3601
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yangjinwen 的贡献)6月27日 创建了 pull request,commit 73c99b72
6月27日 添加了label:cann-cla/yes
CANN-robot
6月27日 评论:
6月27日 评论:
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 |
|---|---|---|
| conversion/broadcast_to | ✅ zhanw_coding, 宋恺 (2/2) | ✅ zhanw_coding, 宋恺 (2/1) |
| conversion/transpose | ✅ zhanw_coding, 宋恺 (2/2) | ✅ zhanw_coding, 宋恺 (2/1) |
| math/expand | ✅ zhanw_coding, 宋恺 (2/2) | ✅ zhanw_coding, 宋恺 (2/1) |
| repo-cann/ops-math | ✅ zhanw_coding, 宋恺 (2/2) | ✅ zhanw_coding, 宋恺 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
yangjinwen, thanks for your pull request. All authors of the commits have signed the CLA. 👍


atomgit-bot
6月27日 评论:
6月27日 评论:
变更摘要
本次 PR 主要聚焦于 CleanCode 规范下的重复代码块优化,将多处重复出现的代码逻辑抽取为独立的辅助函数,以减少代码冗余。核心改动集中在两个层面:融合算子图层面提取张量描述解析逻辑,以及多核 tiling 参数下计算处理范围的统一封装。
主要改动
- 抽取
ResolveSubgraphInputTensorDesc辅助函数:在permute_fusion_pass.cpp中,将GetInputsInfo和InferShape中重复的 TensorDesc 解析与 fallback 逻辑抽取为独立函数,统一了两处调用点。 - 新增
ParseMultiCoreRange辅助函数:在transpose_base.h中定义ParseMultiCoreRange内联函数,封装多核 tiling 参数下的处理范围计算逻辑(blkFactor、blkTailFactor、realCoreNum),并在transpose_big_dim.h、transpose_cut_one_axis.h、transpose_n_last.h三处将原有内联代码替换为对该函数的调用。 - 合并
GetLoopAddressOffsetImpl统一实现:在transpose_cut_two_axis.h中,将GetMainLoopAddressOffset、GetTailLoopAddressOffset、GetTailTailLoopAddressOffset三者的共同循环地址偏移计算逻辑合并为单一的GetLoopAddressOffsetImpl,通过cutIndex1/cutIndex2参数区分主循环与尾循环场景。 - 简化
ProcessTail中的重复表达式:在transpose_cut_two_axis.h的ProcessTail中,将loopidx的重复计算表达式提取为局部变量tailLoopLocalIdx,并复用于两处DecimalToMixedBase调用。#### 变更摘要
本次 PR 对 CleanCode 规范中存在的重复代码块进行了优化重构,主要围绕两方面展开:一是将多处重复的张量描述解析逻辑抽取为独立的辅助函数 ResolveSubgraphInputTensorDesc;二是将多核分片参数下的处理范围计算逻辑封装为内联函数 ParseMultiCoreRange,供多个转换核使用。
主要改动
- 抽取张量描述解析逻辑为独立函数:在
permute_fusion_pass.cpp中新增ResolveSubgraphInputTensorDesc辅助函数,将GetInputsInfo和InferShape中两处重复的 TensorDesc 获取与 shape fallback 逻辑统一收拢到该函数中。 - 封装多核范围计算为内联函数:在
transpose_base.h中定义ParseMultiCoreRange,将多核 tiling 参数下的处理范围计算(blkFactor/blkTailFactor/realCoreNum判断)封装为独立函数,并在transpose_big_dim.h、transpose_cut_one_axis.h、transpose_n_last.h中将原有内联代码替换为对该函数的调用。 - 合并循环地址偏移计算为统一实现:在
transpose_cut_two_axis.h中,将GetMainLoopAddressOffset、GetTailLoopAddressOffset、GetTailTailLoopAddressOffset三者共有的地址偏移计算逻辑合并为单一的GetLoopAddressOffsetImpl,通过cutIndex1和cutIndex2参数区分主循环、尾循环及尾尾循环场景。 - 简化尾循环中的重复表达式:在
ProcessTail中,将重复的loopidx计算表达式抽取为局部变量tailLoopLocalIdx,并复用于两处DecimalToMixedBase调用。


6月27日 修改了pull request 的描述
此处折叠了83条消息 查看更多
zhanw_coding
6月30日 评论:
6月30日 评论:
/lgtm
/approve


6月30日 添加了label:approved
songkai111
6月30日 评论:
6月30日 评论:
/lgtm
/approve


6月30日 添加了label:lgtm
6月30日 合入了pull request
描述
CleanCode规范修改:重复代码块优化
关联的Issue
https://gitcode.com/cann/ops-math/issues/1944
测试
文档更新
类型标签