已关闭
[Bug-Report|缺陷反馈]: Index算子UT覆盖率不足,非连续场景无UT覆盖 #6038
xuejinghui创建于  14 天前关闭于  14 天前
xuejinghui成员
14 天前 创建

[Bug-Report|缺陷反馈]: Index算子UT覆盖率不足,非连续场景无UT覆盖

Describe the current behavior / 问题描述

ops-nn master 分支(commit 547935d4f)index/index 算子的 op_host tiling UT 覆盖率不足,
实测(lcov,bash build.sh --ophost -u --cov --ops=index --soc=ascend950):

  • 整体行覆盖率仅 79.3%(1337/1685),函数覆盖率 85.9%(164/191)
  • 非连续模板 index_tiling_no_continuous.cpp 行覆盖率仅 40.9%(101/247),函数覆盖率 42%(8/19)

问题根因:现有 7 个 tiling 用例全部通过 TilingContextFaker 的 InputShapes 构造 V1 Tensor,
gert::TilingContext::InputIsView() 恒返回 false,导致 IndexNonContinuousTiling::IsCapable()
永远不成立,非连续场景(x/indices 为视图携带非连续 stride)从未被真正执行。
IsCapable 之后的视图 stride 处理、CoalesceIndex、SetTilingData、GetTilingKey、PostTiling
等核心逻辑全部未被覆盖。

同时其他模板也存在覆盖空洞:

  • index_tiling_arch35.cpp(Simt):perf 模板(isPerfTemplate_)、dtype 提升 B32/B16 分支未覆盖
  • index_tiling_simd.cpp(Simd):zeroOneZero 分支、indexedDimNum 达上限(8个index)分支未覆盖
  • index_tiling_full_load.cpp(FullLoad):MASK_MODE_0/1 的 2D tiling key、int32 indices 分支、
    无效 mask 回落分支未覆盖
  • index_infershape.cpp:多个错误处理分支未覆盖(109/126)

Environment Information / 环境信息

  • 硬件型号:Ascend950PR(npu-smi 25.7.rc1.6)
  • CANN版本:9.2.0(innerversion: V100R001C12B076)
  • OS/架构:linux x86_64
  • 代码版本:ops-nn master 547935d4f

Steps to reproduce the issue / 重现步骤

  1. 拉取 ops-nn master 最新代码
  2. 执行 index 算子 ophost UT 覆盖率构建:
    bash build.sh --ophost -u --cov --ops=index --soc=ascend950 -j$(nproc)
    
  3. 查看覆盖率报告:build/tests/ut/cov_report/cpp_utest/ops.info
    或 HTML 报告 build/tests/ut/cov_report/cpp_utest/index.html
  4. 可见 index_tiling_no_continuous.cpp 等文件大量行未覆盖;
    另外 arch35 目录用例仅在 --soc=ascend950/ascend350 时参与编译,
    默认 ascend910b 构建下这些用例不会被编译执行

Describe the expected behavior / 预期结果

  1. 非连续场景应有 UT 覆盖:可通过 gert::TensorV2 + MutableStride 构造携带
    非连续 stride 的输入 tensor(仓库内 batch_mat_mul_v3 已有先例),
    使 InputIsView() 返回 true,真正执行 IndexNonContinuousTiling 模板
  2. Simt perf 模板、dtype 提升各分支、Simd zeroOneZero、FullLoad 各 mask 模式
    等场景补齐用例
  3. index/index 算子 op_host 行覆盖率提升至 90% 以上

改动前覆盖率实测数据(lcov):

Overall coverage rate:
  lines......: 79.3% (1337 of 1685 lines)
  functions..: 85.9% (164 of 191 functions)

op_host/arch35/index_tiling_no_continuous.cpp
  lines=247 hit=101 functions=19 hit=8   <- 非连续模板严重不足
op_host/arch35/index_tiling_arch35.cpp
  lines=113 hit=93  functions=8 hit=7
op_host/arch35/index_tiling_simd.cpp
  lines=120 hit=103 functions=11 hit=11
op_host/arch35/index_tiling_full_load.cpp
  lines=120 hit=110 functions=7 hit=7

Special notes for this issue / 备注

likedislike
Xxuejinghui成员
14 天前 添加了label:bug-report
Xxuejinghui成员
14 天前 修改标题为 “[Bug-Report|缺陷反馈]: Index算子UT覆盖率不足,非连续场景无UT覆盖”,原标题为“[Bug-Report|缺陷反馈]: 1”
Xxuejinghui成员
14 天前 修改了issue 的描述
xuejinghui成员
14 天前 评论:

/assign

likedislike
CANN-robotCANN-robot成员
14 天前 将 xuejinghui 设为负责人
CANN-robotCANN-robot成员
14 天前 关闭了 issue
CANN-robotCANN-robot成员
14 天前 添加了label:resolved