已关闭
feat: 新增 IndexByTensor 算子 fallback 主机执行实现 #8730
esok11创建于 25 天前关闭于 16 天前
feat: 新增 IndexByTensor 算子 fallback 主机执行实现 #8730
已关闭
esok11创建于 25 天前关闭于 16 天前
esok11成员
25 天前

描述

新增 IndexByTensor 算子的 fallback(主机侧)执行实现,文件位于 index/index/op_graph/index_by_tensor_fallback.cpp

实现内容:

  • fallback 命名空间下通过 IMPL_OP(IndexByTensor).OpExecuteFunc(IndexByTensorHostExecuteFunc) 注册 IndexByTensor 的主机侧执行函数。
  • IndexByTensorHostExecuteFunc 基于 gert::OpExecuteContext 获取输入:
    • 输入 0(INPUT_X_ID)为 self 张量;
    • 输入 1..N 为动态索引张量列表;
    • 属性 ATTR_MASK_IDXgert::ContinuousVector,元素类型 int64)为索引掩码;
    • 输出 0(OUTPUT_Y_ID)为索引结果张量。
  • 通过 getIndicesWithMask 按掩码重建索引张量列表:掩码值为 0 时插入一个 shape 为 {0}、dtype 为 DT_INT64 的空占位张量,掩码值为 1 时保留对应的实际索引张量。
  • 最终通过 CANN_OPS_OPB_SYN_EXEC_ACLNN(hostApiCtx, aclnnIndex, self_ge, inputTensorList, out_ge) 同步调用底层 aclnnIndex 接口完成计算。
  • hostApiCtxself_geout_geattrs 等关键指针进行空指针校验,失败时记录 OP_LOGE 并返回 GRAPH_FAILED

关联的Issue

  • #4819

测试

随算子工程编译与精度用例验证。

文档更新

无。

类型标签

AI/Agent生成声明

likedislike
当前Pull Request已关闭, 关闭人@esok11
Eesok11成员
25 天前 创建了 pull request,commit 3a2cfa24
atomgit-bot
atomgit-bot
25 天前 评论:

变更摘要

本 PR 新增 index/index/op_graph/index_by_tensor_fallback.cpp 文件,为 IndexByTensor 算子提供 host 侧 fallback 实现。该实现通过 OpExecuteFunc 注册 IndexByTensorHostExecuteFunc 执行函数,在 host 端解析输入张量、mask 属性和输出张量,将带有 mask 的索引输入整理后,调用 aclnnIndex 完成实际计算,从而补充该算子在图模式下缺少的降级执行路径。

主要改动

  • 新增算子 fallback 注册: 通过 IMPL_OP(IndexByTensor).OpExecuteFunc(IndexByTensorHostExecuteFunc) 注册 IndexByTensor 的 host 执行函数,使算子具备 fallback 执行能力。
  • 新增 IndexByTensorHostExecuteFunc 执行函数: 该函数获取输入张量 self、输出张量 out_gemask 属性,调用 CANN_OPS_OPB_SYN_EXEC_ACLNN(hostApiCtx, aclnnIndex, ...) 执行 aclnnIndex 计算,并对关键参数进行空指针与返回码检查。
  • 新增 getIndicesWithMask 辅助函数: 根据 mask 数组将索引张量列表展开:mask 为 0 时填充空的 INT64 张量,为 1 时按顺序取实际索引张量,非法值时记录错误日志,从而还原带掩码的索引输入结构。
  • 定义相关常量: 新增 INPUT_X_IDINPUT_INDICES_IDATTR_MASK_IDXOUTPUT_Y_ID 等常量,用于标识输入、属性与输出的位置。
likedislike
不准确?
atomgit-bot
atomgit-bot
25 天前 评论:

代码审查

✅ 未发现问题

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

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

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
index ❌ (0/2)(You can also ask: 王星, 刘波, 唐燕峰, 汤平川, 王瑞) ❌ (0/1)(You can also ask: 王瑞, 唐燕峰, 陈风, 黄迪, 王星)

💡 Tip:

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

CLA Signature Pass

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

likedislike
esok11成员
25 天前 评论:

/compile

likedislike
Eesok11成员
25 天前 update merge request[project id: 7665709, iid: 8730, commit_id: 8259b43d95f0a7f205158927b39c3e0e79d2a167] virtual merging success
CANN-robotCANN-robot成员
25 天前 将zengjuan,chenfeng61,chaotang233,kevin_huang1234,FelixTang7,crystalhu,yangyang016,fanqirui,wangrui_,su-yueming,chenqi317,wang-xing001,liubo75,tangweiwei2,pingchuantang设为评审人
CANN-robotCANN-robot成员
25 天前 将chenfeng61,kevin_huang1234,FelixTang7,wangrui_,su-yueming,wang-xing001,pingchuantang设为审查人
esok11成员
25 天前 评论:

/compile

likedislike
CANN-robotCANN-robot成员
25 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
25 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
25 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
25 天前 评论:

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

任务名称状态日志下载链接
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 ❌ FAILED
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
likedislike
CANN-robot
CANN-robot成员
25 天前 评论:

流水线任务触发成功
任务链接 [4bce7bcca40f4a26b94a1ede2b74ca02][流水线指导]

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

likedislike
CANN-robotCANN-robot成员
25 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
25 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
25 天前 添加了label:ci-pipeline-failed
Eesok11成员
24 天前 修改标题为 “feat: 新增 IndexByTensor 算子 fallback 主机执行实现”,原标题为“feat(index tensor fallback)”
Eesok11成员
24 天前 修改了pull request 的描述
esok11成员
24 天前 评论:

/compile

likedislike
CANN-robotCANN-robot成员
24 天前 删除了label:ci-pipeline-failedapi-check-pass
CANN-robotCANN-robot成员
24 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
24 天前 评论:

流水线任务触发成功
任务链接 [7a1ec784746c419c9ab7cd3e08c1d671][流水线指导]

任务名称状态日志下载链接
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 ❌ FAILED
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
likedislike
CANN-robot
CANN-robot成员
24 天前 评论:

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

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

likedislike
CANN-robotCANN-robot成员
24 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
24 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
24 天前 添加了label:ci-pipeline-failed
Eesok11成员
16 天前 关闭了 pull request