已合并
fix: support cce_aicore attribute in kernel regex #1484
jianwei10创建于 4月8日
fix: support cce_aicore attribute in kernel regex #1484
已合并
共 2 个文件变更+7-3
| @@ -14,7 +14,11 @@ import re | |||
| 14 | from host_stub_util import CodeMode | 14 | from host_stub_util import CodeMode |
| 15 | 15 | ||
| 16 | FUNC_SIGNATURE = re.compile( | 16 | FUNC_SIGNATURE = re.compile( |
| 17 | - r'(?:template\s*<\s*([^>]+?)\s*>\s*\n?\s*)?__attribute__\(\(cce_kernel\)\)\s*\[aicore\]\s*(.+?)\s*\{', re.DOTALL | 17 | + r'(?:template\s*<\s*([^>]+?)\s*>\s*\n?\s*)?' |
| 18 | + r'__attribute__\(\(cce_kernel\)\)\s*' | ||
| 19 | + r'(?:\[aicore\]|__attribute__\(\(cce_aicore\)\))\s*' | ||
| 20 | + r'(.+?)\s*\{', | ||
| 21 | + re.DOTALL, | ||
| 18 | ) | 22 | ) |
| 19 | FUNC_PARAMS = re.compile(r'\((.+)\)', re.DOTALL) | 23 | FUNC_PARAMS = re.compile(r'\((.+)\)', re.DOTALL) |
| 20 | 24 | ||
| @@ -63,4 +67,4 @@ STR_TO_KERNEL_TYPE_L300 = { | |||
| 63 | 67 | ||
| 64 | STR_TO_KERNEL_TYPE_L311 = { | 68 | STR_TO_KERNEL_TYPE_L311 = { |
| 65 | "KERNEL_TYPE_AICORE" : CodeMode.AIC, | 69 | "KERNEL_TYPE_AICORE" : CodeMode.AIC, |
| 66 | -} | 70 | +} |
| @@ -39,7 +39,7 @@ def generate_template_config_code(filepaths: List[str]) -> str: | |||
| 39 | disable_kernel_check_option = "--cce-disable-kernel-global-attr-check" | 39 | disable_kernel_check_option = "--cce-disable-kernel-global-attr-check" |
| 40 | src_file_pattern = r'#\s*\d+\s*"([^"]+)"' | 40 | src_file_pattern = r'#\s*\d+\s*"([^"]+)"' |
| 41 | template_kernel_func_pattern = (r'template<([^<>]*(?:<[^<>]*>)*[^<>]*)>\s*__attribute__\(\(cce_kernel\)\)' | 41 | template_kernel_func_pattern = (r'template<([^<>]*(?:<[^<>]*>)*[^<>]*)>\s*__attribute__\(\(cce_kernel\)\)' |
| 42 | - r'\s*\[aicore\]\s*(.+?)\s*\{') | 42 | + r'\s*(?:\[aicore\]|__attribute__\(\(cce_aicore\)\))\s*(.+?)\s*\{') |
| 43 | for path in filepaths: | 43 | for path in filepaths: |
| 44 | try: | 44 | try: |
| 45 | with open(path, encoding='utf-8') as file: | 45 | with open(path, encoding='utf-8') as file: |