| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
fix(fresnel_sin): tiling 拦截负元素总数并上报真实 dtype,VECCALC 队列 Buffer 收敛至 8,README 与示例加固 Co-authored-by: xuejinghui<xuejinghui@huawei.com> # message auto-generated for no-merge-commit merge: !7077 merge fix/fresnelsin-hardening-scan into master fix(fresnel_sin): tiling 拦截负元素总数并上报真实 dtype,VECCALC 队列 Buffer 收敛至 8,README 与示例加固 Created-by: xuejinghui Commit-by: xuejinghui Merged-by: cann-robot Description: ## 描述 修复 FresnelSin(math/fresnel_sin,arch35)质量加固验证发现的产品代码缺陷并同步修正资料与示例: 1. **tiling dtype 报错携带真实输入类型**:dtype 校验失败分支第 3 参数由固定字面量 "unsupported" 改为 ge::TypeUtils::DataTypeToSerialString 实际 dtype 串(对齐仓内 abs_grad tiling 同位置惯例);随后将修改行原用的废弃宏迁移至 OP_LOGE_FOR_INVALID_DTYPE(EZ0019,development-standard dtype 路由),真实 dtype 串语义不回退。 2. **tiling 拦截负元素总数**:元素总数参与分块计算前补 *totalIdx < 0 哨卫(EZ0015)——覆盖 -1/-2 维负乘积与 INT64_MIN 溢出哨兵,消除 SetBlockDim(uint32 形参)隐式回绕后整图静默成功的问题。 3. **VECCALC 队列 Buffer 11→8**:mask 队列(1 个 TQue 3 块,无 EnQue/DeQue 队列语义、全 tile 存活纯工作区)改 3×TBuf 工作区,VECCALC 位置队列 Buffer 收敛至 8(≤ 上限);向量算子零增删、数值与性能路径不变、tiling ubFactor 字节预算不变。 4. **README/proto 资料修正**:补图模式算子 IR 链接、dtype 表产品限定说明(Atlas 推理/训练系列不支持 BF16)、大输入截断(|x|≥36974 → sign(x)·0.5)与 NaN 传播声明、异常校验错误码表(EZ0019/EZ0017/E80012/EZ0015)、元素总数上限(2^32-1)与动态 shape 先决条件。 5. **GE 示例加固**(根副本与 arch35 副本同步):dtype 参数解析(strtol + endptr 校验,按文档声明的 BF16/FP16/FP 映射);ADD_INPUT 节点名改字符串拼接修复指针运算;AddGraph/文件写入(fopen/fwrite/fclose)返回值检查;CreateOppInGraph 失败路径补 GEFinalize;new Session 改 nothrow;arch35 副本 include 相对路径修复(原编译断裂);删除无依据的 "Precision is ok" 打印。 6. **UT 看护**:新增 tiling UT 4 例(负 totalIdx 三形态拒绝断言 + dtype 报错携带真实 dtype 断言,EZ0019 + DT_INT32 双断言),CMakeLists 接线 error_manager。 ### 决策与权衡 - **队列 Buffer 收敛选型(TQue→TBuf)**:三张 mask 从未使用队列语义(无 EnQue/DeQue,纯工作区,全 tile 存活),TBuf 即其语义正解。对比备选:「mask 生产点后移逐张复用(3→1)」在 8+1=9 块下仍超上限且引入 Alloc/Free 时序出错面;「calc 侧减 1 块」需手动生命周期管理、时序敏感。已按官方文档核实 TQue 上限计数口径不含 TBuf(未触发回退组合方案)。多 tile 跨 TBuf 复用已由防复发用例覆盖。 - **dtype 报错宏迁移(EZ0007→EZ0019)**:修改行原用治理废弃宏,按 development-standard 的 dtype 报错路由迁移 OP_LOGE_FOR_INVALID_DTYPE,仓内 abs_grad 同款先例;四实参不变,真实 dtype 串(第 1 条修复引入)语义不回退。 - **负 totalIdx 拦截粒度**:单条 < 0 哨卫即天然覆盖 INT64_MIN 哨兵(无需单独判等);拒绝时点在 tiling,动态 shape「框架先具体化」先决条件在 README 同步显性化(-1/-2 维未具体化时负乘积被 tiling 拒绝)。 ## 关联的Issue Fixes #4443 ## 测试 - **Host UT**:Tiling 17(含 4 新增看护)+ InferShape 9 = 26/26 全过,行覆盖 97.1% 持平不倒退。 - **TTK 全量回归(修复后新执行)**:L0 271/271(非空 265 例 matched_ratio 全 1.0 + 空 shape 6 例 + 防复发 6 例);OOM 插桩 271/271;L2 负例 8/8 受控拒绝(报错含真实 dtype 串);负值路径机制实验 4/4 拒绝 + 3 对照不变。 - **修改前后对账**:PASS→FAIL(新增回归)= 0;修复叙事 FAIL→PASS 8 项(dtype 报错形态 / 负值拒绝 / 队列 Buffer 收敛 L0+OOM / 示例硬化 / arch35 示例编译断裂 / 宏迁移等)。 - **示例**:双副本编译 RC=0,上板 dtype 0/1/2 运行 RC=0,参数负例 RC=255。 - **本地 CI 预检**:pre-commit 全钩子(clang-format/ruff/codespell/OAT License Header 等)通过,OAT 强制重扫 8 文件 Invalid Count: 0。 ## 文档更新 - math/fresnel_sin/README.md:dtype 表产品限定、异常校验错误码表、约束说明(截断/NaN/容量上限/动态 shape 先决条件)、图模式 IR 链接。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!7077 | 14 天前 | |
[CANNBot]add FresnelSin operator Co-authored-by: handsomeRobot_SK<suke13@huawei.com> Co-authored-by: handsomeRobot_SK<2034073486@qq.com> # message auto-generated for no-merge-commit merge: !3644 merge master into master [CANNBot]add FresnelSin operator Created-by: handsomeRobot_SK Commit-by: handsomeRobot_SK Merged-by: cann-robot Description: # feat: add FresnelSin operator ## 概述 新增 FresnelSin 算子,计算 **Fresnel 正弦积分** \[ S(x) = \int_0^x \sin\left(\frac{\pi t^2}{2}\right) dt \] 对标 TensorFlow 的 tf.math.special.fresnel_sin 实现。 --- ## 支持规格 | 项目 | 说明 | |------------|-------------------------------| | 数据类型 | float16, float32, bfloat16 | | 目标芯片 | Ascend 950 (arch35) | | 接口类型 | GE IR(无 ACLNN) | --- ## 算法实现 基于 Cephes 库 fresnl.c 的分段逼近策略: - **小值分支**(\(x^2 < 2.5625\)): 有理逼近 \[ S(|x|) = |x|^3 \cdot \frac{P_S(x^*)}{Q_S(x^*)} \] 其中 \(x^* = x^2\),\(P_S\)、\(Q_S\) 为特定多项式系数。 - **渐近分支**(\(x^2 \ge 2.5625\)): \[ S(|x|) = 0.5 - \frac{f \cdot \cos(z) + g \cdot \sin(z)}{\pi |x|} \] 其中 \(z = \frac{\pi x^2}{2}\),\(f\)、\(g\) 由辅助函数计算。 - **特殊值处理**: - NaN → NaN - ±Inf → ±0.5 - **符号恢复**:利用奇函数性质 \(S(-x) = -S(x)\) 保证数值正确。 --- ## 新增文件 | 文件路径 | 说明 | |----------|------| | math/fresnel_sin/CMakeLists.txt | 构建配置 | | math/fresnel_sin/op_graph/fresnel_sin_proto.h | GE IR 算子注册 | | math/fresnel_sin/op_host/fresnel_sin_def.cpp | 算子定义(dtype/format/config) | | math/fresnel_sin/op_host/fresnel_sin_infershape.cpp | 形状推导(输出 = 输入) | | math/fresnel_sin/op_host/arch35/fresnel_sin_tiling_arch35.cpp | Tiling 策略(多核分块 + UB 规划) | | math/fresnel_sin/op_kernel/arch35/fresnel_sin.h | Kernel 核心实现(Cephes 系数 + Horner 求值) | | math/fresnel_sin/op_kernel/arch35/fresnel_sin_tiling_data.h | Tiling 数据结构 | | math/fresnel_sin/op_kernel/arch35/fresnel_sin_tiling_key.h | 模板参数声明 | | math/fresnel_sin/op_kernel/fresnel_sin_apt.cpp | Kernel 入口 | | math/fresnel_sin/examples/test_geir_fresnel_sin.cpp | GE IR 精度验证(10 个 L1 用例) | | math/fresnel_sin/examples/arch35/test_geir_fresnel_sin.cpp | arch35 精度验证 | --- ## 精度标准 | dtype | rtol | |------------|--------| | float32 | 1e-4 | | float16 | 1e-3 | | bfloat16 | 4e-3 | --- ## UB Buffer 规划 - 输入队列 qIn :1 × sizeof(T) - 输出队列 qOut :1 × sizeof(T) - 计算队列 calcQ :8 × sizeof(float) - 掩码队列 maskQ :3 × sizeof(uint8_t) See merge request: cann/ops-math!3644 | 4 个月前 | |
feat(math): fresnel_cos/fresnel_sin 补充 tiling 校验并迁移 def 驱动 dtype 模式 Co-authored-by: handsomeRobot_SK<suke13@huawei.com> # message auto-generated for no-merge-commit merge: !4447 merge feature/fresnel_cos_v2 into master feat(math): fresnel_cos/fresnel_sin 补充 tiling 校验并迁移 def 驱动 dtype 模式 Created-by: handsomeRobot_SK Commit-by: handsomeRobot_SK Merged-by: cann-robot Description: 标题: feat(math): fresnel_cos/fresnel_sin 补充 tiling 校验并迁移 def 驱动 dtype 模式 描述: ## 变更内容 ### 1. Tiling 校验补充 参考 ops-nn PR#8161 / PR#8095 的校验规范,为 FresnelCos 和 FresnelSin 算子补充以下 tiling 阶段校验: | 校验项 | 宏 | 说明 | |--------|----|------| | 维度数 | OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON | 输入维度数不超过 8 | | dtype | OP_LOGE_WITH_INVALID_INPUT_DTYPE | 替换原有简单 OP_LOGE,使用标准错误日志宏 | | format | OP_LOGE | 校验输入 format 必须为 ND | ### 2. Def 驱动 dtype 模式迁移 - 移除 tiling_key.h 中的 ASCENDC_TPL_ARGS_DECL / ASCENDC_TPL_SEL 模板参数声明 - apt.cpp 中 kernel 函数移除 template <typename T>,改用 DTYPE_X 宏(由 def.cpp DataTypeList 自动注入) ### 3. UT 用例补充 每个算子新增 2 个 tiling UT 用例: - invalid_dim_num_exceeds_max:9 维输入,期望 GRAPH_FAILED - invalid_format_nchw:NCHW 格式输入,期望 GRAPH_FAILED ## 涉及文件 - math/fresnel_cos/op_host/arch35/fresnel_cos_tiling_arch35.cpp - math/fresnel_cos/op_kernel/arch35/fresnel_cos_tiling_key.h - math/fresnel_cos/op_kernel/fresnel_cos_apt.cpp - math/fresnel_cos/tests/ut/op_host/arch35/test_fresnel_cos_tiling_arch35.cpp - math/fresnel_sin/op_host/arch35/fresnel_sin_tiling_arch35.cpp - math/fresnel_sin/op_kernel/arch35/fresnel_sin_tiling_key.h - math/fresnel_sin/op_kernel/fresnel_sin_apt.cpp - math/fresnel_sin/tests/ut/op_host/arch35/test_fresnel_sin_tiling_arch35.cpp See merge request: cann/ops-math!4447 | 3 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 14 天前 | ||
| 4 个月前 | ||
| 3 个月前 |