Merged
新增ViewCopy重载接口,支持传入inplaceFlag参数 #6164
新增ViewCopy重载接口,支持传入inplaceFlag参数 #6164
Merged
ren-botaoAdd on Oct 8
ren-botaoCollaborators
Oct 8

描述

本次变更围绕 ViewCopy 接口进行扩展,新增了一个带 inplaceFlag 参数的重载版本,用于区分“原地”与“非原地”的 Tensor 拷贝语义。原三参数 ViewCopy 接口保持兼容,内部转发到新接口并默认传入 inplaceFlag=false;核心逻辑变化在于:当输入与输出指向同一地址时,仅在不处于原地模式时才调用 executor->AbandonCache(true)。

关联的Issue

#4461

测试

冒烟验证通过

文档更新

对应文档在opbase仓

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for ren-botao's contribution.)
Rren-botaoCollaborators
Oct 8 Created pull request, commit 0927e17e
atomgit-bot
atomgit-bot
Oct 8 Comments:

变更摘要

本次变更围绕 ViewCopy 接口进行扩展,新增了一个带 inplaceFlag 参数的重载版本,用于区分“原地”与“非原地”的 Tensor 拷贝语义。原三参数 ViewCopy 接口保持兼容,内部转发到新接口并默认传入 inplaceFlag=false;核心逻辑变化在于:当输入与输出指向同一地址时,仅在不处于原地模式时才调用 executor->AbandonCache(true)。

主要改动

  • 新增 ViewCopy 重载声明: 在 common/inc/external/aclnn_kernels/contiguous.h 中新增 const aclTensor* ViewCopy(const aclTensor* x, const aclTensor* y, aclOpExecutor* executor, bool inplaceFlag) 声明,对外暴露带原地标志的拷贝接口。
  • 原接口保持兼容并转发: 在 conversion/contiguous/op_host/op_api/contiguous.cpp 中,原三参数 ViewCopy 改为调用 ViewCopy(x, y, executor, false),确保既有调用方行为不变。
  • 就地地址重合时按 inplaceFlag 决定缓存处理: 新增四参数实现中,当 x 与 y 指向同一数据地址时,仅在 !inplaceFlag 条件下执行 executor->AbandonCache(true),原地模式下不再放弃缓存。
  • 日志补充原地标志信息: 同一分支的 OP_LOGD 调整为输出 inplace flag 取值,便于区分两种模式下的执行路径。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Oct 8 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Oct 8 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Oct 8 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
conversion/contiguous ✅ 汤平川, 宋恺 (2/2) ✅ 宋恺, 汤平川 (2/1)
repo-cann/ops-math ✅ 汤平川, 宋恺 (2/2) ✅ 汤平川, 宋恺 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Oct 8 Set FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding,clinglai0517 as approver
CANN-robotCANN-robotCollaborators
Oct 8 Set FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding,clinglai0517 as approver
gubaochengCollaborators
Oct 9 Comments:

/lgtm

likedislike
Rren-botaoCollaborators
8 days ago Pre merge succeeded (commit_id: ae755aca34ef3abc7eacff61dd07aa843297b974)
6 event messages are collapsed here。 See more
Rren-botaoCollaborators
6 days ago Modify description of pull request
ren-botaoCollaborators
6 days ago Comments:

compile

likedislike
Rren-botaoCollaborators
6 days ago Pre merge succeeded (commit_id: d2750f6a59855f9618030eec2caa0da89d6d7e3e)
CANN-robot
CANN-robotCollaborators
6 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
6 days ago Added label: ci-pipeline-running
Rren-botaoCollaborators
6 days ago Modify description of pull request
CANN-robotCANN-robotCollaborators
6 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
6 days ago Added label: ci-pipeline-failed
CANN-robot
CANN-robotCollaborators
6 days ago Comments:

流水线分析报告 — ops-math run#6690

流水线: https://gitcode.com/CANN/ops-math/actions/runs/8e67cdcf00914b1498ebe62d374b6564 | PR#6164 | 2026-11-04 17:47:22 ~ 17:57:57 | 失败 Job 1 个

定界结论: 代码问题 / 代码检查错误 — clang-format 格式不通过
  • 失败类型: 代码问题(代码检查)
  • 根因: PR 变更的 2 个文件未按 clang-format 规范格式化,pre-commit 的 clang-format hook 自动改写文件后判定失败
  • 处置建议: 通知 PR 提交者本地执行 pre-commit run clang-format -a(或 clang-format -i 对下列 2 个文件)并提交格式化结果
  • 排除项: 同一 Job 内 merge-conflicts、detect private key、codespell、OAT Compliance Check 均 Passed;ruff 无文件跳过。非 CI/环境问题,重试无效

失败根因分析

根因 #1: 代码问题 / 代码检查错误 — clang-format 自动改写了 PR 文件
  • 判据: clang-format pre-commit hook 报 files were modified by this hook
  • 定位步骤: 3_precommit.log
  • 影响 Job: CodeCheck_precommit
  • 根因证据(日志原文):
clang-format.............................................................Failed
- hook id: clang-format
- files were modified by this hook

Formatting [1/2] common/inc/external/aclnn_kernels/contiguous.h
Formatting [2/2] conversion/contiguous/op_host/op_api/contiguous.cpp
  • 涉及文件:
    1. common/inc/external/aclnn_kernels/contiguous.h
    2. conversion/contiguous/op_host/op_api/contiguous.cpp
结构化定界摘要
[{"repo": "ops-math", "run_number": 6690, "Failed_Type": "代码问题", "Failed_Sub_Type": "代码检查", "Failed_Reason": "PR 变更的 common/inc/external/aclnn_kernels/contiguous.h 与 conversion/contiguous/op_host/op_api/contiguous.cpp 未通过 clang-format 格式化, pre-commit hook 改写文件后判定失败", "evidence": "clang-format...Failed / - files were modified by this hook / Formatting [1/2] common/inc/external/aclnn_kernels/contiguous.h / Formatting [2/2] conversion/contiguous/op_host/op_api/contiguous.cpp", "suggestion": "本地执行 pre-commit run clang-format -a 或对上述 2 个文件 clang-format -i 后重新提交", "jobs": "CodeCheck_precommit"}]

由门禁失败定界分析自动生成 | repo: ops-math | run: 8e67cdcf00914b1498ebe62d374b6564 | PR#6164

likedislike
Rren-botaoCollaborators
6 days ago Pre merge succeeded (commit_id: f273d62677d9269e47752ad41cb2299b29f54a27)
Rren-botaoCollaborators
6 days ago Force-pushed 1 commits:dd9f397c-新增ViewCopy重载接口,支持传入inplaceFlag参数
Rren-botaoCollaborators
6 days ago Pre merge succeeded (commit_id: ecdd717856be376b05116f998d998f41f09bcd7a)
CANN-robotCANN-robotCollaborators
6 days ago Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
6 days ago Added label: cann-cla/yes
ren-botaoCollaborators
6 days ago Comments:

compile

likedislike
Rren-botaoCollaborators
6 days ago Pre merge succeeded (commit_id: e71ea600ddafebb8807fcc9a626c3894b97c0bf2)
CANN-robot
CANN-robotCollaborators
6 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
6 days ago Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
6 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
6 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
6 days ago Added label: ci-pipeline-passed
TangPC
TangPCCollaborators
5 days ago Comments:

/lgtm
/approve

likedislike
songkai111Collaborators
5 days ago Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
5 days ago Added label: approved
CANN-robotCANN-robotCollaborators
5 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
5 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
5 days ago Merged pull request