| Files | Last commit | Last update |
|---|---|---|
[inv] 算子质量加固修复 + 平台适配 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6567 merge master_new into master [inv] 算子质量加固修复 + 平台适配 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: # [inv] 算子质量加固修复 + 平台适配 ## 描述 依据 Inv 算子六轮全量验证(静态检查 + ST 用例生成/评审/自验证 + 上板 TTK)发现的问题进行整改,并新增芯片平台支持。 本 PR 仅涉及 math/inv/ 目录(15 文件,+646/-152),不影响其他算子。 ## 变更概述 ### 1. P1 精度缺陷修复 **bf16 次正规输入倒数返回 inf**(op_kernel/arch35/inv.h) fp16/bf16 分支的 Div 未带 config,默认 INTRINSIC 算法对 fp32 次正规操作数执行 flush-to-zero,导致合法输入(bf16 最大次正规数 1.166e-38)的倒数结果错误地返回 inf 而非有限值 8.574e37。修复为与 float32 分支统一使用 DivConfig{PRECISION_0ULP_FTZ_FALSE}。 真机复现 FAIL(matched_ratio=0.0) → 修复后 PASS(1.0),整批 L0 零回归。 ### 2. 功能补齐 | 功能 | 文件 | 说明 | |---|---|---| | InferShape 推导 | op_host/inv_infershape.cpp(新增) | 注册 IMPL_OP_INFERSHAPE(Inv).InferShape(InferShape4Inv),复用仓内公共 InferShape4Elewise | | Tiling rank 上界 | op_host/arch35/inv_tiling_arch35.cpp | kMaxRank=8,rank>8 以 EZ0012 结构化诊断码显式拒绝 | | InferShape rank 上界 | op_host/inv_infershape.cpp | 与 Tiling 门对称,rank>8 拒绝(EZ0012) | | ascend350 适配 | CMakeLists.txt + inv_def.cpp | SUPPORT_COMPUTE_UNIT 增加 ascend350,AddConfig("ascend350"),tiling 复用 arch35 | ### 3. Golden 测试资产 新增 tests/assets/golden.py(206 行): - 注册 inv(Kernel/GEIR)+ tf.raw_ops.Inv(TF E2E,对齐插件 OriginOpType) - 参考计算全部由 torch 承担:float 用 torch.reciprocal 直接竞品,int32 三值映射用 torch.where 组合 - NumPy 仅做数据桥接;bfloat16 经 uint16 位视图往返(位级一致,含次正规数) - 延迟导入 torch(_ensure_torch()),纯 TF NPU 环境可加载注册 - 容差按 README 声明:FLOAT 1e-4 / FLOAT16 1e-3 / BFLOAT16 4e-3 / INT32 binary_equal ### 4. 注册面与资料修复 - proto 注释维度 1D~8D → 0D~8D (rank-0 tensor supported)(inv_proto.h:24) - INPUT/OUTPUT TensorType 保持原始声明不变(8 种/4 种) - README:调用表三列化(补"样例代码"列)、参数名 self/out → x/y(对齐 IR 端口)、补动态 shape/rank(-1/-2)声明 ### 5. 样例修复 | 修复 | 说明 | |---|---| | 输入缓冲区泄漏 | Tensor::SetData + DeleteFunc 移交所有权 | | 提前返回未清理 | 两条路径补 GEFinalize() | | AddGraph 返回值 | if (ret != SUCCESS) + 资源清理 | | 宏节点名截短 | "placeholder" + std::to_string(intputIndex) | | WriteDataToFile | 返回值检查 | ### 6. 注释修正 TilingKey/D_T_SELF/DTYPE_SELF 陈旧描述统一修正为 MODE 恒 0 + DTYPE_X 编译期分派(4 处源码 + 20 处 UT 注释)。 ## 关联 Issue https://gitcode.com/cann/ops-math/issues/3696 ## 测试 - **op_host UT**:46/46 通过(含新增 InferShape 8 例 + Tiling rank 拒绝 2 例) - **GEIR 样例真机**:execute samples success(ascend950) - **上板精度**:Kernel 480/494 PASS + GEIR 40/40 PASS(连续四轮零精度失败;14 例 rank-0 失败为 CANN DFX 环境缺陷,BIN 模式 100% 通过,非算子问题) - **bf16 次正规回归**:真机复现 FAIL → 修复后 PASS,整批 L0 零回归 - **README 冻结校验器**:validate_operator_readme.py --mode full PASSED ## 类型标签 - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-math!6567 | 15 days ago | |
迁移开源TF插件--math Co-authored-by: yaochen<yaochen15@huawei.com> # message auto-generated for no-merge-commit merge: !4308 merge transfer-math into master 迁移开源TF插件--math Created-by: nextyale Commit-by: yaochen Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:迁移TF插件 See merge request: cann/ops-math!4308 | 3 months ago | |
[inv] 算子质量加固修复 + 平台适配 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6567 merge master_new into master [inv] 算子质量加固修复 + 平台适配 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: # [inv] 算子质量加固修复 + 平台适配 ## 描述 依据 Inv 算子六轮全量验证(静态检查 + ST 用例生成/评审/自验证 + 上板 TTK)发现的问题进行整改,并新增芯片平台支持。 本 PR 仅涉及 math/inv/ 目录(15 文件,+646/-152),不影响其他算子。 ## 变更概述 ### 1. P1 精度缺陷修复 **bf16 次正规输入倒数返回 inf**(op_kernel/arch35/inv.h) fp16/bf16 分支的 Div 未带 config,默认 INTRINSIC 算法对 fp32 次正规操作数执行 flush-to-zero,导致合法输入(bf16 最大次正规数 1.166e-38)的倒数结果错误地返回 inf 而非有限值 8.574e37。修复为与 float32 分支统一使用 DivConfig{PRECISION_0ULP_FTZ_FALSE}。 真机复现 FAIL(matched_ratio=0.0) → 修复后 PASS(1.0),整批 L0 零回归。 ### 2. 功能补齐 | 功能 | 文件 | 说明 | |---|---|---| | InferShape 推导 | op_host/inv_infershape.cpp(新增) | 注册 IMPL_OP_INFERSHAPE(Inv).InferShape(InferShape4Inv),复用仓内公共 InferShape4Elewise | | Tiling rank 上界 | op_host/arch35/inv_tiling_arch35.cpp | kMaxRank=8,rank>8 以 EZ0012 结构化诊断码显式拒绝 | | InferShape rank 上界 | op_host/inv_infershape.cpp | 与 Tiling 门对称,rank>8 拒绝(EZ0012) | | ascend350 适配 | CMakeLists.txt + inv_def.cpp | SUPPORT_COMPUTE_UNIT 增加 ascend350,AddConfig("ascend350"),tiling 复用 arch35 | ### 3. Golden 测试资产 新增 tests/assets/golden.py(206 行): - 注册 inv(Kernel/GEIR)+ tf.raw_ops.Inv(TF E2E,对齐插件 OriginOpType) - 参考计算全部由 torch 承担:float 用 torch.reciprocal 直接竞品,int32 三值映射用 torch.where 组合 - NumPy 仅做数据桥接;bfloat16 经 uint16 位视图往返(位级一致,含次正规数) - 延迟导入 torch(_ensure_torch()),纯 TF NPU 环境可加载注册 - 容差按 README 声明:FLOAT 1e-4 / FLOAT16 1e-3 / BFLOAT16 4e-3 / INT32 binary_equal ### 4. 注册面与资料修复 - proto 注释维度 1D~8D → 0D~8D (rank-0 tensor supported)(inv_proto.h:24) - INPUT/OUTPUT TensorType 保持原始声明不变(8 种/4 种) - README:调用表三列化(补"样例代码"列)、参数名 self/out → x/y(对齐 IR 端口)、补动态 shape/rank(-1/-2)声明 ### 5. 样例修复 | 修复 | 说明 | |---|---| | 输入缓冲区泄漏 | Tensor::SetData + DeleteFunc 移交所有权 | | 提前返回未清理 | 两条路径补 GEFinalize() | | AddGraph 返回值 | if (ret != SUCCESS) + 资源清理 | | 宏节点名截短 | "placeholder" + std::to_string(intputIndex) | | WriteDataToFile | 返回值检查 | ### 6. 注释修正 TilingKey/D_T_SELF/DTYPE_SELF 陈旧描述统一修正为 MODE 恒 0 + DTYPE_X 编译期分派(4 处源码 + 20 处 UT 注释)。 ## 关联 Issue https://gitcode.com/cann/ops-math/issues/3696 ## 测试 - **op_host UT**:46/46 通过(含新增 InferShape 8 例 + Tiling rank 拒绝 2 例) - **GEIR 样例真机**:execute samples success(ascend950) - **上板精度**:Kernel 480/494 PASS + GEIR 40/40 PASS(连续四轮零精度失败;14 例 rank-0 失败为 CANN DFX 环境缺陷,BIN 模式 100% 通过,非算子问题) - **bf16 次正规回归**:真机复现 FAIL → 修复后 PASS,整批 L0 零回归 - **README 冻结校验器**:validate_operator_readme.py --mode full PASSED ## 类型标签 - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-math!6567 | 15 days ago | |
[inv] 算子质量加固修复 + 平台适配 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6567 merge master_new into master [inv] 算子质量加固修复 + 平台适配 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: # [inv] 算子质量加固修复 + 平台适配 ## 描述 依据 Inv 算子六轮全量验证(静态检查 + ST 用例生成/评审/自验证 + 上板 TTK)发现的问题进行整改,并新增芯片平台支持。 本 PR 仅涉及 math/inv/ 目录(15 文件,+646/-152),不影响其他算子。 ## 变更概述 ### 1. P1 精度缺陷修复 **bf16 次正规输入倒数返回 inf**(op_kernel/arch35/inv.h) fp16/bf16 分支的 Div 未带 config,默认 INTRINSIC 算法对 fp32 次正规操作数执行 flush-to-zero,导致合法输入(bf16 最大次正规数 1.166e-38)的倒数结果错误地返回 inf 而非有限值 8.574e37。修复为与 float32 分支统一使用 DivConfig{PRECISION_0ULP_FTZ_FALSE}。 真机复现 FAIL(matched_ratio=0.0) → 修复后 PASS(1.0),整批 L0 零回归。 ### 2. 功能补齐 | 功能 | 文件 | 说明 | |---|---|---| | InferShape 推导 | op_host/inv_infershape.cpp(新增) | 注册 IMPL_OP_INFERSHAPE(Inv).InferShape(InferShape4Inv),复用仓内公共 InferShape4Elewise | | Tiling rank 上界 | op_host/arch35/inv_tiling_arch35.cpp | kMaxRank=8,rank>8 以 EZ0012 结构化诊断码显式拒绝 | | InferShape rank 上界 | op_host/inv_infershape.cpp | 与 Tiling 门对称,rank>8 拒绝(EZ0012) | | ascend350 适配 | CMakeLists.txt + inv_def.cpp | SUPPORT_COMPUTE_UNIT 增加 ascend350,AddConfig("ascend350"),tiling 复用 arch35 | ### 3. Golden 测试资产 新增 tests/assets/golden.py(206 行): - 注册 inv(Kernel/GEIR)+ tf.raw_ops.Inv(TF E2E,对齐插件 OriginOpType) - 参考计算全部由 torch 承担:float 用 torch.reciprocal 直接竞品,int32 三值映射用 torch.where 组合 - NumPy 仅做数据桥接;bfloat16 经 uint16 位视图往返(位级一致,含次正规数) - 延迟导入 torch(_ensure_torch()),纯 TF NPU 环境可加载注册 - 容差按 README 声明:FLOAT 1e-4 / FLOAT16 1e-3 / BFLOAT16 4e-3 / INT32 binary_equal ### 4. 注册面与资料修复 - proto 注释维度 1D~8D → 0D~8D (rank-0 tensor supported)(inv_proto.h:24) - INPUT/OUTPUT TensorType 保持原始声明不变(8 种/4 种) - README:调用表三列化(补"样例代码"列)、参数名 self/out → x/y(对齐 IR 端口)、补动态 shape/rank(-1/-2)声明 ### 5. 样例修复 | 修复 | 说明 | |---|---| | 输入缓冲区泄漏 | Tensor::SetData + DeleteFunc 移交所有权 | | 提前返回未清理 | 两条路径补 GEFinalize() | | AddGraph 返回值 | if (ret != SUCCESS) + 资源清理 | | 宏节点名截短 | "placeholder" + std::to_string(intputIndex) | | WriteDataToFile | 返回值检查 | ### 6. 注释修正 TilingKey/D_T_SELF/DTYPE_SELF 陈旧描述统一修正为 MODE 恒 0 + DTYPE_X 编译期分派(4 处源码 + 20 处 UT 注释)。 ## 关联 Issue https://gitcode.com/cann/ops-math/issues/3696 ## 测试 - **op_host UT**:46/46 通过(含新增 InferShape 8 例 + Tiling rank 拒绝 2 例) - **GEIR 样例真机**:execute samples success(ascend950) - **上板精度**:Kernel 480/494 PASS + GEIR 40/40 PASS(连续四轮零精度失败;14 例 rank-0 失败为 CANN DFX 环境缺陷,BIN 模式 100% 通过,非算子问题) - **bf16 次正规回归**:真机复现 FAIL → 修复后 PASS,整批 L0 零回归 - **README 冻结校验器**:validate_operator_readme.py --mode full PASSED ## 类型标签 - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-math!6567 | 15 days ago | |
[inv] 算子质量加固修复 + 平台适配 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6567 merge master_new into master [inv] 算子质量加固修复 + 平台适配 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: # [inv] 算子质量加固修复 + 平台适配 ## 描述 依据 Inv 算子六轮全量验证(静态检查 + ST 用例生成/评审/自验证 + 上板 TTK)发现的问题进行整改,并新增芯片平台支持。 本 PR 仅涉及 math/inv/ 目录(15 文件,+646/-152),不影响其他算子。 ## 变更概述 ### 1. P1 精度缺陷修复 **bf16 次正规输入倒数返回 inf**(op_kernel/arch35/inv.h) fp16/bf16 分支的 Div 未带 config,默认 INTRINSIC 算法对 fp32 次正规操作数执行 flush-to-zero,导致合法输入(bf16 最大次正规数 1.166e-38)的倒数结果错误地返回 inf 而非有限值 8.574e37。修复为与 float32 分支统一使用 DivConfig{PRECISION_0ULP_FTZ_FALSE}。 真机复现 FAIL(matched_ratio=0.0) → 修复后 PASS(1.0),整批 L0 零回归。 ### 2. 功能补齐 | 功能 | 文件 | 说明 | |---|---|---| | InferShape 推导 | op_host/inv_infershape.cpp(新增) | 注册 IMPL_OP_INFERSHAPE(Inv).InferShape(InferShape4Inv),复用仓内公共 InferShape4Elewise | | Tiling rank 上界 | op_host/arch35/inv_tiling_arch35.cpp | kMaxRank=8,rank>8 以 EZ0012 结构化诊断码显式拒绝 | | InferShape rank 上界 | op_host/inv_infershape.cpp | 与 Tiling 门对称,rank>8 拒绝(EZ0012) | | ascend350 适配 | CMakeLists.txt + inv_def.cpp | SUPPORT_COMPUTE_UNIT 增加 ascend350,AddConfig("ascend350"),tiling 复用 arch35 | ### 3. Golden 测试资产 新增 tests/assets/golden.py(206 行): - 注册 inv(Kernel/GEIR)+ tf.raw_ops.Inv(TF E2E,对齐插件 OriginOpType) - 参考计算全部由 torch 承担:float 用 torch.reciprocal 直接竞品,int32 三值映射用 torch.where 组合 - NumPy 仅做数据桥接;bfloat16 经 uint16 位视图往返(位级一致,含次正规数) - 延迟导入 torch(_ensure_torch()),纯 TF NPU 环境可加载注册 - 容差按 README 声明:FLOAT 1e-4 / FLOAT16 1e-3 / BFLOAT16 4e-3 / INT32 binary_equal ### 4. 注册面与资料修复 - proto 注释维度 1D~8D → 0D~8D (rank-0 tensor supported)(inv_proto.h:24) - INPUT/OUTPUT TensorType 保持原始声明不变(8 种/4 种) - README:调用表三列化(补"样例代码"列)、参数名 self/out → x/y(对齐 IR 端口)、补动态 shape/rank(-1/-2)声明 ### 5. 样例修复 | 修复 | 说明 | |---|---| | 输入缓冲区泄漏 | Tensor::SetData + DeleteFunc 移交所有权 | | 提前返回未清理 | 两条路径补 GEFinalize() | | AddGraph 返回值 | if (ret != SUCCESS) + 资源清理 | | 宏节点名截短 | "placeholder" + std::to_string(intputIndex) | | WriteDataToFile | 返回值检查 | ### 6. 注释修正 TilingKey/D_T_SELF/DTYPE_SELF 陈旧描述统一修正为 MODE 恒 0 + DTYPE_X 编译期分派(4 处源码 + 20 处 UT 注释)。 ## 关联 Issue https://gitcode.com/cann/ops-math/issues/3696 ## 测试 - **op_host UT**:46/46 通过(含新增 InferShape 8 例 + Tiling rank 拒绝 2 例) - **GEIR 样例真机**:execute samples success(ascend950) - **上板精度**:Kernel 480/494 PASS + GEIR 40/40 PASS(连续四轮零精度失败;14 例 rank-0 失败为 CANN DFX 环境缺陷,BIN 模式 100% 通过,非算子问题) - **bf16 次正规回归**:真机复现 FAIL → 修复后 PASS,整批 L0 零回归 - **README 冻结校验器**:validate_operator_readme.py --mode full PASSED ## 类型标签 - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-math!6567 | 15 days ago | |
Inv 算子 golden 容差从 mix_tolerance 改为 cross_check L1 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6955 merge master_new into master Inv 算子 golden 容差从 mix_tolerance 改为 cross_check L1 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: ## 描述 Inv 算子 golden 容差从 mix_tolerance 改为 cross_check L1(1 文件 +7/-9)。 两处 tolerance dict(InvTestSpec、InvTensorFlowTestSpec)的浮点条目从 mix_tolerance rtol/atol 改为 cross_check L1,int32 保持 binary_equal 不变。 cross_check 为三方判据(NPU 输出 + CPU golden + XPU 第三方参考),需要 TTK XPU Server 支持(ttk.conf.yaml 配置)。 ## 关联的 Issue https://gitcode.com/cann/ops-math/issues/4381 ## 测试 **上板精度验证**(Ascend950PR + XPU Server CPU 三方参考,cross_check L1): - L0 全量 **43/43 PASS(100%)**,覆盖全 dtype: - float32: 14/14 - float16: 15/15(含次正规、rank-0 标量、2^31 边界、空 Tensor) - bfloat16: 7/7(含次正规、rank-0 标量、空 Tensor) - int32: 7/7(三值映射含 INT_MIN/MAX) - 零精度失败、零 PROFILE_CRASH ## 文档更新 不涉及。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!6955 | 8 days ago | |
[inv] 算子质量加固修复 + 平台适配 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6567 merge master_new into master [inv] 算子质量加固修复 + 平台适配 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: # [inv] 算子质量加固修复 + 平台适配 ## 描述 依据 Inv 算子六轮全量验证(静态检查 + ST 用例生成/评审/自验证 + 上板 TTK)发现的问题进行整改,并新增芯片平台支持。 本 PR 仅涉及 math/inv/ 目录(15 文件,+646/-152),不影响其他算子。 ## 变更概述 ### 1. P1 精度缺陷修复 **bf16 次正规输入倒数返回 inf**(op_kernel/arch35/inv.h) fp16/bf16 分支的 Div 未带 config,默认 INTRINSIC 算法对 fp32 次正规操作数执行 flush-to-zero,导致合法输入(bf16 最大次正规数 1.166e-38)的倒数结果错误地返回 inf 而非有限值 8.574e37。修复为与 float32 分支统一使用 DivConfig{PRECISION_0ULP_FTZ_FALSE}。 真机复现 FAIL(matched_ratio=0.0) → 修复后 PASS(1.0),整批 L0 零回归。 ### 2. 功能补齐 | 功能 | 文件 | 说明 | |---|---|---| | InferShape 推导 | op_host/inv_infershape.cpp(新增) | 注册 IMPL_OP_INFERSHAPE(Inv).InferShape(InferShape4Inv),复用仓内公共 InferShape4Elewise | | Tiling rank 上界 | op_host/arch35/inv_tiling_arch35.cpp | kMaxRank=8,rank>8 以 EZ0012 结构化诊断码显式拒绝 | | InferShape rank 上界 | op_host/inv_infershape.cpp | 与 Tiling 门对称,rank>8 拒绝(EZ0012) | | ascend350 适配 | CMakeLists.txt + inv_def.cpp | SUPPORT_COMPUTE_UNIT 增加 ascend350,AddConfig("ascend350"),tiling 复用 arch35 | ### 3. Golden 测试资产 新增 tests/assets/golden.py(206 行): - 注册 inv(Kernel/GEIR)+ tf.raw_ops.Inv(TF E2E,对齐插件 OriginOpType) - 参考计算全部由 torch 承担:float 用 torch.reciprocal 直接竞品,int32 三值映射用 torch.where 组合 - NumPy 仅做数据桥接;bfloat16 经 uint16 位视图往返(位级一致,含次正规数) - 延迟导入 torch(_ensure_torch()),纯 TF NPU 环境可加载注册 - 容差按 README 声明:FLOAT 1e-4 / FLOAT16 1e-3 / BFLOAT16 4e-3 / INT32 binary_equal ### 4. 注册面与资料修复 - proto 注释维度 1D~8D → 0D~8D (rank-0 tensor supported)(inv_proto.h:24) - INPUT/OUTPUT TensorType 保持原始声明不变(8 种/4 种) - README:调用表三列化(补"样例代码"列)、参数名 self/out → x/y(对齐 IR 端口)、补动态 shape/rank(-1/-2)声明 ### 5. 样例修复 | 修复 | 说明 | |---|---| | 输入缓冲区泄漏 | Tensor::SetData + DeleteFunc 移交所有权 | | 提前返回未清理 | 两条路径补 GEFinalize() | | AddGraph 返回值 | if (ret != SUCCESS) + 资源清理 | | 宏节点名截短 | "placeholder" + std::to_string(intputIndex) | | WriteDataToFile | 返回值检查 | ### 6. 注释修正 TilingKey/D_T_SELF/DTYPE_SELF 陈旧描述统一修正为 MODE 恒 0 + DTYPE_X 编译期分派(4 处源码 + 20 处 UT 注释)。 ## 关联 Issue https://gitcode.com/cann/ops-math/issues/3696 ## 测试 - **op_host UT**:46/46 通过(含新增 InferShape 8 例 + Tiling rank 拒绝 2 例) - **GEIR 样例真机**:execute samples success(ascend950) - **上板精度**:Kernel 480/494 PASS + GEIR 40/40 PASS(连续四轮零精度失败;14 例 rank-0 失败为 CANN DFX 环境缺陷,BIN 模式 100% 通过,非算子问题) - **bf16 次正规回归**:真机复现 FAIL → 修复后 PASS,整批 L0 零回归 - **README 冻结校验器**:validate_operator_readme.py --mode full PASSED ## 类型标签 - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-math!6567 | 15 days ago | |
[inv] 算子质量加固修复 + 平台适配 Co-authored-by: JasonZhang88<jason.zhangshen@huawei.com> # message auto-generated for no-merge-commit merge: !6567 merge master_new into master [inv] 算子质量加固修复 + 平台适配 Created-by: JasonZhang88 Commit-by: JasonZhang88 Merged-by: cann-robot Description: # [inv] 算子质量加固修复 + 平台适配 ## 描述 依据 Inv 算子六轮全量验证(静态检查 + ST 用例生成/评审/自验证 + 上板 TTK)发现的问题进行整改,并新增芯片平台支持。 本 PR 仅涉及 math/inv/ 目录(15 文件,+646/-152),不影响其他算子。 ## 变更概述 ### 1. P1 精度缺陷修复 **bf16 次正规输入倒数返回 inf**(op_kernel/arch35/inv.h) fp16/bf16 分支的 Div 未带 config,默认 INTRINSIC 算法对 fp32 次正规操作数执行 flush-to-zero,导致合法输入(bf16 最大次正规数 1.166e-38)的倒数结果错误地返回 inf 而非有限值 8.574e37。修复为与 float32 分支统一使用 DivConfig{PRECISION_0ULP_FTZ_FALSE}。 真机复现 FAIL(matched_ratio=0.0) → 修复后 PASS(1.0),整批 L0 零回归。 ### 2. 功能补齐 | 功能 | 文件 | 说明 | |---|---|---| | InferShape 推导 | op_host/inv_infershape.cpp(新增) | 注册 IMPL_OP_INFERSHAPE(Inv).InferShape(InferShape4Inv),复用仓内公共 InferShape4Elewise | | Tiling rank 上界 | op_host/arch35/inv_tiling_arch35.cpp | kMaxRank=8,rank>8 以 EZ0012 结构化诊断码显式拒绝 | | InferShape rank 上界 | op_host/inv_infershape.cpp | 与 Tiling 门对称,rank>8 拒绝(EZ0012) | | ascend350 适配 | CMakeLists.txt + inv_def.cpp | SUPPORT_COMPUTE_UNIT 增加 ascend350,AddConfig("ascend350"),tiling 复用 arch35 | ### 3. Golden 测试资产 新增 tests/assets/golden.py(206 行): - 注册 inv(Kernel/GEIR)+ tf.raw_ops.Inv(TF E2E,对齐插件 OriginOpType) - 参考计算全部由 torch 承担:float 用 torch.reciprocal 直接竞品,int32 三值映射用 torch.where 组合 - NumPy 仅做数据桥接;bfloat16 经 uint16 位视图往返(位级一致,含次正规数) - 延迟导入 torch(_ensure_torch()),纯 TF NPU 环境可加载注册 - 容差按 README 声明:FLOAT 1e-4 / FLOAT16 1e-3 / BFLOAT16 4e-3 / INT32 binary_equal ### 4. 注册面与资料修复 - proto 注释维度 1D~8D → 0D~8D (rank-0 tensor supported)(inv_proto.h:24) - INPUT/OUTPUT TensorType 保持原始声明不变(8 种/4 种) - README:调用表三列化(补"样例代码"列)、参数名 self/out → x/y(对齐 IR 端口)、补动态 shape/rank(-1/-2)声明 ### 5. 样例修复 | 修复 | 说明 | |---|---| | 输入缓冲区泄漏 | Tensor::SetData + DeleteFunc 移交所有权 | | 提前返回未清理 | 两条路径补 GEFinalize() | | AddGraph 返回值 | if (ret != SUCCESS) + 资源清理 | | 宏节点名截短 | "placeholder" + std::to_string(intputIndex) | | WriteDataToFile | 返回值检查 | ### 6. 注释修正 TilingKey/D_T_SELF/DTYPE_SELF 陈旧描述统一修正为 MODE 恒 0 + DTYPE_X 编译期分派(4 处源码 + 20 处 UT 注释)。 ## 关联 Issue https://gitcode.com/cann/ops-math/issues/3696 ## 测试 - **op_host UT**:46/46 通过(含新增 InferShape 8 例 + Tiling rank 拒绝 2 例) - **GEIR 样例真机**:execute samples success(ascend950) - **上板精度**:Kernel 480/494 PASS + GEIR 40/40 PASS(连续四轮零精度失败;14 例 rank-0 失败为 CANN DFX 环境缺陷,BIN 模式 100% 通过,非算子问题) - **bf16 次正规回归**:真机复现 FAIL → 修复后 PASS,整批 L0 零回归 - **README 冻结校验器**:validate_operator_readme.py --mode full PASSED ## 类型标签 - [x] Bug修复 - [x] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-math!6567 | 15 days ago | |
docs: add English translations for markdown files Co-authored-by: jenny_xiang<jenny.xiang@huawei.com> # message auto-generated for no-merge-commit merge: !7113 merge docs/add-english-translations into master docs: add English translations for markdown files Created-by: jenny_xiang Commit-by: jenny_xiang Merged-by: cann-robot Description: ## 描述 新增仓库Markdown文档英文译稿(第二批,共409个文件):第一批(已合入)之外的其余全部译稿,覆盖conversion、examples、ge、math、random各类算子README译稿,以及CHANGELOG_en.md、.gitcode PR模板英文版等。 本批内全部仓内链接均指向master已有文件(含第一批已合入的21+2篇译稿),合入后本仓432篇英文文档全部就位,链接完整生效。 本批同时包含4篇基于最新源文档的增量更新(math/ada_cast、math/prod_force_se_a、math/sinkhorn、math/xlogy,对应上游近期文档变更)。 ## 关联的Issue 无 ## 测试 文档类变更,无需算子测试;已通过链接有效性校验(本批全部相对链接仅指向master已有文件,无指向本PR外未提交文件的链接),并完成逐篇翻译规范自查与语义校对(含支持状态表、限定词、术语、数值符号核对)。 ## 文档更新 新增409个英文译稿文件(*_en.md / .en-US.md),不修改任何现有文件。 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!7113 | 5 days ago |
Inv
English | 简体中文
Product Support Status
| Product | Supported |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | √ |
| Atlas inference products | √ |
| Atlas training products | √ |
Function Description
-
Operator function: computes the reciprocal of each element in the input tensor element-wise.
-
Computation formula:
yi=1xiy_{i}=\frac{1}{x_{i}} yi=xi1
-
Floating-point types (FLOAT, FLOAT16, BFLOAT16) compute the true reciprocal according to IEEE-754 (division by zero yields ±Inf\pm\text{Inf}±Inf, ±Inf\pm\text{Inf}±Inf yields ±0\pm0±0, and NaN yields NaN).
-
INT32 computes the integer reciprocal truncated toward zero. For integers, 1/x1/x1/x is non-zero only when ∣x∣=1|x|=1∣x∣=1, which is equivalent to a three-value mapping:
yi={+1xi=+1−1xi=−10other (including xi=0,∣xi∣≥2,INT_MIN,INT_MAX)y_{i}= \begin{cases} +1 & x_{i}=+1 \\ -1 & x_{i}=-1 \\ 0 & \text{other (including } x_{i}=0, |x_{i}|\ge 2, \text{INT\_MIN}, \text{INT\_MAX)} \end{cases} yi=⎩⎪⎪⎨⎪⎪⎧+1−10xi=+1xi=−1other (including xi=0,∣xi∣≥2,INT_MIN,INT_MAX)
Here, xi=0x_{i}=0xi=0 is mapped to 000 without throwing an exception, and INT_MIN(−2147483648)\text{INT\_MIN}(-2147483648)INT_MIN(−2147483648) and INT_MAX(2147483647)\text{INT\_MAX}(2147483647)INT_MAX(2147483647) are both mapped to 000 without overflow.
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| x | Input | Input parameter for the inv computation, which is x in the formula. Empty tensors and non-contiguous tensors are supported, and the number of shape dimensions ranges from 0 to 8. | FLOAT, FLOAT16, BFLOAT16, INT32 | ND |
| y | Output | Output parameter for the inv computation, which is y in the formula. The shape and data type are the same as those of x. | FLOAT, FLOAT16, BFLOAT16, INT32 | ND |
Constraint Description
- x and y must have the same shape and dtype, with element-wise computation and no broadcasting.
- Dynamic shape support: dynamic shapes and dynamic ranks are supported (-1 indicates an unknown dimension / -2 indicates an unknown rank). The dimension and rank are specified by the actual input at runtime, and after specification, the number of shape dimensions must range from 0 to 8.
- The precision of the floating-point path follows community standards: FLOAT rtol/atol = 1e-4, FLOAT16 = 1e-3, and BFLOAT16 = 4e-3.
- The INT32 path is an exact match (bitwise, rtol = atol = 0). The three-value mapping is implemented through pure integer comparison and selection, without float32 conversion or negating INT_MIN. Therefore, INT_MIN/INT_MAX do not overflow, and x = 0 does not throw an exception.
Invocation Description
| Invocation Method | Sample Code | Description |
|---|---|---|
| GE graph mode | test_geir_inv | Invokes the Inv operator by building a graph through the operator IR. |