已合并
增加assign_add,assign_sub,atan,cast,ceil st用例 #3420
ligen75创建于 6月18日
增加assign_add,assign_sub,atan,cast,ceil st用例 #3420
已合并
ligen75创建于 6月18日
已删除 :master合入到cann/ops-mathmaster
10 个文件变更+262-0
@@ -0,0 +1,33 @@
1+#!/usr/bin/env python3
2+# -*- coding: UTF-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+
13+import numpy as np
14+
15+__golden__ = {
16+ "kernel": {
17+ "assign_add": "assign_add_golden"
18+ }
19+}
20+
21+def assign_add_golden(ref,
22+ value,
23+ use_locking: bool = False,
24+ **kwargs):
25+ '''
26+ Kernel golden for assign_add.
27+ All the parameters follow @assign_add_def.cpp without outputs.
28+ All the input Tensors are numpy.ndarray.
29+ kwargs may contain: short_soc_version, input_ori_shapes, output_ori_shapes,
30+ input_formats, output_formats, input_ori_formats, output_ori_formats,
31+ input_dtypes, output_dtypes.
32+ '''
33+ return np.add(ref, value)
@@ -0,0 +1,5 @@
1+testcase_name,network_name,op_name,input_dtypes,input_ori_shapes,output_ori_shapes,input_ori_formats,output_ori_formats,attributes,input_shapes,output_dtypes,output_shapes,input_formats,output_formats,input_data_ranges,precision_tolerances,absolute_precision,output_inplace_indexes,output_shape_unknown_indexes,is_enabled,remark,soc_series,priority,dump_file_prefix,manual_input_binaries,manual_golden_binaries
2+assign_add_fuzz_27,UNKNOWN,assign_add,"('int32', 'int32')","((48, 39, 42, 27), (48, 39, 42, 27))","((48, 39, 42, 27),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((48, 39, 42, 27), (48, 39, 42, 27))","('int32',)","((48, 39, 42, 27),)","('ND', 'ND')","('ND',)","((-2147483648, 2147483647),)",,1e-08,"(0,)",(),True,,,0,,,
3+assign_add_fuzz_51,UNKNOWN,assign_add,"('float32', 'bfloat16')","((2, 6, 18), (2, 6, 18))","((2, 6, 18),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((2, 6, 18), (2, 6, 18))","('float32',)","((2, 6, 18),)","('ND', 'ND')","('ND',)","((-3.4028235e+38, 3.4028235e+38),)",,1e-08,"(0,)",(),True,,,0,,,
4+assign_add_fuzz_103,UNKNOWN,assign_add,"('int32', 'int32')","((28, 13, 25, 13, 1, 2, 37), (28, 13, 25, 13, 1, 2, 37))","((28, 13, 25, 13, 1, 2, 37),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((28, 13, 25, 13, 1, 2, 37), (28, 13, 25, 13, 1, 2, 37))","('int32',)","((28, 13, 25, 13, 1, 2, 37),)","('ND', 'ND')","('ND',)","((-1, 1),)",,1e-08,"(0,)",(),True,,,0,,,
5+assign_add_fuzz_250,UNKNOWN,assign_add,"('float16', 'float16')","((30, 24), (30, 24))","((30, 24),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((30, 24), (30, 24))","('float16',)","((30, 24),)","('ND', 'ND')","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,"(0,)",(),True,,,0,,,
@@ -0,0 +1,33 @@
1+#!/usr/bin/env python3
2+# -*- coding: UTF-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+
13+import numpy as np
14+
15+__golden__ = {
16+ "kernel": {
17+ "assign_sub": "assign_sub_golden"
18+ }
19+}
20+
21+def assign_sub_golden(var,
22+ value,
23+ use_locking: bool = False,
24+ **kwargs):
25+ '''
26+ Kernel golden for assign_sub.
27+ All the parameters follow @assign_sub_def.cpp without outputs.
28+ All the input Tensors are numpy.ndarray.
29+ kwargs may contain: short_soc_version, input_ori_shapes, output_ori_shapes,
30+ input_formats, output_formats, input_ori_formats, output_ori_formats,
31+ input_dtypes, output_dtypes.
32+ '''
33+ return np.subtract(var, value)
@@ -0,0 +1,5 @@
1+testcase_name,network_name,op_name,input_dtypes,input_ori_shapes,output_ori_shapes,input_ori_formats,output_ori_formats,attributes,input_shapes,output_dtypes,output_shapes,input_formats,output_formats,input_data_ranges,precision_tolerances,absolute_precision,output_inplace_indexes,output_shape_unknown_indexes,is_enabled,remark,soc_series,priority,dump_file_prefix,manual_input_binaries,manual_golden_binaries
2+assign_sub_fuzz_177,UNKNOWN,assign_sub,"('float32', 'float32')","((28, 10, 1, 26, 39, 45), (28, 10, 1, 26, 39, 45))","((28, 10, 1, 26, 39, 45),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((28, 10, 1, 26, 39, 45), (28, 10, 1, 26, 39, 45))","('float32',)","((28, 10, 1, 26, 39, 45),)","('ND', 'ND')","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,"(0,)",(),True,,,0,,,
3+assign_sub_fuzz_117,UNKNOWN,assign_sub,"('int32', 'int32')","((44, 16, 33, 9), (44, 16, 33, 9))","((44, 16, 33, 9),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((44, 16, 33, 9), (44, 16, 33, 9))","('int32',)","((44, 16, 33, 9),)","('ND', 'ND')","('ND',)","((-1, 1),)",,1e-08,"(0,)",(),True,,,0,,,
4+assign_sub_fuzz_243,UNKNOWN,assign_sub,"('float16', 'float16')","((11, 24, 2), (11, 24, 2))","((11, 24, 2),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((11, 24, 2), (11, 24, 2))","('float16',)","((11, 24, 2),)","('ND', 'ND')","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,"(0,)",(),True,,,0,,,
5+assign_sub_fuzz_19,UNKNOWN,assign_sub,"('float32', 'float32')","((11, 14), (11, 14))","((11, 14),)","('ND', 'ND')","('ND',)",{'use_locking': False},"((11, 14), (11, 14))","('float32',)","((11, 14),)","('ND', 'ND')","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,"(0,)",(),True,,,0,,,
@@ -0,0 +1,36 @@
1+#!/usr/bin/env python3
2+# -*- coding: UTF-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+
13+import numpy as np
14+
15+__golden__ = {
16+ "kernel": {
17+ "atan": "atan_golden"
18+ }
19+}
20+
21+def atan_golden(x,
22+ **kwargs):
23+ '''
24+ Kernel golden for atan.
25+ All the parameters follow @atan_def.cpp without outputs.
26+ All the input Tensors are numpy.ndarray.
27+ kwargs may contain: short_soc_version, input_ori_shapes, output_ori_shapes,
28+ input_formats, output_formats, input_ori_formats, output_ori_formats,
29+ input_dtypes, output_dtypes.
30+ '''
31+ x_dtype = x.dtype
32+ if x_dtype.name == "bfloat16" or x_dtype.name == "float16":
33+ result = np.arctan(x.astype(np.float32)).astype(x_dtype, copy=False)
34+ else:
35+ result = np.arctan(x)
36+ return result
@@ -0,0 +1,5 @@
1+testcase_name,network_name,op_name,input_dtypes,input_ori_shapes,output_ori_shapes,input_ori_formats,output_ori_formats,attributes,input_shapes,output_dtypes,output_shapes,input_formats,output_formats,input_data_ranges,precision_tolerances,absolute_precision,output_inplace_indexes,output_shape_unknown_indexes,is_enabled,remark,soc_series,priority,dump_file_prefix,manual_input_binaries,manual_golden_binaries
2+atan_fuzz_49,UNKNOWN,atan,"('float32',)","((36, 16),)","((36, 16),)","('ND',)","('ND',)",{},"((36, 16),)","('float32',)","((36, 16),)","('ND',)","('ND',)","((-3.4028235e+38, 3.4028235e+38),)",,1e-08,(),(),True,,,0,,,
3+atan_fuzz_115,UNKNOWN,atan,"('float32',)","((37, 31, 43, 24),)","((37, 31, 43, 24),)","('ND',)","('ND',)",{},"((37, 31, 43, 24),)","('float32',)","((37, 31, 43, 24),)","('ND',)","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,(),(),True,,,0,,,
4+atan_fuzz_179,UNKNOWN,atan,"('float32',)","((40, 20),)","((40, 20),)","('ND',)","('ND',)",{},"((40, 20),)","('float32',)","((40, 20),)","('ND',)","('ND',)","((-3.4028235e+38, 3.4028235e+38),)",,1e-08,(),(),True,,,0,,,
5+atan_fuzz_75,UNKNOWN,atan,"('float16',)","((16, 44),)","((16, 44),)","('ND',)","('ND',)",{},"((16, 44),)","('float16',)","((16, 44),)","('ND',)","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,(),(),True,,,0,,,
@@ -0,0 +1,104 @@
1+#!/usr/bin/env python3
2+# -*- coding: UTF-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+
13+import numpy as np
14+
15+__golden__ = {
16+ "kernel": {
17+ "cast": "cast_golden"
18+ }
19+}
20+
21+_DATA_TYPE_INT_TO_STR = {
22+ 0: 'float32',
23+ 1: 'float16',
24+ 2: 'int8',
25+ 3: 'int32',
26+ 4: 'uint8',
27+ 6: 'int16',
28+ 7: 'uint16',
29+ 8: 'uint32',
30+ 9: 'int64',
31+ 10: 'uint64',
32+ 11: 'double',
33+ 12: 'bool',
34+ 16: 'complex64',
35+ 17: 'complex128',
36+ 27: 'bfloat16',
37+ 29: 'int4',
38+ 30: 'uint1',
39+ 33: 'complex32',
40+ 34: 'hifloat8',
41+ 35: 'float8_e5m2',
42+ 36: 'float8_e4m3fn',
43+ 40: 'float4_e2m1',
44+ 41: 'float4_e1m2',
45+}
46+
47+_SPECIAL_DTYPES = ("bfloat16", "int4",
48+ "float8_e5m2", "float8_e4m3fn",
49+ "float4_e2m1", "float4_e1m2",
50+ "hifloat8")
51+
52+def _resolve_custom_numpy_dtype(dtype_str):
53+ if dtype_str == "bfloat16":
54+ from ml_dtypes import bfloat16
55+ return bfloat16
56+ elif dtype_str == "int4":
57+ from ml_dtypes import int4
58+ return int4
59+ elif dtype_str == "float8_e5m2":
60+ from ml_dtypes import float8_e5m2
61+ return float8_e5m2
62+ elif dtype_str == "float8_e4m3fn":
63+ from ml_dtypes import float8_e4m3fn
64+ return float8_e4m3fn
65+ elif dtype_str == "hifloat8":
66+ from en_dtypes import hifloat8
67+ return hifloat8
68+ elif dtype_str == "float4_e2m1":
69+ from ml_dtypes import float4_e2m1
70+ return float4_e2m1
71+ elif dtype_str == "float4_e1m2":
72+ from ml_dtypes import float4_e1m2
73+ return float4_e1m2
74+ return None
75+
76+def cast_golden(x,
77+ dst_type: int,
78+ **kwargs):
79+ '''
80+ Kernel golden for cast.
81+ All the parameters follow @cast_def.cpp without outputs.
82+ All the input Tensors are numpy.ndarray.
83+ kwargs may contain: short_soc_version, input_ori_shapes, output_ori_shapes,
84+ input_formats, output_formats, input_ori_formats, output_ori_formats,
85+ input_dtypes, output_dtypes.
86+ '''
87+ dst_type_str = _DATA_TYPE_INT_TO_STR.get(dst_type, str(dst_type))
88+ if (x.dtype.name == "bfloat16" and dst_type_str == "hifloat8") or \
89+ (x.dtype.name == "hifloat8" and dst_type_str == "bfloat16"):
90+ np_dtype = _resolve_custom_numpy_dtype(dst_type_str)
91+ return x.astype(np.float32).astype(np_dtype)
92+ elif dst_type_str in _SPECIAL_DTYPES:
93+ np_dtype = _resolve_custom_numpy_dtype(dst_type_str)
94+ return x.astype(np_dtype)
95+ elif dst_type_str == "complex32":
96+ _shape = list(x.shape)
97+ x = x.reshape(_shape + [1])
98+ imag = np.zeros(_shape + [1], dtype=np.float16)
99+ res = np.concatenate((x, imag), axis=-1)
100+ return res
101+ elif dst_type_str == "bool":
102+ return x.astype(np.bool_)
103+ else:
104+ return x.astype(getattr(np, dst_type_str))
@@ -0,0 +1,5 @@
1+testcase_name,network_name,op_name,input_dtypes,input_ori_shapes,output_ori_shapes,input_ori_formats,output_ori_formats,attributes,input_shapes,output_dtypes,output_shapes,input_formats,output_formats,input_data_ranges,precision_tolerances,absolute_precision,output_inplace_indexes,output_shape_unknown_indexes,is_enabled,remark,soc_series,priority,dump_file_prefix,manual_input_binaries,manual_golden_binaries
2+cast_fuzz_092,UNKNOWN,cast,"('int8',)","((20, 9, 1),)","((20, 9, 1),)","('ND',)","('NCHW',)",{'dst_type': 12},"((20, 9, 1),)","('bool',)","((20, 9, 1),)","('NCHW',)","('NCHW',)","((-128, 127),)",,1e-08,(),(),True,,,0,,,
3+cast_fuzz_038,UNKNOWN,cast,"('bool',)","((29, 10),)","((29, 10),)","('ND',)","('ND',)",{'dst_type': 3},"((29, 10),)","('int32',)","((29, 10),)","('ND',)","('ND',)","((True, False),)",,1e-08,(),(),True,,,0,,,
4+cast_fuzz_101,UNKNOWN,cast,"('hifloat8',)","((14,),)","((14,),)","('ND',)","('ND',)",{'dst_type': 1},"((14,),)","('float16',)","((14,),)","('ND',)","('ND',)","((-1, 1),)",,1e-08,(),(),True,,,0,,,
5+cast_fuzz_030,UNKNOWN,cast,"('int32',)","((34, 5),)","((34, 5),)","('ND',)","('ND',)",{'dst_type': 1},"((34, 5),)","('float16',)","((34, 5),)","('ND',)","('ND',)","((-2147483648, 2147483647),)",,1e-08,(),(),True,,,0,,,
@@ -0,0 +1,31 @@
1+#!/usr/bin/env python3
2+# -*- coding: UTF-8 -*-
3+# ----------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------
12+
13+import numpy as np
14+
15+__golden__ = {
16+ "kernel": {
17+ "ceil": "ceil_golden"
18+ }
19+}
20+
21+def ceil_golden(x,
22+ **kwargs):
23+ '''
24+ Kernel golden for ceil.
25+ All the parameters follow @ceil_def.cpp without outputs.
26+ All the input Tensors are numpy.ndarray.
27+ kwargs may contain: short_soc_version, input_ori_shapes, output_ori_shapes,
28+ input_formats, output_formats, input_ori_formats, output_ori_formats,
29+ input_dtypes, output_dtypes.
30+ '''
31+ return np.ceil(x)
@@ -0,0 +1,5 @@
1+testcase_name,network_name,op_name,input_dtypes,input_ori_shapes,output_ori_shapes,input_ori_formats,output_ori_formats,attributes,input_shapes,output_dtypes,output_shapes,input_formats,output_formats,input_data_ranges,precision_tolerances,absolute_precision,output_inplace_indexes,output_shape_unknown_indexes,is_enabled,remark,soc_series,priority,dump_file_prefix,manual_input_binaries,manual_golden_binaries
2+ceil_fuzz_32,UNKNOWN,ceil,"('bfloat16',)","((33, 6, 40, 45),)","((33, 6, 40, 45),)","('ND',)","('ND',)",{},"((33, 6, 40, 45),)","('bfloat16',)","((33, 6, 40, 45),)","('ND',)","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,(),(),True,,,0,,,
3+ceil_fuzz_64,UNKNOWN,ceil,"('bfloat16',)","((29, 38),)","((29, 38),)","('ND',)","('ND',)",{},"((29, 38),)","('bfloat16',)","((29, 38),)","('ND',)","('ND',)","((nan, nan),)",,1e-08,(),(),True,,,0,,,
4+ceil_fuzz_6,UNKNOWN,ceil,"('float16',)","((21, 16, 1, 37, 15),)","((21, 16, 1, 37, 15),)","('NCHW',)","('NCHW',)",{},"((21, 16, 1, 37, 15),)","('float16',)","((21, 16, 1, 37, 15),)","('NCHW',)","('NCHW',)","((65500.0, 65500.0),)",,1e-08,(),(),True,,,0,,,
5+ceil_fuzz_22,UNKNOWN,ceil,"('float32',)","((45,),)","((45,),)","('ND',)","('ND',)",{},"((45,),)","('float32',)","((45,),)","('ND',)","('ND',)","((-1, 1, nan, -0.0, inf),)",,1e-08,(),(),True,,,0,,,