已合并
refactor: 将 op_api 目录移动至算子根目录并统一构建配置 #8840
Nice try创建于 21 天前
refactor: 将 op_api 目录移动至算子根目录并统一构建配置 #8840
已合并
Nice try创建于 21 天前
Nice try
Nice try成员
21 天前

描述

将 7 个算子的 op_api 实现从 op_host/op_api/ 子目录移动至算子根目录 op_api/,并将算子根目录 CMakeLists.txt 由递归式 file(GLOB) + add_subdirectory 统一为 add_modules_sources 构建方式,同时同步更新所有相关头文件引用路径。

涉及的算子:

  • index/apply_top_k_top_p_with_sorted
  • index/embedding_bag
  • index/linear_index
  • index/linear_index_v2
  • loss/fused_cross_entropy_loss_with_max_sum
  • quant/fake_quant_affine_cachemask
  • rnn/single_layer_lstm_grad

改动原因

ops-nn 仓库中部分算子的 op_api 代码位于 op_host/op_api/ 层级之下,与其他算子的组织方式不一致,且构建配置分散在 op_host/CMakeLists.txt 中。本改动将 op_api 目录统一上移至算子根目录,并统一算子构建配置。

改动方法

  1. 将 7 个算子的 op_host/op_api/ 目录整体移动至算子根目录 op_api/(纯移动,内容不变);
  2. 删除 7 个 op_host/CMakeLists.txt,算子根目录 CMakeLists.txt 统一改为调用 add_modules_sources(HOSTNAME ${OPHOST_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR} OPTYPE <op_name> ACLNNTYPE aclnn_exclude)
  3. 同步更新头文件引用路径:index/index_put_v2/op_api/aclnn_index_put_impl.cpp(linear_index_v2.h)、index/scatter_elements_v2/op_api/aclnn_scatter.cpp(linear_index.h)及 6 个 UT 测试文件;
  4. 更新 classify_rule.yaml 中 linear_index_v2 的 op_api 路径(op_host/op_api/op_api/);
  5. 格式修正:3 个文件补充末尾换行符,embedding_bag.cpp 注释格式调整。

关联的Issue

测试

  • 变更均为目录结构移动与构建配置统一,无算法逻辑改动;UT 测试文件仅同步头文件引用路径。
  • 依赖 CI 构建验证(未在 PR 中提供其他测试信息)。

文档更新

无文档变更。

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Nice try 的贡献)
Nice tryNice try成员
21 天前 创建了 pull request,commit cb4da95c
atomgit-bot
atomgit-bot
21 天前 评论:

变更摘要

本 PR 将多个算子的 op_api 目录从 op_host/op_api/ 路径整体上移至算子根目录 op_api/(涉及 apply_top_k_top_p_with_sortedembedding_baglinear_indexlinear_index_v2fused_cross_entropy_loss_with_max_sumfake_quant_affine_cachemasksingle_layer_lstm_grad 等算子),并同步更新了 classify_rule.yaml 分类规则、各源文件与测试文件中的 include 路径,同时顺带修正了部分文件末尾缺失换行符及注释格式问题。该改动属于目录结构调整(标记为 Bug 修复),不改动算子对外接口与业务逻辑。

主要改动

  • op_api 目录上移: 将上述多个算子原本位于 op_host/op_api/ 下的 .cpp/.h 文件整体迁移至算子根目录 op_api/,如 linear_index_v2.haclnn_embedding_bag.hfake_quant_common.haclnn_lstm_backward.h 等,统一 op_api 目录层级。
  • 更新 classify_rule.yaml 分类路径: 将 linear_index_v2 的源码分类路径由 ops/ops-nn/index/linear_index_v2/op_host/op_api/ 调整为 ops/ops-nn/index/linear_index_v2/op_api/,与新的目录结构保持一致。
  • 同步修正 include 路径: 源文件中 index_put_v2aclnn_index_put_impl.cppindex/linear_index_v2/op_host/op_api/linear_index_v2.h 改为 index/linear_index_v2/op_api/linear_index_v2.hscatter_elements_v2aclnn_scatter.cpp../../linear_index/op_host/op_api/linear_index.h 改为 ../../linear_index/op_api/linear_index.h;多个测试文件(如 test_aclnn_apply_top_k_top_p.cpptest_aclnn_embedding_bag.cpptest_aclnn_fake_quant_per_channel_affine_cachemask.cpptest_aclnn_lstm_backward.cpp 等)的 #include 路径也相应从 ../../../op_host/op_api/ 调整为 ../../../op_api/
  • 顺带修正格式问题: 为 embedding_bag.cpp 中注释补充空格(如 //根据dtype// 根据dtype),并为 linear_index_v2.hfake_quant_common.haclnn_lstm_backward.cppembedding_bag.htest_aclnn_embedding_bag.cpp 等文件末尾补充缺失的换行符。
likedislike
不准确?
atomgit-bot
atomgit-bot
21 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
21 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
21 天前 评论:

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.
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
*/*/op_api/*.h 王永光, 刘波, 汤平川 (3/2) 王永光 (1/1)
index 钱泽洪, 刘波, 唐燕峰, 汤平川 (4/2) 唐燕峰, 汤平川, 钱泽洪 (3/1)
loss 汤平川, 钱泽洪, 刘波 (3/2) 汤平川, 钱泽洪 (2/1)
quant 钱泽洪, 刘波, 汤平川 (3/2) 汤平川, 钱泽洪 (2/1)
repo-cann/ops-nn 汤平川, 刘波 (2/2) 汤平川, 刘波 (2/1)
rnn 钱泽洪, 汤平川, 刘波 (3/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

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

likedislike
CANN-robotCANN-robot成员
21 天前 将zengjuan,sxb154714,chenfeng61,chaotang233,kevin_huang1234,FelixTang7,crystalhu,yu-xinjie62,yangyang016,fanqirui,wangrui_,su-yueming,zhajianqing123,tang-lei01,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,wangyongguang,liuyang_806,liuchuangdev设为评审人
CANN-robotCANN-robot成员
21 天前 将zengjuan,sxb154714,chenfeng61,chaotang233,kevin_huang1234,FelixTang7,crystalhu,yu-xinjie62,yangyang016,fanqirui,wangrui_,su-yueming,zhajianqing123,tang-lei01,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,wangyongguang,liuyang_806,liuchuangdev设为审查人
Nice tryNice try成员
21 天前 修改标题为 “refactor: 将 op_api 目录移动至算子根目录并统一构建配置”,原标题为“[fix] move opapi to ops root path”
Nice tryNice try成员
21 天前 修改了pull request 的描述
Nice try
Nice try成员
21 天前 评论:

compile

likedislike
Nice tryNice try成员
21 天前 update merge request[project id: 7665709, iid: 8840, commit_id: 53c4119b6854334c846337b4239e3ba5d0a73657] virtual merging success
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
21 天前 评论:

流水线任务触发成功
任务链接 [40b1c3ce9eec4141b850a1069a1b1ec2][流水线指导]

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

[2026-08-18 10:53:11]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
21 天前 评论:

流水线任务触发成功
任务链接 [0707c922c1444979a9ef4eefd93d8e5d][流水线指导]

任务名称状态日志下载链接
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-18 10:34:28]    CI执行结束

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:api-check-failed
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-passed
FelixTang7成员
21 天前 评论:

/lgtm
/approve

likedislike
Nice tryNice try成员
21 天前 将pull request提交信息修改为 “refactor: 将 op_api 目录移动至算子根目录并统一构建配置” ,原信息为 “[fix] move opapi to ops root path”
TangPC
TangPC成员
20 天前 评论:

/lgtm
/approve

likedislike
qianzehong成员
20 天前 评论:

/lgtm
/approve

likedislike
wangyongguang成员
20 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
20 天前 添加了label:approved
liubo75成员
20 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
20 天前 添加了label:lgtm
CANN-robotCANN-robot成员
20 天前 关闭了关联的issue
CANN-robotCANN-robot成员
20 天前 合入了pull request