| Support Acos op with AscendC,new data type float16 and bfloat16
Co-authored-by: zyf0712<zhangyufei63@huawei.com>
# message auto-generated for no-merge-commit merge:
!1095 merge master into master
Support Acos op with AscendC,new data type float16 and bfloat16
Created-by: luomin2005
Commit-by: luomin2005;zyf0712
Merged-by: cann-robot
Description: 描述
使用AscendC实现acos算子,本次新增数据类型float16和bfloat16,修复kernel计算Compute未进行256字节对齐问题,并且完善UT用例
出问题的log日志如下
[2026-02-03 14:28:27] tileLength =1638
[2026-02-03 14:28:29] [ERROR][Block_1][AIV_0][/home/l00614971/cann/cann-9.0.0/aarch64-linux/asc/include/basic_api/../../impl/basic_api/kernel_operator_vec_cmpsel_intf_impl.h:314][CompareScalar][182417] Failed to check count elements size in CompareScalar, current size is 6556, should be an integer multiple of 256.
[2026-02-03 14:28:29] [ERROR][CORE_1][pid 182417] error happened! =========
关联的Issue
[Requirement|需求建议]: 支持AscendC类型Acos算子
测试
[2026-02-09 16:40:25] [INFO] RUNTIME(264152,test_aclnn_acos):2026-02-09-16:40:25.044.668 [task_fail_callback_data_manager.cc:93] 264152 ~TaskFailCallBackManager: Destructor.
[2026-02-09 16:40:25] [INFO] ATRACE(264152,test_aclnn_acos):2026-02-09-16:40:25.044.913 [stacktrace_signal.c:194](tid:264152) unregister all signal handlers, can not capture signal.
[2026-02-09 16:40:25] [INFO] ATRACE(264152,test_aclnn_acos):2026-02-09-16:40:25.101.762 [awatchdog_monitor.c:233](tid:264152) AwdMonitorExit
[2026-02-09 16:40:25] 0 acos(-inf) = nan
[2026-02-09 16:40:25] 1 acos(-12.000000) = nan
[2026-02-09 16:40:25] 2 acos(-1.000001) = nan
[2026-02-09 16:40:25] 3 acos(-1.000010) = nan
[2026-02-09 16:40:25] 4 acos(-1.000100) = nan
[2026-02-09 16:40:25] 5 acos(-1.001000) = nan
[2026-02-09 16:40:25] 6 acos(-1.010000) = nan
[2026-02-09 16:40:25] 7 acos(-1.000000) = 3.141593
[2026-02-09 16:40:25] 8 acos(-0.999990) = 3.137117
[2026-02-09 16:40:25] 9 acos(-0.999900) = 3.127449
[2026-02-09 16:40:25] 10 acos(-0.999000) = 3.096868
[2026-02-09 16:40:25] 11 acos(-0.990000) = 3.000053
[2026-02-09 16:40:25] 12 acos(-0.900000) = 2.690566
[2026-02-09 16:40:25] 13 acos(-0.800000) = 2.498095
[2026-02-09 16:40:25] 14 acos(-0.710000) = 2.360346
[2026-02-09 16:40:25] 15 acos(-0.705000) = 2.353167
[2026-02-09 16:40:25] 16 acos(-0.700000) = 2.346148
[2026-02-09 16:40:25] 17 acos(-0.650000) = 2.278369
[2026-02-09 16:40:25] 18 acos(-0.600000) = 2.214295
[2026-02-09 16:40:25] 19 acos(-0.500000) = 2.094395
[2026-02-09 16:40:25] 20 acos(-0.400000) = 1.982313
[2026-02-09 16:40:25] 21 acos(-0.300000) = 1.875489
[2026-02-09 16:40:25] 22 acos(-0.200000) = 1.772154
[2026-02-09 16:40:25] 23 acos(-0.100000) = 1.670964
[2026-02-09 16:40:25] 24 acos(-0.010000) = 1.580796
[2026-02-09 16:40:25] 25 acos(-0.001000) = 1.571796
[2026-02-09 16:40:25] 26 acos(-0.000100) = 1.570896
[2026-02-09 16:40:25] 27 acos(-0.000010) = 1.570806
[2026-02-09 16:40:25] 28 acos(-0.000001) = 1.570797
[2026-02-09 16:40:25] 29 acos(-0.000000) = 1.570796
[2026-02-09 16:40:25] 30 acos(0.000000) = 1.570796
[2026-02-09 16:40:25] 31 acos(nan) = nan
[2026-02-09 16:40:25] 32 acos(0.000000) = 1.570796
[2026-02-09 16:40:25] 33 acos(0.000000) = 1.570796
[2026-02-09 16:40:25] 34 acos(0.000001) = 1.570795
[2026-02-09 16:40:25] 35 acos(0.000010) = 1.570786
[2026-02-09 16:40:25] 36 acos(0.000100) = 1.570696
[2026-02-09 16:40:25] 37 acos(0.010000) = 1.560796
[2026-02-09 16:40:25] 38 acos(0.100000) = 1.470629
[2026-02-09 16:40:25] 39 acos(0.200000) = 1.369438
[2026-02-09 16:40:25] 40 acos(0.200000) = 1.369438
[2026-02-09 16:40:25] 41 acos(0.300000) = 1.266104
[2026-02-09 16:40:25] 42 acos(0.400000) = 1.159280
[2026-02-09 16:40:25] 43 acos(0.500000) = 1.047198
[2026-02-09 16:40:25] 44 acos(0.500000) = 1.047198
[2026-02-09 16:40:25] 45 acos(0.600000) = 0.927298
[2026-02-09 16:40:25] 46 acos(0.650000) = 0.863224
[2026-02-09 16:40:25] 47 acos(0.700000) = 0.795445
[2026-02-09 16:40:25] 48 acos(0.705000) = 0.788426
[2026-02-09 16:40:25] 49 acos(0.710000) = 0.781247
[2026-02-09 16:40:25] 50 acos(0.800000) = 0.643498
[2026-02-09 16:40:25] 51 acos(0.900000) = 0.451027
[2026-02-09 16:40:25] 52 acos(0.990000) = 0.141539
[2026-02-09 16:40:25] 53 acos(0.999000) = 0.044725
[2026-02-09 16:40:25] 54 acos(0.999900) = 0.014144
[2026-02-09 16:40:25] 55 acos(0.999990) = 0.004475
[2026-02-09 16:40:25] 56 acos(1.000000) = 0.000000
[2026-02-09 16:40:25] 57 acos(1.010000) = nan
[2026-02-09 16:40:25] 58 acos(1.001000) = nan
[2026-02-09 16:40:25] 59 acos(1.000100) = nan
[2026-02-09 16:40:25] 60 acos(1.000010) = nan
[2026-02-09 16:40:25] 61 acos(1.000001) = nan
[2026-02-09 16:40:25] 62 acos(12.000000) = nan
[2026-02-09 16:40:25] 63 acos(inf) = nan
[2026-02-09 16:40:25] run test_aclnn_acos, execute samples success
ST用例测试通过,测试数据随机,形状10281*10241
(base) [root@shlqh-cann-cluster8-141-61-33-172 st]# python test_acos.py
fp32 result: True
fp16 result: True
bf16 result: True
(base) [root@shlqh-cann-cluster8-141-61-33-172 st]#
Kernel UT测试结果如下:测试数据形状(32, 8, 7, 7) 精度误差绝对误差和相对误差float32类型控制10的负4次方,float16控制10的负3次方,bfloat16控制4*10的负三次方
[2026-02-09 16:43:08] [SUCCESS][CORE_39][pid 266919] exit success!
[2026-02-09 16:43:12] PASSED!
[2026-02-09 16:43:12] compare result: True
[2026-02-09 16:43:12] [ OK ] AcosTest.test_case_2 (12822 ms)
[2026-02-09 16:43:12] AcosTest TearDown
[2026-02-09 16:43:12]
[2026-02-09 16:43:12] [----------] 3 tests from AcosTest (40890 ms total)
[2026-02-09 16:43:12]
[2026-02-09 16:43:12] [----------] Global test environment tear-down
[2026-02-09 16:43:12] Global Environment TearDown
[2026-02-09 16:43:12] [==========] 3 tests from 1 test suite ran. (40922 ms total)
[2026-02-09 16:43:12] [ PASSED ] 3 tests.
host侧tiling UT测试通过
[2026-02-09 16:45:17] [----------] 5 tests from AcosTiling
[2026-02-09 16:45:17] AcosTiling SetUp
[2026-02-09 16:45:17] [ RUN ] AcosTiling.acos_tiling_001
[2026-02-09 16:45:17] [INFO] GE(268526,math_op_host_ut):2026-02-09-16:45:17.592.907 [op_context_builder_impl.cc:103]268526 CreateComputeNodeInfoImpl:Node Acos, compute_node_info attr_size 48, outputs_ins_info_size:48, offset:416, total_size:520.
[2026-02-09 16:45:17] [ OK ] AcosTiling.acos_tiling_001 (0 ms)
[2026-02-09 16:45:17] [ RUN ] AcosTiling.acos_tiling_002
[2026-02-09 16:45:17] [INFO] GE(268526,math_op_host_ut):2026-02-09-16:45:17.593.743 [op_context_builder_impl.cc:103]268526 CreateComputeNodeInfoImpl:Node Acos, compute_node_info attr_size 48, outputs_ins_info_size:48, offset:416, total_size:520.
[2026-02-09 16:45:17] [ OK ] AcosTiling.acos_tiling_002 (0 ms)
[2026-02-09 16:45:17] [ RUN ] AcosTiling.acos_tiling_003
[2026-02-09 16:45:17] [INFO] GE(268526,math_op_host_ut):2026-02-09-16:45:17.594.411 [op_context_builder_impl.cc:103]268526 CreateComputeNodeInfoImpl:Node Acos, compute_node_info attr_size 48, outputs_ins_info_size:48, offset:416, total_size:520.
[2026-02-09 16:45:17] [ OK ] AcosTiling.acos_tiling_003 (0 ms)
[2026-02-09 16:45:17] [ RUN ] AcosTiling.acos_tiling_004
[2026-02-09 16:45:17] [INFO] GE(268526,math_op_host_ut):2026-02-09-16:45:17.595.066 [op_context_builder_impl.cc:103]268526 CreateComputeNodeInfoImpl:Node Acos, compute_node_info attr_size 48, outputs_ins_info_size:48, offset:416, total_size:520.
[2026-02-09 16:45:17] [ OK ] AcosTiling.acos_tiling_004 (0 ms)
[2026-02-09 16:45:17] [ RUN ] AcosTiling.acos_tiling_005
[2026-02-09 16:45:17] [INFO] GE(268526,math_op_host_ut):2026-02-09-16:45:17.595.730 [op_context_builder_impl.cc:103]268526 CreateComputeNodeInfoImpl:Node Acos, compute_node_info attr_size 48, outputs_ins_info_size:48, offset:416, total_size:520.
[2026-02-09 16:45:17] [ OK ] AcosTiling.acos_tiling_005 (0 ms)
[2026-02-09 16:45:17] AcosTiling TearDown
[2026-02-09 16:45:17] [----------] 5 tests from AcosTiling (3 ms total)
[2026-02-09 16:45:17]
[2026-02-09 16:45:17] [----------] Global test environment tear-down
[2026-02-09 16:45:17] Global Environment TearDown
[2026-02-09 16:45:17] [==========] 5 tests from 1 test suite ran. (15 ms total)
[2026-02-09 16:45:17] [ PASSED ] 5 tests.
(ws) [root@shlqh-cann-cluster8-141-61-33-172 op-math]#
<!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。-->
## 类型标签
<!-- [x] 表示选中 -->
- [x] Bug修复
- [ ] 新特性
- [ ] 性能优化
- [ ] 文档更新
- [ ] 其他,请描述:
See merge request: cann/ops-math!1095 | 3 个月前 |