Merged
[fix] 删除constexpr中调用非constexpr的属性 #911
[fix] 删除constexpr中调用非constexpr的属性 #911
Merged
点月♡Add on Sep 22
点月♡
点月♡
Sep 22

描述

问题描述:atvoss库中存在constexpr调用非constexpr的现象

规则描述:constexpr的只能调用constexpr/callee的函数

整改方案:给被(constexpr)调用的非constexpr函数加__callee__属性。constexpr的语义在A5及之后的版本上,改为了cpp中的constexpr和__callee__(__callee__的意思是 在device上可以被任何函数调用)

关联的Issue

https://gitcode.com/cann/opbase/issues/352

测试

文档更新

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 点月♡'s contribution.)
点月♡点月♡
Sep 22 Created pull request, commit 84f33df0
点月♡点月♡
Sep 22 Associated issue: [Bug-Report|缺陷反馈]: atvoss库中存在constexpr调用非constexpr的现象,需要整改
atomgit-bot
atomgit-bot
Sep 22 Comments:

变更摘要

本 PR 针对 atvoss 库中 constexpr 函数调用非 constexpr 函数的问题进行整改。按照整改方案,constexpr 只能调用 constexpr/__callee__ 函数,因此将各调度基类中 GetScalar 模板函数的 constexpr 修饰去除,使其回归为普通的 __aicore__ inline 函数,从而不再以 constexpr 语义被调用,规避非法调用。改动覆盖 broadcast、elewise、reduce 等模块中同名模板方法,模式一致、范围明确。

主要改动

  • 移除 GetScalar 的 constexpr 修饰: 将各文件中 __aicore__ inline constexpr ScalarType GetScalar() 统一改为 __aicore__ inline ScalarType GetScalar(),函数签名与返回类型保持不变,仅去掉 constexpr 限定。
  • broadcast 模块批量调整: 涉及 broadcast_sch_base.h、broadcast_sch_one_dim.h、broadcast_sch_one_dim_advance.h 以及 noncontiguous 下 last_transpose、nlast_transpose、transpose 等基类头文件中的同名模板方法。
  • elewise 模块同步修改: elewise_sch.h、elewise_sch_16b.h、elewise_sch_with_scalar.h 中的 GetScalar 一并去掉 constexpr。
  • reduce 模块同步修改: reduce_sch.h 中 GetScalar 模板方法(模板参数为 ScalarType、ScalarValue)同样移除 constexpr 修饰。
  • 保持函数体与断言不变: 各处 GetScalar 内部的 static_assert 校验逻辑未发生变化,仅调整函数限定符。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 22 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 22 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
9.2.0 ✅ gcw_kUomxQ2l, 王瑞 (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Set pengjiahao96,zhou-qilong,wangrui_,rxtfeng,loov1,tang-lei01,TianXL,jia0liang,zl_hw,songkai111,jiangtao_rts,gitcode-chenjiao,hanxiaolong,pingchuantang,llimwang,gubaocheng,wangyongguang,gcw_kUomxQ2l,Andy-lb as approver
CANN-robotCANN-robotCollaborators
Sep 22 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
点月♡
点月♡
Sep 22 Comments:

compile

likedislike
点月♡点月♡
Sep 22 Pre merge succeeded (commit_id: 3b067518f39a7e7b262b7d2107691d8ae43a34c6)
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
RuiWang_
RuiWang_Collaborators
Sep 22 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-passed
wangyongguang
wangyongguangCollaborators
Sep 22 Comments:

/approve

likedislike
liulun0308
liulun0308Collaborators
Sep 23 Comments:

/approve

likedislike
CANN-robot
CANN-robotCollaborators
Sep 23 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: 王永光, 王瑞

likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 23 Merged pull request