| Files | Last commit | Last update |
|---|---|---|
fix(tile_with_axis): Tiling溢出/CeilDiv回绕与标量UB越界加固,补动态shape范围推导及golden Co-authored-by: tan_xin<tanxin44@huawei.com> # message auto-generated for no-merge-commit merge: !6647 merge master-only-tile into master fix(tile_with_axis): Tiling溢出/CeilDiv回绕与标量UB越界加固,补动态shape范围推导及golden Created-by: tan_xin Commit-by: tan_xin Merged-by: cann-robot Description: ## 描述 对 TileWithAxis 算子(Ascend950 AICore 实现)进行加固,覆盖 Tiling 计算、动态 shape 推导与属性契约三个维度。 ### 改动原因 - Tiling 中 outerDim/innerDim/rowLength/rowOutElements/totalOutElements 乘积链缺少 int64 溢出守卫,超大 shape 下会回绕产生错误分块; - CeilDiv 对空张量(rowLength==0 / totalCount==0)存在除以 0 与负数回绕风险; - 标量输入(rank=0)时输出共 tiles 个元素,原实现单核整块搬运,tiles 超过单缓冲容量(ubSize/2/dtypeSize)时发生 UB 越界写; - axis/tiles 属性契约与 TBE/AICPU 基线不一致(axis 默认 0 vs 1,tiles 可选 vs 必选); - 算子声明支持动态 shape(DynamicShapeSupportFlag=true),但缺少 InferShapeRange 输出范围推导。 ### 改动方法 - 新增 CheckMulNoOverflow 对全部 int64 乘积链做符号与溢出校验,超限即返回 GRAPH_FAILED; - 空张量分支:ComputeUbFactor/ComputeTotalCount/MaxBlocksOnAxis/SelectInitialUbAxis 对 rowLength==0 返回 0 块数,多核切分 totalCount==0 时 SetBlockDim(1); - HandleScalarInput 引入 bufferSize/dtypeSize 单缓冲容量判断:tiles 超容量时沿 tiles 维分块(ubAxis=1,NDDMA dim1 源 stride=0 广播读),消除 UB 越界写; - axis 缺省值统一为 1(对齐 TBE/AICPU),tiles 改为 REQUIRED(对齐 proto/README/AICPU def); - 新增 InferShapeRange4TileWithAxis:输出 range = 输入 range,axis 维乘 tiles,-1/-2 未知维标记原样传播,带 int64 溢出检查; - proto 明确 x 仅支持 ND 格式,文档与 golden 补齐。 ## 关联的Issue - https://gitcode.com/cann/ops-math/issues/3874 ## 测试 - 更新 op_host UT:tiling(溢出/空张量/标量分块)与 infershape(未知维传播、axis/tiles 契约)用例; - 新增 tests/assets/golden.py:以 torch 小算子拼接实现 TileWithAxis 语义,提供 TTK kernel/GEIR 模式的 golden 与 binary_equal 容差声明。 ## 文档更新 - 更新 README.md(axis 默认值、tiles 必选、ND 格式约束、动态 shape 支持说明)。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!6647 | 17 days ago | |
add aicpu:tile_with_axis&topkpqdistance Co-authored-by: sujunwei3<sujunwei3@huawei.com> # message auto-generated for no-merge-commit merge: !4174 merge dev into master add aicpu:tile_with_axis&topkpqdistance Created-by: sujunwei3 Commit-by: sujunwei3 Merged-by: cann-robot Description: ## 描述 新增四个 AI CPU 算子: 1. **tile_with_axis**(conversion):沿指定维度复制输入 Tensor 数据,扩展输出 Tensor。包含 AI Core 和 AI CPU 双实现。 2. **top_k_pq_distance**(math):基于分组极值剪枝的 TopK 距离计算,用于向量检索场景。支持动态多组输入。 3. **top_k_v2_d**(math):沿指定维度找出最大或最小的 k 个元素及其索引,兼容 TensorFlow TopKV2,包含 infershape 实现。 4. **zeta**(math):计算 Hurwitz zeta 函数 ζ(x, q) = Σ(n=0→∞) 1/(q+n)^x。 每个算子包含:op_kernel_aicpu 实现、op_graph 构图定义、examples 示例、UT 单元测试、README 文档。 ## 关联的Issue #2294 ## 测试 根据代码变更,测试场景如下: 1. **tile_with_axis 单元测试 + GE IR 验证** - 执行 bash build.sh -u --opkernel_aicpu --ops=tile_with_axis --soc=ascend910b,17 个 UT 全部通过 - 执行编包 + GE IR 运行,execute samples success,输出 bin 文件正常 2. **top_k_pq_distance 单元测试** - 执行 bash build.sh -u --opkernel_aicpu --ops=top_k_pq_distance --soc=ascend910b,5 个 UT 全部通过 3. **top_k_v2_d 单元测试 + GE IR 验证** - 执行 bash build.sh -u --opkernel_aicpu --ops=top_k_v2_d --soc=ascend910b,UT 全部通过 - 执行编包 + GE IR 运行,验证通过 4. **zeta 单元测试 + GE IR 验证** - 执行 bash build.sh -u --opkernel_aicpu --ops=zeta --soc=ascend910b,8 个 UT 全部通过 - 执行编包 + GE IR 运行,execute samples success,输出 bin 文件正常 ## 文档更新 - 新增 4 个算子 README.md(tile_with_axis、top_k_pq_distance、top_k_v2_d、zeta) - 更新 docs/zh/op_list.md,新增 4 个算子条目 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4174 | 3 months ago |
| Files | Last commit | Last update |
|---|---|---|
| 17 days ago | ||
| 3 months ago |