Pull Request已成功合入, 合并人@CANN-robot
(感谢 justsheldon 的贡献)变更摘要
此 PR 将多个 BLAS 测试文件中的精度校验方式统一调整为混合精度模式。原来各测试手动设置 VerifyConfig 的 mode(如 MERE_MARE、COMBINED)、mereThreshold、mareMultiplier、absTol、relTol 等字段,现在全部替换为调用 applyMixedTolerance 辅助函数,由其根据数据类型和参考数据自动推导合适的容差配置。同时移除了一些验证函数中冗余的阈值参数,并在部分测试中补充了数据类型判定和对角线元素处理逻辑。
主要改动
- 引入
applyMixedTolerance统一精度配置:在sgbmv、syr、syr2、trsv、strsv等测试中,原先手动配置VerifyConfig的mode、mereThreshold、mareMultiplier等字段的代码被替换为单次applyMixedTolerance(cfg, ACL_FLOAT, ...)调用,实现混合精度容差自动推导。 - 简化验证函数签名:
sgetri_batched的VerifyInverseMatrices、getrs_batched的VerifySolutions等函数移除了mereThreshold和mareMultiplier参数,内部改用applyMixedTolerance代替原来的手动配置逻辑。 gemv_batched测试增加输出数据类型判定:新增根据p.dtype值推导outDtype的逻辑(0 →ACL_FLOAT16,3 →ACL_BF16,其他 →ACL_FLOAT),并将该类型传入applyMixedTolerance。tpsv测试增强矩阵对角线处理:新增对ACLBLAS_UNIT对角类型的支持——当p.diag == ACLBLAS_UNIT时对所有元素按比例缩放,否则按矩阵维度动态增大对角线元素(boost = max(5.0, n)),同时将精度校验也迁移到applyMixedTolerance。


代码审查
Now I have all the information needed. Let me write the closing summary.
审查总结
已逐一审查全部 14 个变更文件:
| 文件 | 结论 |
|---|---|
test/gbmv/sgbmv/arch35/sgbmv_test.cpp |
无问题 |
test/gels_batched/sgels_batched/arch35/sgels_batched_test.cpp |
无问题 |
test/gemv_batched/arch35/gemv_batched_test.cpp |
P2 — 早期返回守卫 p.mereThreshold <= 0.0 语义与新的 applyMixedTolerance 脱节 |
test/gemv_batched/arch35/gemv_batched_test.csv |
P3 — 数据生成方式变更(RANDOM_100→RANDOM)与精度模式变更无关 |
test/getrf_batched/sgetrf_batched/arch35/sgetrf_batched_test.cpp |
无问题 |
test/getri_batched/sgetri_batched/arch35/sgetri_batched_test.cpp |
无问题 |
test/getrs_batched/CMakeLists.txt |
无问题(测试目标重命名一致) |
test/getrs_batched/arch35/getrs_batched_test.cpp |
无问题 |
test/getrs_batched/arch35/getrs_batched_test.csv |
无问题(仅重命名,内容未变) |
test/matinv_batched/arch35/matinv_batched_test.cpp |
P3 — VerifyInverseMatrices 保留已失效的 mereThreshold/mareMultiplier 参数 |
test/syr/ssyr/arch35/ssyr_test.cpp |
无问题 |
test/syr2/ssyr2/arch35/ssyr2_test.cpp |
无问题 |
test/tpsv/stpsv/arch35/stpsv_test.cpp |
无问题(对角调优变更合理) |
test/trsv/strsv/arch35/strsv_test.cpp |
无问题 |
发现统计:P2 × 1,P3 × 2,合计 3 个问题。
整体风险判断:低风险。核心精度模式变更(MERE_MARE/COMBINED → MIXED_TOLERANCE)在各文件中执行一致。主要遗留问题是 gemv_batched 中 p.mereThreshold 早期返回的语义不一致,以及 matinv_batched 中已过时的参数签名,均属于可后续清理的维护性问题,不影响当前功能正确性。CSV 数据生成变更需作者确认是否为有意改动。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-blas | ✅ 宋恺, xutianze (2/2) | ✅ 宋恺, xutianze (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
justsheldon, thanks for your pull request. All authors of the commits have signed the CLA. 👍


🟡 Medium Priority
gemv_batched_test.cpp 新增的 dtype→aclDataType 映射(第 298–300 行)遗漏了 dtype=2(HSS,FP16 计算)和 dtype=4(TSS,BF16 计算)两个 case。当前映射:
HSS 使用 FP16 算术,TSS 使用 BF16 算术。applyMixedTolerance 根据 dtype 选择不同的容差默认值:ACL_FLOAT16 的 atol=0.001953125,而 ACL_FLOAT 的 atol=1.53e-5(约 128 倍更严格)。对 HSS/TSS 测试用例使用 FP32 容差会导致合法的 FP16/BF16 计算结果被误判为失败。CSV 中受影响的用例包括 TC_L1_012–014、TC_L1_042(dtype=2)和 TC_L1_044、TC_L1_050–054(dtype=4)。
建议:为 dtype=2 (HSS) 映射 ACL_FLOAT16,为 dtype=4 (TSS) 映射 ACL_BF16:将 if (p.dtype == 0) 改为 if (p.dtype == 0 || p.dtype == 2),将 else if (p.dtype == 3) 改为 else if (p.dtype == 3 || p.dtype == 4)。
|
300 | + aclDataType outDtype = ACL_FLOAT; |
|
301 | + if (p.dtype == 0 || p.dtype == 2) outDtype = ACL_FLOAT16; |
| 300
| - else if (p.dtype == 3) outDtype = ACL_BF16; |
|
302 | + else if (p.dtype == 3 || p.dtype == 4) outDtype = ACL_BF16; |


compile


流水线任务触发成功
任务链接 [79143d4cbe5c4797acacb35c038e2175][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck | ❌ FAILED | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| precommit | ⚠️ WARNING | >>>>> | >>>>> |


compile


流水线任务触发成功
任务链接 [c6f370800d2049d1bc7bb6223f416720][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck | ❌ FAILED | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| precommit | ⚠️ WARNING | >>>>> | >>>>> |


compile


流水线任务触发成功
任务链接 [098b4595cf934ea096ccc084d3ca86bf][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| precommit | ⚠️ WARNING | >>>>> | >>>>> |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-07-17 16:14:02] CI执行结束


compile


流水线任务触发成功
任务链接 [04b1c4af7bfe442dbb0c61634e59ed8e][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A2_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| precommit | ⚠️ WARNING | >>>>> | >>>>> |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-07-20 09:23:28] CI执行结束


/lgtm
/approve


/approve


描述
将syr,syr2,trsv,gbmv,tpsv,getrs_batched,gemv_batched,matinv_batched,gels_batched,getrf_batched,getri_batched算子精度校验规则调整为混合精度模式
关联的Issue
https://gitcode.com/cann/ops-blas/issues/319
测试
文档更新
类型标签