Merged
feat: 构建与CI流程适配 npuArch 算子注册(AddConfigByArch) #6990
esok11Add on 9 days ago
feat: 构建与CI流程适配 npuArch 算子注册(AddConfigByArch) #6990
Merged
esok11Add on 9 days ago
Total: 7 files changed+237-101
@@ -843,17 +843,20 @@ macro(add_all_modules_sources)
843 target_sources(${OPHOST_NAME}_infer_obj PRIVATE ${OPINFER_SRCS})843 target_sources(${OPHOST_NAME}_infer_obj PRIVATE ${OPINFER_SRCS})
844 endif()844 endif()
845 845 
846- # 添加tiling文件:NPU_ARCH 与 TILING_DIR 按位置一一配对;兼容旧 COMPUTE_UNIT 参数,846+ # 添加tiling文件:NPU_ARCH 与 TILING_DIR 按位置一一配对;兼容旧 COMPUTE_UNIT 参数。
847- # 逐项转换为 npuArch(字符串拼接保留空元素位置,避免 list(APPEND) 丢弃空元素导致错位),847+ # 允许 npuArch 与 socVersion 混合书写:优先按当前构建芯片的 npuArch 匹配,
848- # 当前构建芯片同样转换为 npuArch 后统一按 arch 匹配848+ # 未命中(声明列表里全是 socVersion)时回退到按 socVersion 字面值匹配。
849 # 同一芯片型号允许出现多次,此时会收集所有配对的 tiling 目录(一个芯片型号可配置多个目录)849 # 同一芯片型号允许出现多次,此时会收集所有配对的 tiling 目录(一个芯片型号可配置多个目录)
850 if(MODULE_NPU_ARCH)850 if(MODULE_NPU_ARCH)
851- get_npu_arch_by_soc_version("${ASCEND_COMPUTE_UNIT}" _cur_key)
852 set(_cur_keys "${MODULE_NPU_ARCH}")851 set(_cur_keys "${MODULE_NPU_ARCH}")
853 else()852 else()
854- set(_cur_key "${ASCEND_COMPUTE_UNIT}")
855 set(_cur_keys "${MODULE_COMPUTE_UNIT}")853 set(_cur_keys "${MODULE_COMPUTE_UNIT}")
856 endif()854 endif()
855+ get_npu_arch_by_soc_version("${ASCEND_COMPUTE_UNIT}" _cur_key)
856+ list(FIND _cur_keys "${_cur_key}" _cur_key_index)
857+ if(_cur_key_index EQUAL -1)
858+ set(_cur_key "${ASCEND_COMPUTE_UNIT}")
859+ endif()
857 860 
858 find_values_by_key("${_cur_keys}" "${MODULE_TILING_DIR}" "${_cur_key}" TILING_SOC_DIR)861 find_values_by_key("${_cur_keys}" "${MODULE_TILING_DIR}" "${_cur_key}" TILING_SOC_DIR)
859 add_tiling_sources("${TILING_SOC_DIR}" "${MODULE_DISABLE_IN_OPP}")862 add_tiling_sources("${TILING_SOC_DIR}" "${MODULE_DISABLE_IN_OPP}")
@@ -295,13 +295,21 @@ endfunction()
295# get op_type from *_def.cpp295# get op_type from *_def.cpp
296# ######################################################################################################################296# ######################################################################################################################
297function(check_op_supported OP_NAME OP_DIR COMPUTE_UNIT OP_SUPPORTED_COMPUTE_UNIT)297function(check_op_supported OP_NAME OP_DIR COMPUTE_UNIT OP_SUPPORTED_COMPUTE_UNIT)
298- set(cmd "find ${OP_DIR} -name ${OP_NAME}_def.cpp -exec grep '\.AddConfig(\\s*\"${COMPUTE_UNIT}\"' {} \;")298+ set(_arch_pattern "")
299+ if(COMMAND get_npu_arch_by_soc_version)
300+ get_npu_arch_by_soc_version("${COMPUTE_UNIT}" _check_npu_arch)
301+ if(_check_npu_arch)
302+ string(TOUPPER "${_check_npu_arch}" _check_npu_arch_upper)
303+ set(_arch_pattern "\\|AddConfigByArch.*${_check_npu_arch_upper}")
304+ endif()
305+ endif()
306+ set(cmd "find ${OP_DIR} -name ${OP_NAME}_def.cpp -exec grep '\\.AddConfig(\\s*\"${COMPUTE_UNIT}\"${_arch_pattern}' {} \;")
299 execute_process(307 execute_process(
300 COMMAND bash -c "${cmd}"308 COMMAND bash -c "${cmd}"
301 OUTPUT_VARIABLE op_supported_compute_unit309 OUTPUT_VARIABLE op_supported_compute_unit
302 )310 )
303 if(NOT ${MODULE_EXT} STREQUAL "")311 if(NOT ${MODULE_EXT} STREQUAL "")
304- set(cmd_ext "find ${MODULE_EXT} -name ${OP_NAME}_*_def.cpp -exec grep 'OpAICoreConfig.*\"${COMPUTE_UNIT}\"' {} \;")312+ set(cmd_ext "find ${MODULE_EXT} -name ${OP_NAME}_*_def.cpp -exec grep 'OpAICoreConfig.*\"${COMPUTE_UNIT}\"${_arch_pattern}' {} \;")
305 execute_process(313 execute_process(
306 COMMAND bash -c "${cmd_ext}"314 COMMAND bash -c "${cmd_ext}"
307 OUTPUT_VARIABLE op_supported_compute_unit315 OUTPUT_VARIABLE op_supported_compute_unit
@@ -21,10 +21,11 @@ function(gen_opbuild_target)
21 21 
22 add_library(gen_op_host_${OPBUILD_PREFIX} SHARED ${OPBUILD_IN_SRCS})22 add_library(gen_op_host_${OPBUILD_PREFIX} SHARED ${OPBUILD_IN_SRCS})
23 target_link_libraries(gen_op_host_${OPBUILD_PREFIX} PRIVATE $<BUILD_INTERFACE:intf_pub_cxx17> exe_graph register23 target_link_libraries(gen_op_host_${OPBUILD_PREFIX} PRIVATE $<BUILD_INTERFACE:intf_pub_cxx17> exe_graph register
24- c_sec)24+ c_sec $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>>)
25 target_compile_options(gen_op_host_${OPBUILD_PREFIX} PRIVATE -fno-common)25 target_compile_options(gen_op_host_${OPBUILD_PREFIX} PRIVATE -fno-common)
26 # op def 源文件可能需要引用仓库内公共头文件(如 common/inc/op_host/*.h)26 # op def 源文件可能需要引用仓库内公共头文件(如 common/inc/op_host/*.h)
27- target_include_directories(gen_op_host_${OPBUILD_PREFIX} PRIVATE ${OPS_MATH_DIR} ${OPS_MATH_COMMON_INC})27+ target_include_directories(gen_op_host_${OPBUILD_PREFIX} PRIVATE ${OPS_MATH_DIR} ${OPS_MATH_COMMON_INC}
28+ ${OPBASE_INC_DIRS})
28 string(REPLACE ";" "\;" OPS_PRODUCT_NAME "${ASCEND_COMPUTE_UNIT}")29 string(REPLACE ";" "\;" OPS_PRODUCT_NAME "${ASCEND_COMPUTE_UNIT}")
29 30 
30 31 
@@ -7,7 +7,7 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10-set(OPBASE_TAG_ID f09beaf70dd62c9c089c237cbfcdc2bd2cb757d6)10+set(OPBASE_TAG_ID 8e8cf1b60b28bc1f8aaa1652fe054ac7e35d5852)
11 11 
12if(EXISTS "${PROJECT_SOURCE_DIR}/../../ops-base")12if(EXISTS "${PROJECT_SOURCE_DIR}/../../ops-base")
13 get_filename_component(OPBASE_SOURCE_PATH13 get_filename_component(OPBASE_SOURCE_PATH
@@ -55,6 +55,33 @@ import sys
55# ============================================================55# ============================================================
56# 配置常量56# 配置常量
57# ============================================================57# ============================================================
58+# socVersion -> npuArch(均小写),与 cmake/soc_arch_variables.cmake 保持一致
59+SOC_TO_ARCH = {
60+ "ascend031": "dav_3004",
61+ "ascend035": "dav_3505",
62+ "ascend310b": "dav_3002",
63+ "ascend310p": "dav_2002",
64+ "ascend910_93": "dav_2201",
65+ "ascend950": "dav_3510",
66+ "ascend350": "dav_3510",
67+ "ascend910b": "dav_2201",
68+ "ascend910": "dav_1001",
69+ "kirinx90": "dav_3003",
70+ "kirin9030": "dav_3113",
71+ "mc62": "dav_5102",
72+ "ascend5162a": "dav_5162",
73+ "ascend960dt": "dav_9201",
74+ "ascend960pr": "dav_9202",
75+ "ascend630": "dav_5102",
76+ "ascend610lite": "dav_3102",
77+}
78+ 
79+ 
80+def soc_to_arch(soc):
81+ """按 socVersion 查询 npuArch(小写),未匹配返回空串"""
82+ return SOC_TO_ARCH.get(soc.lower(), "")
83+ 
84+ 
58DEFAULT_SOC = "ascend910b"85DEFAULT_SOC = "ascend910b"
59DEFAULT_EXP_OP = "acos"86DEFAULT_EXP_OP = "acos"
60DEFAULT_NORMAL_OP = "is_finite"87DEFAULT_NORMAL_OP = "is_finite"
@@ -81,8 +108,10 @@ DEFAULT_FILTER_SOC = "ascend910b"
81def check_op_supports_soc(op_name, soc, is_experimental=False):108def check_op_supports_soc(op_name, soc, is_experimental=False):
82 """检查算子是否支持指定的SOC109 """检查算子是否支持指定的SOC
83 110 
84- 检查方法:查找算子的 op_host/*def.cpp 文件,111+ 检查方法:查找算子的 op_host/*def.cpp 文件,以下任一形式即视为支持:
85- 检查是否包含 AddConfig("{soc}") 字符串112+ - AddConfig("{soc}"):按 socVersion 直接注册
113+ - AddConfigByArch(..., Ops::Base::DAV_xxx ...):按 npuArch 注册,
114+ 通过本文件 SOC_TO_ARCH 的 socVersion -> npuArch 映射换算
86 115 
87 Args:116 Args:
88 op_name: 算子名称117 op_name: 算子名称
@@ -100,6 +129,13 @@ def check_op_supports_soc(op_name, soc, is_experimental=False):
100 "experimental/random/",129 "experimental/random/",
101 ]130 ]
102 131 
132+ arch = soc_to_arch(soc)
133+ arch_pattern = None
134+ if arch:
135+ arch_pattern = re.compile(
136+ r"AddConfigByArch\s*\([^;]*\b%s\b" % re.escape(arch.upper()), re.IGNORECASE
137+ )
138+ 
103 for prefix in prefixes:139 for prefix in prefixes:
104 op_host_dir = os.path.join(prefix, op_name, "op_host")140 op_host_dir = os.path.join(prefix, op_name, "op_host")
105 if not os.path.isdir(op_host_dir):141 if not os.path.isdir(op_host_dir):
@@ -113,6 +149,8 @@ def check_op_supports_soc(op_name, soc, is_experimental=False):
113 content = f.read()149 content = f.read()
114 if f'AddConfig("{soc}"' in content:150 if f'AddConfig("{soc}"' in content:
115 return True151 return True
152+ if arch_pattern and arch_pattern.search(content):
153+ return True
116 except (IOError, OSError):154 except (IOError, OSError):
117 # 文件读取失败,继续检查下一个文件155 # 文件读取失败,继续检查下一个文件
118 continue156 continue
@@ -9,9 +9,35 @@
9# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.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.10# See LICENSE in the root of the software repository for the full text of the License.
11# ----------------------------------------------------------------------------11# ----------------------------------------------------------------------------
12+import logging
12import os13import os
13import re14import re
14-import logging15+ 
16+# socVersion -> npuArch(均小写),与 gen_ci_cmd.py、local_check.sh 中的配置保持一致
17+SOC_TO_ARCH = {
18+ "ascend031": "dav_3004",
19+ "ascend035": "dav_3505",
20+ "ascend310b": "dav_3002",
21+ "ascend310p": "dav_2002",
22+ "ascend910_93": "dav_2201",
23+ "ascend950": "dav_3510",
24+ "ascend350": "dav_3510",
25+ "ascend910b": "dav_2201",
26+ "ascend910": "dav_1001",
27+ "kirinx90": "dav_3003",
28+ "kirin9030": "dav_3113",
29+ "mc62": "dav_5102",
30+ "ascend5162a": "dav_5162",
31+ "ascend960dt": "dav_9201",
32+ "ascend960pr": "dav_9202",
33+ "ascend630": "dav_5102",
34+ "ascend610lite": "dav_3102",
35+}
36+ 
37+# npuArch(大写)-> socVersion 列表,由 SOC_TO_ARCH 反向推导,保持 socVersion 顺序
38+ARCH_TO_SOC_NAMES = {}
39+for _soc, _arch in SOC_TO_ARCH.items():
40+ ARCH_TO_SOC_NAMES.setdefault(_arch.upper(), []).append(_soc)
15 41 
16 42 
17def should_skip_directory(dir_name):43def should_skip_directory(dir_name):
@@ -19,8 +45,15 @@ def should_skip_directory(dir_name):
19 判断是否应该跳过该目录45 判断是否应该跳过该目录
20 """46 """
21 skip_dirs = {47 skip_dirs = {
22- 'build', 'cmake', 'common', 'docs', 'examples',48+ "build",
23- 'experimental', 'scripts', 'tests', 'third_party'49+ "cmake",
50+ "common",
51+ "docs",
52+ "examples",
53+ "experimental",
54+ "scripts",
55+ "tests",
56+ "third_party",
24 }57 }
25 return dir_name in skip_dirs58 return dir_name in skip_dirs
26 59 
@@ -29,31 +62,19 @@ def parse_foreach_config(config_str):
29 """62 """
30 解析 FOREACH_OPDEF 中的配置字符串63 解析 FOREACH_OPDEF 中的配置字符串
31 """64 """
32- config_mapping = {
33- 'A2': 'ascend910b',
34- '910_93': 'ascend910_93',
35- 'A5': 'ascend950',
36- '910B': 'ascend910b',
37- '910B_93': 'ascend910_93',
38- '910B_95': 'ascend950',
39- '950': 'ascend950',
40- '910': 'ascend910',
41- '910_55': 'ascend910_55',
42- }
43- 
44 found_configs = []65 found_configs = []
45 config_str_upper = config_str.upper()66 config_str_upper = config_str.upper()
46 67 
47 priority_checks = [68 priority_checks = [
48- ('A2', 'ascend910b'),69+ ("A2", "ascend910b"),
49- ('910_93', 'ascend910_93'),70+ ("910_93", "ascend910_93"),
50- ('A5', 'ascend950'),71+ ("A5", "ascend950"),
51- ('910_55', 'ascend910_55'),72+ ("910_55", "ascend910_55"),
52- ('910B', 'ascend910b'),73+ ("910B", "ascend910b"),
53- ('910B_93', 'ascend910_93'),74+ ("910B_93", "ascend910_93"),
54- ('910B_95', 'ascend950'),75+ ("910B_95", "ascend950"),
55- ('950', 'ascend950'),76+ ("950", "ascend950"),
56- ('910', 'ascend910'),77+ ("910", "ascend910"),
57 ]78 ]
58 79 
59 for key, value in priority_checks:80 for key, value in priority_checks:
@@ -70,7 +91,7 @@ def extract_static_map_configs(content):
70 configs = []91 configs = []
71 92 
72 map_patterns = [93 map_patterns = [
73- r'static\s+const\s+std::map<std::string[^>]*>\s+\w+\s*=\s*\{([^}]+)\}',94+ r"static\s+const\s+std::map<std::string[^>]*>\s+\w+\s*=\s*\{([^}]+)\}",
74 r'\{"([a-zA-Z0-9_]+)"[^}]*\}',95 r'\{"([a-zA-Z0-9_]+)"[^}]*\}',
75 ]96 ]
76 97 
@@ -113,13 +134,13 @@ def extract_foreach_opdef_configs(content):
113 """134 """
114 configs = []135 configs = []
115 136 
116- pattern1 = r'FOREACH_OPDEF\(([^,]+),'137+ pattern1 = r"FOREACH_OPDEF\(([^,]+),"
117 matches1 = re.findall(pattern1, content)138 matches1 = re.findall(pattern1, content)
118 for match in matches1:139 for match in matches1:
119 config_str = match.strip()140 config_str = match.strip()
120 configs.extend(parse_foreach_config(config_str))141 configs.extend(parse_foreach_config(config_str))
121 142 
122- pattern2 = r'FOREACH_OPDEF_END_([^(]+)\('143+ pattern2 = r"FOREACH_OPDEF_END_([^(]+)\("
123 matches2 = re.findall(pattern2, content)144 matches2 = re.findall(pattern2, content)
124 for match in matches2:145 for match in matches2:
125 config_str = match.strip()146 config_str = match.strip()
@@ -149,13 +170,27 @@ def extract_traditional_aicore_configs(content):
149 return configs170 return configs
150 171 
151 172 
173+def extract_add_config_by_arch_configs(content):
174+ """
175+ 提取 ArchConfigHelper::AddConfigByArch 中 NpuArch 对应的 SoC 名称
176+ """
177+ configs = []
178+ for match in re.finditer(r"AddConfigByArch", content):
179+ call_content = content[match.end() :].split(";", 1)[0]
180+ for arch in re.findall(r"\b(DAV_[0-9A-Za-z_]+)\b", call_content):
181+ for soc in ARCH_TO_SOC_NAMES.get(arch, []):
182+ if soc not in configs:
183+ configs.append(soc)
184+ return configs
185+ 
186+ 
152def extract_ai_core_configs(file_path):187def extract_ai_core_configs(file_path):
153 """188 """
154 从 _def.cpp 文件中提取 AICore 配置名称189 从 _def.cpp 文件中提取 AICore 配置名称
155 """190 """
156 configs = []191 configs = []
157 try:192 try:
158- with open(file_path, 'r', encoding='utf-8') as f:193+ with open(file_path, "r", encoding="utf-8") as f:
159 content = f.read()194 content = f.read()
160 195 
161 # 方法1:匹配传统的 AICore 配置196 # 方法1:匹配传统的 AICore 配置
@@ -163,6 +198,10 @@ def extract_ai_core_configs(file_path):
163 if traditional_configs:198 if traditional_configs:
164 configs.extend(traditional_configs)199 configs.extend(traditional_configs)
165 200 
201+ arch_configs = extract_add_config_by_arch_configs(content)
202+ if arch_configs:
203+ configs.extend(arch_configs)
204+ 
166 # 方法2:匹配 FOREACH_OPDEF 相关格式205 # 方法2:匹配 FOREACH_OPDEF 相关格式
167 foreach_configs = extract_foreach_opdef_configs(content)206 foreach_configs = extract_foreach_opdef_configs(content)
168 if foreach_configs:207 if foreach_configs:
@@ -194,15 +233,13 @@ def split_list_by_num_groups(lst, num_groups):
194 last = 0.0233 last = 0.0
195 for _ in range(num_groups):234 for _ in range(num_groups):
196 val = int(round(last + avg))235 val = int(round(last + avg))
197- out.append(lst[int(last):val])236+ out.append(lst[int(last) : val])
198 last = val237 last = val
199 return out238 return out
200 239 
240+ 
201# 耗时较长的单独分组241# 耗时较长的单独分组
202-GROUPING_CONFIGS = {242+GROUPING_CONFIGS = {"default": {}, "ascend950": {}}
203- "default": {},
204- "ascend950": {}
205-}
206 243 
207 244 
208def grouped(repository_path, soc, group_size):245def grouped(repository_path, soc, group_size):
@@ -219,9 +256,9 @@ def grouped(repository_path, soc, group_size):
219 dirs[:] = [d for d in dirs if not should_skip_directory(d)]256 dirs[:] = [d for d in dirs if not should_skip_directory(d)]
220 257 
221 for file in files:258 for file in files:
222- if file.endswith('_def.cpp'):259+ if file.endswith("_def.cpp"):
223 full_path = os.path.join(root, file)260 full_path = os.path.join(root, file)
224- op_name = file.replace('_def.cpp', '')261+ op_name = file.replace("_def.cpp", "")
225 262 
226 # 提取 AICore 配置263 # 提取 AICore 配置
227 ai_core_configs = extract_ai_core_configs(full_path)264 ai_core_configs = extract_ai_core_configs(full_path)
@@ -238,7 +275,7 @@ def grouped(repository_path, soc, group_size):
238 break275 break
239 if not matched:276 if not matched:
240 remain.append(op_name)277 remain.append(op_name)
241- 278+ 
242 filtered_result = []279 filtered_result = []
243 len_size = len(result)280 len_size = len(result)
244 for i in range(len_size):281 for i in range(len_size):
@@ -248,10 +285,13 @@ def grouped(repository_path, soc, group_size):
248 filtered_result.append(result[i])285 filtered_result.append(result[i])
249 286 
250 remain = sorted(remain)287 remain = sorted(remain)
251- remain = split_list_by_num_groups(remain, group_size - len_size + zero_tensor_num if group_size > 8 else group_size)288+ remain = split_list_by_num_groups(
289+ remain,
290+ group_size - len_size + zero_tensor_num if group_size > 8 else group_size,
291+ )
252 result.extend(remain)292 result.extend(remain)
253 return result293 return result
254 294 
255 295 
256def main(repository_path, soc, group_size):296def main(repository_path, soc, group_size):
257- return grouped(repository_path, soc, group_size)297+ return grouped(repository_path, soc, group_size)
@@ -11,6 +11,38 @@
11 11 
12set -euo pipefail12set -euo pipefail
13 13 
14+# ============================================================
15+# SoC 配置
16+# ============================================================
17+# socVersion -> npuArch(均小写),本文件内置一份配置,
18+# 与 gen_ci_cmd.py、gen_ops_soc.py 中的 SOC_TO_ARCH 数据保持一致
19+declare -A SOC_TO_ARCH=(
20+ ["ascend031"]="dav_3004"
21+ ["ascend035"]="dav_3505"
22+ ["ascend310b"]="dav_3002"
23+ ["ascend310p"]="dav_2002"
24+ ["ascend910_93"]="dav_2201"
25+ ["ascend950"]="dav_3510"
26+ ["ascend350"]="dav_3510"
27+ ["ascend910b"]="dav_2201"
28+ ["ascend910"]="dav_1001"
29+ ["kirinx90"]="dav_3003"
30+ ["kirin9030"]="dav_3113"
31+ ["mc62"]="dav_5102"
32+ ["ascend5162a"]="dav_5162"
33+ ["ascend960dt"]="dav_9201"
34+ ["ascend960pr"]="dav_9202"
35+ ["ascend630"]="dav_5102"
36+ ["ascend610lite"]="dav_3102"
37+)
38+ 
39+# 查询 socVersion 对应的 npuArch(小写),未匹配返回空串,
40+# 调用方回退为只按 socVersion 字面值匹配。
41+soc_to_npu_arch() {
42+ local soc="${1,,}"
43+ echo "${SOC_TO_ARCH[${soc}]:-}"
44+}
45+ 
14SCRIPT_DIR=$(cd "$(dirname "$0")/../.." && pwd)46SCRIPT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
15PROJECT_ROOT="${SCRIPT_DIR}"47PROJECT_ROOT="${SCRIPT_DIR}"
16PR_FILELIST="${PROJECT_ROOT}/.local_check_filelist.txt"48PR_FILELIST="${PROJECT_ROOT}/.local_check_filelist.txt"
@@ -106,12 +138,26 @@ op_supports_soc() {
106 if [[ "$is_experimental" == "true" ]]; then138 if [[ "$is_experimental" == "true" ]]; then
107 prefixes=("experimental/math" "experimental/conversion" "experimental/random")139 prefixes=("experimental/math" "experimental/conversion" "experimental/random")
108 fi140 fi
141+ local arch
142+ arch=$(soc_to_npu_arch "${soc}")
143+ local arch_upper=""
144+ if [[ -n "${arch}" ]]; then
145+ arch_upper="${arch^^}"
146+ fi
109 for prefix in "${prefixes[@]}"; do147 for prefix in "${prefixes[@]}"; do
110 local def_dir="${PROJECT_ROOT}/${prefix}/${op}/op_host"148 local def_dir="${PROJECT_ROOT}/${prefix}/${op}/op_host"
111 [[ -d "${def_dir}" ]] || continue149 [[ -d "${def_dir}" ]] || continue
112 for def_file in "${def_dir}"/*_def.cpp; do150 for def_file in "${def_dir}"/*_def.cpp; do
113 [[ -f "${def_file}" ]] || continue151 [[ -f "${def_file}" ]] || continue
114 grep -q "AddConfig(\"${soc}\"" "${def_file}" && return 0152 grep -q "AddConfig(\"${soc}\"" "${def_file}" && return 0
153+ if [[ -n "${arch_upper}" ]]; then
154+ local content=""
155+ local arch_pattern="AddConfigByArch[^;]*${arch_upper}"
156+ content=$(<"${def_file}")
157+ if [[ "${content}" =~ ${arch_pattern} ]]; then
158+ return 0
159+ fi
160+ fi
115 done161 done
116 done162 done
117 return 1163 return 1
@@ -181,7 +227,7 @@ LLT/Cannsim Mode Options (single task, default runs all):
181 227 
182Build Parameters:228Build Parameters:
183 --soc=<soc_version> Target SoC229 --soc=<soc_version> Target SoC
184- Supported: ascend910b ascend910_93 ascend950 ascend310p 230+ Supported: ascend910b ascend910_93 ascend950 ascend310p
185 ascend910 ascend310b231 ascend910 ascend310b
186 -j <num> Parallel jobs (default: 16)232 -j <num> Parallel jobs (default: 16)
187 --cann_3rd_lib_path=<path> CANN third party lib path233 --cann_3rd_lib_path=<path> CANN third party lib path
@@ -326,7 +372,7 @@ parse_args() {
326 ;;372 ;;
327 esac373 esac
328 done374 done
329- 375+ 
330 }376 }
331 377 
332detect_changed_ops() {378detect_changed_ops() {
@@ -342,20 +388,20 @@ detect_changed_ops() {
342 print_ok "Loaded $(wc -l < "${PR_FILELIST}") files"388 print_ok "Loaded $(wc -l < "${PR_FILELIST}") files"
343 else389 else
344 local base_ref="master"390 local base_ref="master"
345- 391+ 
346 {392 {
347 git -C "${PROJECT_ROOT}" diff --name-only "${base_ref}...HEAD" 2>/dev/null || true393 git -C "${PROJECT_ROOT}" diff --name-only "${base_ref}...HEAD" 2>/dev/null || true
348 git -C "${PROJECT_ROOT}" diff --name-only "HEAD~1...HEAD" 2>/dev/null || true394 git -C "${PROJECT_ROOT}" diff --name-only "HEAD~1...HEAD" 2>/dev/null || true
349 git -C "${PROJECT_ROOT}" diff --cached --name-only 2>/dev/null || true395 git -C "${PROJECT_ROOT}" diff --cached --name-only 2>/dev/null || true
350 git -C "${PROJECT_ROOT}" diff --name-only HEAD 2>/dev/null || true396 git -C "${PROJECT_ROOT}" diff --name-only HEAD 2>/dev/null || true
351 } | grep -v '^$' | sort -u > "${PR_FILELIST}"397 } | grep -v '^$' | sort -u > "${PR_FILELIST}"
352- 398+ 
353 if [[ ! -s "${PR_FILELIST}" ]]; then399 if [[ ! -s "${PR_FILELIST}" ]]; then
354 print_warn "No changed files detected (committed, staged, or working)"400 print_warn "No changed files detected (committed, staged, or working)"
355 print_info "Use -f/--file-list to manually specify which files to verify"401 print_info "Use -f/--file-list to manually specify which files to verify"
356 return 1402 return 1
357 fi403 fi
358- 404+ 
359 print_ok "Detected $(wc -l < "${PR_FILELIST}") changed files (committed + staged + working)"405 print_ok "Detected $(wc -l < "${PR_FILELIST}") changed files (committed + staged + working)"
360 fi406 fi
361 407 
@@ -508,7 +554,7 @@ do_compile_flow() {
508 [[ "${SINGLE_MODE}" == "true" ]] && any_mode=true554 [[ "${SINGLE_MODE}" == "true" ]] && any_mode=true
509 [[ "${A5_MODE}" == "true" ]] && any_mode=true555 [[ "${A5_MODE}" == "true" ]] && any_mode=true
510 [[ "${NORMAL_MODE}" == "true" ]] && any_mode=true556 [[ "${NORMAL_MODE}" == "true" ]] && any_mode=true
511- 557+ 
512 if [[ "${any_mode}" == "false" ]]; then558 if [[ "${any_mode}" == "false" ]]; then
513 NORMAL_MODE=true559 NORMAL_MODE=true
514 EXPERIMENTAL_MODE=true560 EXPERIMENTAL_MODE=true
@@ -532,7 +578,7 @@ do_compile_flow() {
532 local cmd_array=(bash build.sh --pkg --soc="${SOC}" -j"${JOBS}")578 local cmd_array=(bash build.sh --pkg --soc="${SOC}" -j"${JOBS}")
533 [[ -n "${CANN_3RD_LIB_PATH}" ]] && cmd_array+=(--cann_3rd_lib_path="${CANN_3RD_LIB_PATH}")579 [[ -n "${CANN_3RD_LIB_PATH}" ]] && cmd_array+=(--cann_3rd_lib_path="${CANN_3RD_LIB_PATH}")
534 print_info "Command: ${cmd_array[*]}"580 print_info "Command: ${cmd_array[*]}"
535- 581+ 
536 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_normal.txt"; then582 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_normal.txt"; then
537 print_ok "Normal compilation passed"583 print_ok "Normal compilation passed"
538 record_sub_task "Normal compilation" "PASS" "artifacts/normal/" "logs/build_normal.txt" ""584 record_sub_task "Normal compilation" "PASS" "artifacts/normal/" "logs/build_normal.txt" ""
@@ -564,7 +610,7 @@ do_compile_flow() {
564 local cmd_array=(bash build.sh --pkg --jit --soc="${SOC}" -j"${JOBS}")610 local cmd_array=(bash build.sh --pkg --jit --soc="${SOC}" -j"${JOBS}")
565 [[ -n "${CANN_3RD_LIB_PATH}" ]] && cmd_array+=(--cann_3rd_lib_path="${CANN_3RD_LIB_PATH}")611 [[ -n "${CANN_3RD_LIB_PATH}" ]] && cmd_array+=(--cann_3rd_lib_path="${CANN_3RD_LIB_PATH}")
566 print_info "Command: ${cmd_array[*]}"612 print_info "Command: ${cmd_array[*]}"
567- 613+ 
568 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_jit.txt"; then614 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_jit.txt"; then
569 print_ok "JIT compilation passed"615 print_ok "JIT compilation passed"
570 local jit_src_pattern="cann-${chip_short}-ops-math_*_linux-*.run"616 local jit_src_pattern="cann-${chip_short}-ops-math_*_linux-*.run"
@@ -615,7 +661,7 @@ do_compile_flow() {
615 print_step "2.4" "Single package build"661 print_step "2.4" "Single package build"
616 local cmd_array=(bash scripts/ci/check_pkg.sh "${PR_FILELIST}" --soc="${SOC}")662 local cmd_array=(bash scripts/ci/check_pkg.sh "${PR_FILELIST}" --soc="${SOC}")
617 print_info "Command: ${cmd_array[*]}"663 print_info "Command: ${cmd_array[*]}"
618- 664+ 
619 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_single.txt"; then665 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_single.txt"; then
620 print_ok "Single package build passed"666 print_ok "Single package build passed"
621 record_sub_task "Single package build" "PASS" "artifacts/single/" "logs/build_single.txt" ""667 record_sub_task "Single package build" "PASS" "artifacts/single/" "logs/build_single.txt" ""
@@ -632,7 +678,7 @@ do_compile_flow() {
632 if [[ "${A5_MODE}" == "true" ]]; then678 if [[ "${A5_MODE}" == "true" ]]; then
633 print_step "2.5" "A5 compilation"679 print_step "2.5" "A5 compilation"
634 local cmd_array=(bash scripts/ci/compile_a5_pkg.sh "${PR_FILELIST}")680 local cmd_array=(bash scripts/ci/compile_a5_pkg.sh "${PR_FILELIST}")
635- 681+ 
636 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_a5.txt"; then682 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/build_a5.txt"; then
637 print_ok "A5 compilation passed"683 print_ok "A5 compilation passed"
638 record_sub_task "A5 compilation" "PASS" "artifacts/a5/" "logs/build_a5.txt" ""684 record_sub_task "A5 compilation" "PASS" "artifacts/a5/" "logs/build_a5.txt" ""
@@ -662,9 +708,9 @@ do_compile_flow() {
662# ============================================================708# ============================================================
663do_presmoke_a900() {709do_presmoke_a900() {
664 local task_ret=0710 local task_ret=0
665- 711+ 
666 print_step "3.1" "PreSmoke_A900 Upper: single.tar.gz + check_example.sh"712 print_step "3.1" "PreSmoke_A900 Upper: single.tar.gz + check_example.sh"
667- 713+ 
668 local single_tgz="${PROJECT_ROOT}/artifacts/single/single.tar.gz"714 local single_tgz="${PROJECT_ROOT}/artifacts/single/single.tar.gz"
669 if [[ ! -f "${single_tgz}" ]]; then715 if [[ ! -f "${single_tgz}" ]]; then
670 print_warn "single.tar.gz not found in artifacts/single/"716 print_warn "single.tar.gz not found in artifacts/single/"
@@ -677,7 +723,7 @@ do_presmoke_a900() {
677 record_sub_task "PreSmoke_A900 Upper" "FAIL" "artifacts/single/single.tar.gz" "logs/presmoke_a900_upper.txt" "tar -zxf ${single_tgz}"723 record_sub_task "PreSmoke_A900 Upper" "FAIL" "artifacts/single/single.tar.gz" "logs/presmoke_a900_upper.txt" "tar -zxf ${single_tgz}"
678 if [[ ${task_ret} -ne 1 ]]; then task_ret=1; fi724 if [[ ${task_ret} -ne 1 ]]; then task_ret=1; fi
679 fi725 fi
680- 726+ 
681 local installed_vendors=()727 local installed_vendors=()
682 for single_run in "${PROJECT_ROOT}"/single/cann-ops-math-*_linux-*.run; do728 for single_run in "${PROJECT_ROOT}"/single/cann-ops-math-*_linux-*.run; do
683 if [[ -f "${single_run}" ]]; then729 if [[ -f "${single_run}" ]]; then
@@ -685,7 +731,7 @@ do_presmoke_a900() {
685 installed_vendors+=("${op_name}_math")731 installed_vendors+=("${op_name}_math")
686 fi732 fi
687 done733 done
688- 734+ 
689 local filtered_ops=$(filter_ops_by_soc "${OPS}" "${SOC}" "false")735 local filtered_ops=$(filter_ops_by_soc "${OPS}" "${SOC}" "false")
690 if [[ -n "${OPS}" && -z "${filtered_ops}" ]]; then736 if [[ -n "${OPS}" && -z "${filtered_ops}" ]]; then
691 print_warn "Specified operators do not support ${SOC}, skipping PreSmoke_A900 Upper"737 print_warn "Specified operators do not support ${SOC}, skipping PreSmoke_A900 Upper"
@@ -700,10 +746,10 @@ do_presmoke_a900() {
700 make_filtered_pr_file "${PR_FILELIST}" "${filtered_ops}" "${filtered_pr}"746 make_filtered_pr_file "${PR_FILELIST}" "${filtered_ops}" "${filtered_pr}"
701 local cmd_array=(bash scripts/ci/check_example.sh "${filtered_pr}" --soc="${SOC}")747 local cmd_array=(bash scripts/ci/check_example.sh "${filtered_pr}" --soc="${SOC}")
702 print_info "Command: ${cmd_array[*]}"748 print_info "Command: ${cmd_array[*]}"
703- 749+ 
704 "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_a900_upper.txt"750 "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_a900_upper.txt"
705 local ret=$?751 local ret=$?
706- 752+ 
707 if [[ ${ret} -eq 0 ]]; then753 if [[ ${ret} -eq 0 ]]; then
708 print_ok "PreSmoke_A900 Upper passed"754 print_ok "PreSmoke_A900 Upper passed"
709 record_sub_task "PreSmoke_A900 Upper" "PASS" "artifacts/single/single.tar.gz" "logs/presmoke_a900_upper.txt" ""755 record_sub_task "PreSmoke_A900 Upper" "PASS" "artifacts/single/single.tar.gz" "logs/presmoke_a900_upper.txt" ""
@@ -724,9 +770,9 @@ do_presmoke_a900() {
724 fi770 fi
725 done771 done
726 fi772 fi
727- 773+ 
728 print_step "3.2" "PreSmoke_A900 Lower: experimental package + --run_example"774 print_step "3.2" "PreSmoke_A900 Lower: experimental package + --run_example"
729- 775+ 
730 local exp_pkgs=("${PROJECT_ROOT}"/artifacts/experimental/cann-ops-math-experimental_linux-*.run)776 local exp_pkgs=("${PROJECT_ROOT}"/artifacts/experimental/cann-ops-math-experimental_linux-*.run)
731 if [[ ${#exp_pkgs[@]} -eq 0 ]] || [[ ! -f "${exp_pkgs[0]}" ]]; then777 if [[ ${#exp_pkgs[@]} -eq 0 ]] || [[ ! -f "${exp_pkgs[0]}" ]]; then
732 print_warn "experimental package not found in artifacts/experimental/"778 print_warn "experimental package not found in artifacts/experimental/"
@@ -735,12 +781,12 @@ do_presmoke_a900() {
735 else781 else
736 local exp_pkg="${exp_pkgs[0]}"782 local exp_pkg="${exp_pkgs[0]}"
737 print_info "Found experimental package: $(basename ${exp_pkg})"783 print_info "Found experimental package: $(basename ${exp_pkg})"
738- 784+ 
739 print_info "Installing experimental package with --quiet..."785 print_info "Installing experimental package with --quiet..."
740 chmod +x "${exp_pkg}"786 chmod +x "${exp_pkg}"
741 "${exp_pkg}" --quiet --force 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_a900_lower_install.txt"787 "${exp_pkg}" --quiet --force 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_a900_lower_install.txt"
742 local install_ret=$?788 local install_ret=$?
743- 789+ 
744 if [[ ${install_ret} -ne 0 ]]; then790 if [[ ${install_ret} -ne 0 ]]; then
745 print_fail "Failed to install experimental package"791 print_fail "Failed to install experimental package"
746 record_sub_task "PreSmoke_A900 Lower" "FAIL" "artifacts/experimental/" "logs/presmoke_a900_lower_install.txt" "${exp_pkg} --quiet"792 record_sub_task "PreSmoke_A900 Lower" "FAIL" "artifacts/experimental/" "logs/presmoke_a900_lower_install.txt" "${exp_pkg} --quiet"
@@ -788,7 +834,7 @@ do_presmoke_a900() {
788 fi834 fi
789 fi835 fi
790 fi836 fi
791- 837+ 
792 return ${task_ret}838 return ${task_ret}
793}839}
794 840 
@@ -803,7 +849,7 @@ do_presmoke_st() {
803 chmod +x "${monitor_pkg}"849 chmod +x "${monitor_pkg}"
804 "${monitor_pkg}" --full --install-path="${ASCEND_HOME_PATH}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_st_install.txt"850 "${monitor_pkg}" --full --install-path="${ASCEND_HOME_PATH}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_st_install.txt"
805 local install_ret=$?851 local install_ret=$?
806- 852+ 
807 if [[ ${install_ret} -eq 0 ]]; then853 if [[ ${install_ret} -eq 0 ]]; then
808 print_ok "Package installed"854 print_ok "Package installed"
809 else855 else
@@ -813,7 +859,7 @@ do_presmoke_st() {
813 else859 else
814 print_warn "Package not found in artifacts/normal/: cann-${chip_short}-ops-math_*_linux-*.run"860 print_warn "Package not found in artifacts/normal/: cann-${chip_short}-ops-math_*_linux-*.run"
815 fi861 fi
816- 862+ 
817 if [[ -z "${OPS}" ]]; then863 if [[ -z "${OPS}" ]]; then
818 print_warn "No operators detected"864 print_warn "No operators detected"
819 if [[ -n "${monitor_pkg:-}" ]] && [[ -f "${monitor_pkg}" ]]; then865 if [[ -n "${monitor_pkg:-}" ]] && [[ -f "${monitor_pkg}" ]]; then
@@ -822,18 +868,18 @@ do_presmoke_st() {
822 fi868 fi
823 return 2869 return 2
824 fi870 fi
825- 871+ 
826 local cmd_array=(bash scripts/ci/ops_st_test.sh --soc_version="${SOC}" --ops="${OPS}" --pr_filelist="${PR_FILELIST}")872 local cmd_array=(bash scripts/ci/ops_st_test.sh --soc_version="${SOC}" --ops="${OPS}" --pr_filelist="${PR_FILELIST}")
827 print_info "Command: ${cmd_array[*]}"873 print_info "Command: ${cmd_array[*]}"
828- 874+ 
829 "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_st.txt"875 "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_st.txt"
830 local ret=$?876 local ret=$?
831- 877+ 
832 if [[ -n "${monitor_pkg:-}" ]] && [[ -f "${monitor_pkg}" ]]; then878 if [[ -n "${monitor_pkg:-}" ]] && [[ -f "${monitor_pkg}" ]]; then
833 print_info "Uninstalling normal package to restore environment..."879 print_info "Uninstalling normal package to restore environment..."
834 "${monitor_pkg}" --uninstall --install-path="${ASCEND_HOME_PATH}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_st_uninstall.txt" || print_warn "Normal package uninstall failed"880 "${monitor_pkg}" --uninstall --install-path="${ASCEND_HOME_PATH}" 2>&1 | tee "${PROJECT_ROOT}/logs/presmoke_st_uninstall.txt" || print_warn "Normal package uninstall failed"
835 fi881 fi
836- 882+ 
837 if [[ ${ret} -eq 0 ]]; then883 if [[ ${ret} -eq 0 ]]; then
838 print_ok "PreSmoke_St passed"884 print_ok "PreSmoke_St passed"
839 record_sub_task "PreSmoke_St" "PASS" "" "logs/presmoke_st.txt" ""885 record_sub_task "PreSmoke_St" "PASS" "" "logs/presmoke_st.txt" ""
@@ -847,19 +893,19 @@ do_presmoke_st() {
847 893 
848do_llt_flow() {894do_llt_flow() {
849 print_header "Step 3: LLT Flow"895 print_header "Step 3: LLT Flow"
850- 896+ 
851 if [[ "${SKIP_LLT}" == "true" ]]; then897 if [[ "${SKIP_LLT}" == "true" ]]; then
852 print_warn "LLT flow skipped (--skip-llt)"898 print_warn "LLT flow skipped (--skip-llt)"
853 return 2899 return 2
854 fi900 fi
855- 901+ 
856 local any_llt_mode=false902 local any_llt_mode=false
857 [[ "${LLT_A900_MODE}" == "true" ]] && any_llt_mode=true903 [[ "${LLT_A900_MODE}" == "true" ]] && any_llt_mode=true
858 [[ "${LLT_ST_MODE}" == "true" ]] && any_llt_mode=true904 [[ "${LLT_ST_MODE}" == "true" ]] && any_llt_mode=true
859 [[ "${LLT_EXP_UT_MODE}" == "true" ]] && any_llt_mode=true905 [[ "${LLT_EXP_UT_MODE}" == "true" ]] && any_llt_mode=true
860 [[ "${LLT_KERNEL_UT_MODE}" == "true" ]] && any_llt_mode=true906 [[ "${LLT_KERNEL_UT_MODE}" == "true" ]] && any_llt_mode=true
861 [[ "${LLT_STD_UT_MODE}" == "true" ]] && any_llt_mode=true907 [[ "${LLT_STD_UT_MODE}" == "true" ]] && any_llt_mode=true
862- 908+ 
863 if [[ "${any_llt_mode}" == "false" ]]; then909 if [[ "${any_llt_mode}" == "false" ]]; then
864 LLT_A900_MODE=true910 LLT_A900_MODE=true
865 LLT_ST_MODE=true911 LLT_ST_MODE=true
@@ -868,9 +914,9 @@ do_llt_flow() {
868 LLT_STD_UT_MODE=true914 LLT_STD_UT_MODE=true
869 print_info "Auto mode: all LLT tasks enabled (default)"915 print_info "Auto mode: all LLT tasks enabled (default)"
870 fi916 fi
871- 917+ 
872 local llt_ret=0918 local llt_ret=0
873- 919+ 
874 # --- PreSmoke_A900 ---920 # --- PreSmoke_A900 ---
875 if [[ "${LLT_A900_MODE}" == "true" ]]; then921 if [[ "${LLT_A900_MODE}" == "true" ]]; then
876 do_presmoke_a900922 do_presmoke_a900
@@ -880,7 +926,7 @@ do_llt_flow() {
880 print_warn "PreSmoke_A900 skipped (use --llt-a900 to enable)"926 print_warn "PreSmoke_A900 skipped (use --llt-a900 to enable)"
881 record_sub_task "PreSmoke_A900" "SKIP" "" "" ""927 record_sub_task "PreSmoke_A900" "SKIP" "" "" ""
882 fi928 fi
883- 929+ 
884 # --- PreSmoke_St ---930 # --- PreSmoke_St ---
885 if [[ "${LLT_ST_MODE}" == "true" ]]; then931 if [[ "${LLT_ST_MODE}" == "true" ]]; then
886 do_presmoke_st932 do_presmoke_st
@@ -890,7 +936,7 @@ do_llt_flow() {
890 print_warn "PreSmoke_St skipped (use --llt-st to enable)"936 print_warn "PreSmoke_St skipped (use --llt-st to enable)"
891 record_sub_task "PreSmoke_St" "SKIP" "" "" ""937 record_sub_task "PreSmoke_St" "SKIP" "" "" ""
892 fi938 fi
893- 939+ 
894 # --- Experimental UT ---940 # --- Experimental UT ---
895 if [[ "${LLT_EXP_UT_MODE}" == "true" ]]; then941 if [[ "${LLT_EXP_UT_MODE}" == "true" ]]; then
896 print_step "3.4" "Experimental UT"942 print_step "3.4" "Experimental UT"
@@ -921,16 +967,16 @@ do_llt_flow() {
921 print_warn "Experimental UT skipped (use --llt-exp-ut to enable)"967 print_warn "Experimental UT skipped (use --llt-exp-ut to enable)"
922 record_sub_task "Experimental UT" "SKIP" "" "" ""968 record_sub_task "Experimental UT" "SKIP" "" "" ""
923 fi969 fi
924- 970+ 
925 # --- Kernel UT ---971 # --- Kernel UT ---
926 if [[ "${LLT_KERNEL_UT_MODE}" == "true" ]]; then972 if [[ "${LLT_KERNEL_UT_MODE}" == "true" ]]; then
927 print_step "3.5" "Kernel UT"973 print_step "3.5" "Kernel UT"
928 local cmd_array=(bash scripts/ci/check_kernel_ut.sh "${PR_FILELIST}")974 local cmd_array=(bash scripts/ci/check_kernel_ut.sh "${PR_FILELIST}")
929 print_info "Command: ${cmd_array[*]}"975 print_info "Command: ${cmd_array[*]}"
930- 976+ 
931 "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/ut_kernel.txt"977 "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/ut_kernel.txt"
932 local ret=$?978 local ret=$?
933- 979+ 
934 if [[ ${ret} -eq 0 ]]; then980 if [[ ${ret} -eq 0 ]]; then
935 print_ok "Kernel UT passed"981 print_ok "Kernel UT passed"
936 record_sub_task "Kernel UT" "PASS" "" "logs/ut_kernel.txt" ""982 record_sub_task "Kernel UT" "PASS" "" "logs/ut_kernel.txt" ""
@@ -943,7 +989,7 @@ do_llt_flow() {
943 print_warn "Kernel UT skipped (use --llt-kernel-ut to enable)"989 print_warn "Kernel UT skipped (use --llt-kernel-ut to enable)"
944 record_sub_task "Kernel UT" "SKIP" "" "" ""990 record_sub_task "Kernel UT" "SKIP" "" "" ""
945 fi991 fi
946- 992+ 
947 # --- Standard UT ---993 # --- Standard UT ---
948 if [[ "${LLT_STD_UT_MODE}" == "true" ]]; then994 if [[ "${LLT_STD_UT_MODE}" == "true" ]]; then
949 print_step "3.6" "Standard UT"995 print_step "3.6" "Standard UT"
@@ -974,13 +1020,13 @@ do_llt_flow() {
974 print_warn "Standard UT skipped (use --llt-std-ut to enable)"1020 print_warn "Standard UT skipped (use --llt-std-ut to enable)"
975 record_sub_task "Standard UT" "SKIP" "" "" ""1021 record_sub_task "Standard UT" "SKIP" "" "" ""
976 fi1022 fi
977- 1023+ 
978 if [[ ${llt_ret} -eq 0 ]]; then1024 if [[ ${llt_ret} -eq 0 ]]; then
979 print_ok "LLT Flow completed (all tasks passed)"1025 print_ok "LLT Flow completed (all tasks passed)"
980 else1026 else
981 print_fail "LLT Flow completed with failures"1027 print_fail "LLT Flow completed with failures"
982 fi1028 fi
983- 1029+ 
984 return ${llt_ret}1030 return ${llt_ret}
985}1031}
986 1032 
@@ -1004,7 +1050,7 @@ do_cannsim_check() {
1004 1050 
1005 local ops_arr=(${OPS//,/ })1051 local ops_arr=(${OPS//,/ })
1006 local cannsim_ops=()1052 local cannsim_ops=()
1007- print_info "cannsim requires ascend950 support; operators without AddConfig(\"ascend950\") will be skipped"1053+ print_info "cannsim requires ascend950 support; operators without AddConfig(\"ascend950\") or AddConfigByArch(DAV_3510) will be skipped"
1008 for op in "${ops_arr[@]}"; do1054 for op in "${ops_arr[@]}"; do
1009 if op_supports_soc "$op" "ascend950" "false" || \1055 if op_supports_soc "$op" "ascend950" "false" || \
1010 op_supports_soc "$op" "ascend950" "true"; then1056 op_supports_soc "$op" "ascend950" "true"; then
@@ -1021,7 +1067,7 @@ do_cannsim_check() {
1021 print_step "4" "Running cannsim: ${op}"1067 print_step "4" "Running cannsim: ${op}"
1022 local cmd_array=(bash scripts/ci/run_cannsim_example.sh "${op}" -j "${JOBS}")1068 local cmd_array=(bash scripts/ci/run_cannsim_example.sh "${op}" -j "${JOBS}")
1023 print_info "Command: ${cmd_array[*]}"1069 print_info "Command: ${cmd_array[*]}"
1024- 1070+ 
1025 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/cannsim_${op}.txt"; then1071 if "${cmd_array[@]}" 2>&1 | tee "${PROJECT_ROOT}/logs/cannsim_${op}.txt"; then
1026 print_ok "Cannsim passed: ${op}"1072 print_ok "Cannsim passed: ${op}"
1027 else1073 else
@@ -1143,13 +1189,13 @@ print_summary() {
1143# ============================================================1189# ============================================================
1144main() {1190main() {
1145 parse_args "$@"1191 parse_args "$@"
1146- 1192+ 
1147 # 设置 CI 脚本依赖的环境变量1193 # 设置 CI 脚本依赖的环境变量
1148 export REPOSITORY_NAME="ops-math"1194 export REPOSITORY_NAME="ops-math"
1149 export WORKSPACE="${PROJECT_ROOT}"1195 export WORKSPACE="${PROJECT_ROOT}"
1150 export CANN_3RD_LIB_PATH="${CANN_3RD_LIB_PATH}"1196 export CANN_3RD_LIB_PATH="${CANN_3RD_LIB_PATH}"
1151 export ASCEND_3RD_LIB_PATH="${ASCEND_3RD_LIB_PATH}"1197 export ASCEND_3RD_LIB_PATH="${ASCEND_3RD_LIB_PATH}"
1152- 1198+ 
1153 # 全局单任务互斥检测1199 # 全局单任务互斥检测
1154 local compile_task=false1200 local compile_task=false
1155 local llt_task=false1201 local llt_task=false
@@ -1185,12 +1231,12 @@ main() {
1185 SKIP_LLT=true1231 SKIP_LLT=true
1186 print_info "Single-task mode: cannsim only, compile and LLT auto-skipped"1232 print_info "Single-task mode: cannsim only, compile and LLT auto-skipped"
1187 fi1233 fi
1188- 1234+ 
1189 cd "${PROJECT_ROOT}"1235 cd "${PROJECT_ROOT}"
1190 mkdir -p "${PROJECT_ROOT}/logs"1236 mkdir -p "${PROJECT_ROOT}/logs"
1191- 1237+ 
1192 local TOTAL_START=$(date +%s)1238 local TOTAL_START=$(date +%s)
1193- 1239+ 
1194 print_header "ops-math Local Check"1240 print_header "ops-math Local Check"
1195 echo -e " Project: ${PROJECT_ROOT}"1241 echo -e " Project: ${PROJECT_ROOT}"
1196 echo -e " SoC: ${SOC:-auto-detect}"1242 echo -e " SoC: ${SOC:-auto-detect}"
@@ -1200,17 +1246,17 @@ main() {
1200 echo -e " Mode: JIT=${JIT_MODE} Exp=${EXPERIMENTAL_MODE} Single=${SINGLE_MODE} A5=${A5_MODE} Normal=${NORMAL_MODE}"1246 echo -e " Mode: JIT=${JIT_MODE} Exp=${EXPERIMENTAL_MODE} Single=${SINGLE_MODE} A5=${A5_MODE} Normal=${NORMAL_MODE}"
1201 echo -e " LLT: A900=${LLT_A900_MODE} St=${LLT_ST_MODE} ExpUT=${LLT_EXP_UT_MODE} KernelUT=${LLT_KERNEL_UT_MODE} StdUT=${LLT_STD_UT_MODE} Cannsim=${CANNSIM_MODE}"1247 echo -e " LLT: A900=${LLT_A900_MODE} St=${LLT_ST_MODE} ExpUT=${LLT_EXP_UT_MODE} KernelUT=${LLT_KERNEL_UT_MODE} StdUT=${LLT_STD_UT_MODE} Cannsim=${CANNSIM_MODE}"
1202 echo -e " Logs: ${PROJECT_ROOT}/logs/"1248 echo -e " Logs: ${PROJECT_ROOT}/logs/"
1203- 1249+ 
1204 check_environment || exit 11250 check_environment || exit 1
1205 detect_changed_ops || { print_fail "Failed to detect changed files"; exit 1; }1251 detect_changed_ops || { print_fail "Failed to detect changed files"; exit 1; }
1206- 1252+ 
1207 # 主流程1253 # 主流程
1208 run_check "Compile Flow" do_compile_flow1254 run_check "Compile Flow" do_compile_flow
1209 run_check "LLT Flow" do_llt_flow1255 run_check "LLT Flow" do_llt_flow
1210- 1256+ 
1211 # 仿真测试1257 # 仿真测试
1212 run_check "Cannsim Tests" do_cannsim_check1258 run_check "Cannsim Tests" do_cannsim_check
1213- 1259+ 
1214 print_summary "${TOTAL_START}"1260 print_summary "${TOTAL_START}"
1215}1261}
1216 1262