已合并
add asc_op_compile_base #199
吴洋创建于 1月30日
add asc_op_compile_base #199
已合并
共 35 个文件变更+2427-207
| @@ -0,0 +1,213 @@ | |||
| 1 | +# 语言: None, Cpp, Java, JavaScript, ObjC, Proto, TableGen, TextProto | ||
| 2 | +Language: Cpp | ||
| 3 | +# BasedOnStyle: LLVM | ||
| 4 | + | ||
| 5 | +# 访问说明符(public、private等)的偏移 | ||
| 6 | +AccessModifierOffset: -4 | ||
| 7 | + | ||
| 8 | +# 开括号(开圆括号、开尖括号、开方括号)后的对齐: Align, DontAlign, AlwaysBreak(总是在开括号后换行) | ||
| 9 | +AlignAfterOpenBracket: Align | ||
| 10 | + | ||
| 11 | +# 连续赋值时,对齐所有等号 | ||
| 12 | +AlignConsecutiveAssignments: false | ||
| 13 | + | ||
| 14 | +# 连续声明时,对齐所有声明的变量名 | ||
| 15 | +AlignConsecutiveDeclarations: false | ||
| 16 | + | ||
| 17 | +# 右对齐逃脱换行(使用反斜杠换行)的反斜杠 | ||
| 18 | +AlignEscapedNewlines: Right | ||
| 19 | + | ||
| 20 | +# 水平对齐二元和三元表达式的操作数 | ||
| 21 | +AlignOperands: true | ||
| 22 | + | ||
| 23 | +# 对齐连续的尾随的注释 | ||
| 24 | +AlignTrailingComments: true | ||
| 25 | + | ||
| 26 | +# 不允许函数声明的所有参数在放在下一行 | ||
| 27 | +AllowAllParametersOfDeclarationOnNextLine: false | ||
| 28 | + | ||
| 29 | +# 不允许短的块放在同一行 | ||
| 30 | +AllowShortBlocksOnASingleLine: true | ||
| 31 | + | ||
| 32 | +# 允许短的case标签放在同一行 | ||
| 33 | +AllowShortCaseLabelsOnASingleLine: false | ||
| 34 | + | ||
| 35 | +# 允许短的函数放在同一行: None, InlineOnly(定义在类中), Empty(空函数), Inline(定义在类中,空函数), All | ||
| 36 | +AllowShortFunctionsOnASingleLine: Empty | ||
| 37 | + | ||
| 38 | +# 允许短的if语句保持在同一行 | ||
| 39 | +AllowShortIfStatementsOnASingleLine: false | ||
| 40 | + | ||
| 41 | +# 禁止将短的循环体(如单行语句)放在同一行 | ||
| 42 | +AllowShortLoopsOnASingleLine: false | ||
| 43 | + | ||
| 44 | +# 总是在返回类型后换行: None, All, TopLevel(顶级函数,不包括在类中的函数), | ||
| 45 | +# AllDefinitions(所有的定义,不包括声明), TopLevelDefinitions(所有的顶级函数的定义) | ||
| 46 | +AlwaysBreakAfterReturnType: None | ||
| 47 | + | ||
| 48 | +# 总是在多行string字面量前换行 | ||
| 49 | +AlwaysBreakBeforeMultilineStrings: false | ||
| 50 | + | ||
| 51 | +# 总是在template声明后换行 | ||
| 52 | +AlwaysBreakTemplateDeclarations: true | ||
| 53 | + | ||
| 54 | +# false表示函数实参要么都在同一行,要么都各自一行 | ||
| 55 | +BinPackArguments: true | ||
| 56 | + | ||
| 57 | +# false表示所有形参要么都在同一行,要么都各自一行 | ||
| 58 | +BinPackParameters: true | ||
| 59 | + | ||
| 60 | +# 大括号换行,只有当BreakBeforeBraces设置为Custom时才有效 | ||
| 61 | +BraceWrapping: | ||
| 62 | + # class定义后面 | ||
| 63 | + AfterClass: false | ||
| 64 | + # 控制语句后面 | ||
| 65 | + AfterControlStatement: false | ||
| 66 | + # enum定义后面 | ||
| 67 | + AfterEnum: false | ||
| 68 | + # 函数定义后面 | ||
| 69 | + AfterFunction: true | ||
| 70 | + # 命名空间定义后面 | ||
| 71 | + AfterNamespace: false | ||
| 72 | + # struct定义后面 | ||
| 73 | + AfterStruct: false | ||
| 74 | + # union定义后面 | ||
| 75 | + AfterUnion: false | ||
| 76 | + # extern之后 | ||
| 77 | + AfterExternBlock: false | ||
| 78 | + # catch之前 | ||
| 79 | + BeforeCatch: false | ||
| 80 | + # else之前 | ||
| 81 | + BeforeElse: false | ||
| 82 | + # 缩进大括号 | ||
| 83 | + IndentBraces: false | ||
| 84 | + # 分离空函数 | ||
| 85 | + SplitEmptyFunction: false | ||
| 86 | + # 分离空语句 | ||
| 87 | + SplitEmptyRecord: false | ||
| 88 | + # 分离空命名空间 | ||
| 89 | + SplitEmptyNamespace: false | ||
| 90 | + | ||
| 91 | +# 在二元运算符前换行: None(在操作符后换行), NonAssignment(在非赋值的操作符前换行), All(在操作符前换行) | ||
| 92 | +BreakBeforeBinaryOperators: NonAssignment | ||
| 93 | + | ||
| 94 | +# 在大括号前换行: Attach(始终将大括号附加到周围的上下文), Linux(除函数、命名空间和类定义,与Attach类似), | ||
| 95 | +# Mozilla(除枚举、函数、记录定义,与Attach类似), Stroustrup(除函数定义、catch、else,与Attach类似), | ||
| 96 | +# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom | ||
| 97 | +# 注:这里认为语句块也属于函数 | ||
| 98 | +BreakBeforeBraces: Custom | ||
| 99 | + | ||
| 100 | +# 在三元运算符前换行 | ||
| 101 | +BreakBeforeTernaryOperators: false | ||
| 102 | + | ||
| 103 | +# 在构造函数的初始化列表的冒号后换行 | ||
| 104 | +BreakConstructorInitializers: AfterColon | ||
| 105 | + | ||
| 106 | +#BreakInheritanceList: AfterColon | ||
| 107 | + | ||
| 108 | +BreakStringLiterals: false | ||
| 109 | + | ||
| 110 | +# 每行字符的限制,0表示没有限制 | ||
| 111 | +ColumnLimit: 120 | ||
| 112 | + | ||
| 113 | +CompactNamespaces: false | ||
| 114 | + | ||
| 115 | +# 构造函数的初始化列表要么都在同一行,要么都各自一行 | ||
| 116 | +ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
| 117 | + | ||
| 118 | +# 构造函数的初始化列表的缩进宽度 | ||
| 119 | +ConstructorInitializerIndentWidth: 4 | ||
| 120 | + | ||
| 121 | +# 延续的行的缩进宽度 | ||
| 122 | +ContinuationIndentWidth: 4 | ||
| 123 | + | ||
| 124 | +# 去除C++11的列表初始化的大括号{后和}前的空格 | ||
| 125 | +Cpp11BracedListStyle: true | ||
| 126 | + | ||
| 127 | +# 继承最常用的指针和引用的对齐方式 | ||
| 128 | +DerivePointerAlignment: false | ||
| 129 | + | ||
| 130 | +# 固定命名空间注释 | ||
| 131 | +FixNamespaceComments: true | ||
| 132 | + | ||
| 133 | +# 缩进case标签 | ||
| 134 | +IndentCaseLabels: false | ||
| 135 | + | ||
| 136 | +IndentPPDirectives: None | ||
| 137 | + | ||
| 138 | +# 缩进宽度 | ||
| 139 | +IndentWidth: 4 | ||
| 140 | + | ||
| 141 | +# 函数返回类型换行时,缩进函数声明或函数定义的函数名 | ||
| 142 | +IndentWrappedFunctionNames: false | ||
| 143 | + | ||
| 144 | +# 保留在块开始处的空行 | ||
| 145 | +KeepEmptyLinesAtTheStartOfBlocks: false | ||
| 146 | + | ||
| 147 | +# 连续空行的最大数量 | ||
| 148 | +MaxEmptyLinesToKeep: 1 | ||
| 149 | + | ||
| 150 | +# 命名空间的缩进: None, Inner(缩进嵌套的命名空间中的内容), All | ||
| 151 | +NamespaceIndentation: None | ||
| 152 | + | ||
| 153 | +# 指针和引用的对齐: Left, Right, Middle | ||
| 154 | +PointerAlignment: Left | ||
| 155 | + | ||
| 156 | +# 允许重新排版注释 | ||
| 157 | +ReflowComments: true | ||
| 158 | + | ||
| 159 | +# 允许排序#include | ||
| 160 | +SortIncludes: false | ||
| 161 | + | ||
| 162 | +# 允许排序 using 声明 | ||
| 163 | +SortUsingDeclarations: false | ||
| 164 | + | ||
| 165 | +# 在C风格类型转换后添加空格 | ||
| 166 | +SpaceAfterCStyleCast: false | ||
| 167 | + | ||
| 168 | +# 在Template 关键字后面添加空格 | ||
| 169 | +SpaceAfterTemplateKeyword: true | ||
| 170 | + | ||
| 171 | +# 在赋值运算符之前添加空格 | ||
| 172 | +SpaceBeforeAssignmentOperators: true | ||
| 173 | + | ||
| 174 | +# SpaceBeforeCpp11BracedList: true | ||
| 175 | + | ||
| 176 | +# SpaceBeforeCtorInitializerColon: true | ||
| 177 | + | ||
| 178 | +# SpaceBeforeInheritanceColon: true | ||
| 179 | + | ||
| 180 | +# 开圆括号之前添加一个空格: Never, ControlStatements, Always | ||
| 181 | +SpaceBeforeParens: ControlStatements | ||
| 182 | + | ||
| 183 | +# SpaceBeforeRangeBasedForLoopColon: true | ||
| 184 | + | ||
| 185 | +# 在空的圆括号中添加空格 | ||
| 186 | +SpaceInEmptyParentheses: false | ||
| 187 | + | ||
| 188 | +# 在尾随的评论前添加的空格数(只适用于//) | ||
| 189 | +SpacesBeforeTrailingComments: 1 | ||
| 190 | + | ||
| 191 | +# 在尖括号的<后和>前添加空格 | ||
| 192 | +SpacesInAngles: false | ||
| 193 | + | ||
| 194 | +# 在C风格类型转换的括号中添加空格 | ||
| 195 | +SpacesInCStyleCastParentheses: false | ||
| 196 | + | ||
| 197 | +# 在容器(ObjC和JavaScript的数组和字典等)字面量中添加空格 | ||
| 198 | +SpacesInContainerLiterals: true | ||
| 199 | + | ||
| 200 | +# 在圆括号的(后和)前添加空格 | ||
| 201 | +SpacesInParentheses: false | ||
| 202 | + | ||
| 203 | +# 在方括号的[后和]前添加空格,lamda表达式和未指明大小的数组的声明不受影响 | ||
| 204 | +SpacesInSquareBrackets: false | ||
| 205 | + | ||
| 206 | +# 标准: Cpp03, Cpp11, Auto | ||
| 207 | +Standard: Cpp11 | ||
| 208 | + | ||
| 209 | +# tab宽度 | ||
| 210 | +TabWidth: 4 | ||
| 211 | + | ||
| 212 | +# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always | ||
| 213 | +UseTab: Never | ||
| @@ -0,0 +1 @@ | |||
| 1 | +docs/api/context/c_api/figures/*.png filter=lfs diff=lfs merge=lfs -text | ||
| @@ -1,5 +1,6 @@ | |||
| 1 | -build | 1 | +.vscode |
| 2 | +/build/ | ||
| 2 | build_out | 3 | build_out |
| 3 | -scripts/package/common/__pycache__/ | 4 | +output |
| 4 | -scripts/package/common/py/__pycache__/ | 5 | +__pycache__/ |
| 5 | -scripts/package/common/py/utils/__pycache__/ | 6 | +/examples/**/build/ |
| @@ -43,7 +43,6 @@ if(CCACHE_PROGRAM) | |||
| 43 | endif() | 43 | endif() |
| 44 | 44 | ||
| 45 | add_subdirectory(impl) | 45 | add_subdirectory(impl) |
| 46 | -add_subdirectory(cmake) | ||
| 47 | 46 | ||
| 48 | if(BUILD_OPEN_PROJECT) | 47 | if(BUILD_OPEN_PROJECT) |
| 49 | include(cmake/intf_pub_linux.cmake) | 48 | include(cmake/intf_pub_linux.cmake) |
| @@ -51,6 +50,7 @@ if(BUILD_OPEN_PROJECT) | |||
| 51 | endif() | 50 | endif() |
| 52 | 51 | ||
| 53 | add_subdirectory(tools) | 52 | add_subdirectory(tools) |
| 53 | +add_subdirectory(cmake) | ||
| 54 | 54 | ||
| 55 | set(ASC_DEVKIT_VERSION_FILE ${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages/makeself_staging/share/info/asc-devkit/version.info) | 55 | set(ASC_DEVKIT_VERSION_FILE ${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages/makeself_staging/share/info/asc-devkit/version.info) |
| 56 | add_custom_command( | 56 | add_custom_command( |
| @@ -13,15 +13,13 @@ | |||
| 13 | <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies"> | 13 | <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies"> |
| 14 | <filteritem type="filename" name="OAT.xml" desc="Describe commite owner"/> | 14 | <filteritem type="filename" name="OAT.xml" desc="Describe commite owner"/> |
| 15 | <filteritem type="filename" name=".gitmodules" desc="git submodule "/> | 15 | <filteritem type="filename" name=".gitmodules" desc="git submodule "/> |
| 16 | - <filteritem type="filename" name="*.xml" desc="xml file"/> | 16 | + <filteritem type="filename" name=".xml" desc="xml file"/> |
| 17 | - <filteritem type="filename" name="*.csv" desc="csv file"/> | 17 | + <filteritem type="filename" name=".csv" desc="csv file"/> |
| 18 | - <filteritem type="filename" name="*.info" desc="info file"/> | ||
| 19 | </filefilter> | 18 | </filefilter> |
| 20 | <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies"> | 19 | <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies"> |
| 21 | <filteritem type="filename" name=".gitmodules" desc="git submodule "/> | 20 | <filteritem type="filename" name=".gitmodules" desc="git submodule "/> |
| 22 | - <filteritem type="filename" name="*.xml" desc="xml file"/> | 21 | + <filteritem type="filename" name=".xml" desc="xml file"/> |
| 23 | - <filteritem type="filename" name="*.csv" desc="xml csv"/> | 22 | + <filteritem type="filename" name=".csv" desc="xml csv"/> |
| 24 | - <filteritem type="filename" name="*.info" desc="info file"/> | ||
| 25 | </filefilter> | 23 | </filefilter> |
| 26 | <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies"> | 24 | <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies"> |
| 27 | </filefilter> | 25 | </filefilter> |
| @@ -138,7 +138,7 @@ class CompileKernel: | |||
| 138 | tiling_key_info, op_debug_config, kernel_json_file, _ = ( | 138 | tiling_key_info, op_debug_config, kernel_json_file, _ = ( |
| 139 | ascendc_bin_param_build.parse_op_debug_confg( | 139 | ascendc_bin_param_build.parse_op_debug_confg( |
| 140 | opc_config_file, | 140 | opc_config_file, |
| 141 | - self.op_type | 141 | + self.op_soc_ver |
| 142 | ) | 142 | ) |
| 143 | ) | 143 | ) |
| 144 | if self.op_type in op_debug_config: | 144 | if self.op_type in op_debug_config: |
| @@ -7,6 +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 | +add_compile_options(-Werror) | ||
| 10 | 11 | ||
| 11 | add_subdirectory(aicpu_api) | 12 | add_subdirectory(aicpu_api) |
| 12 | add_subdirectory(adv_api) | 13 | add_subdirectory(adv_api) |
| @@ -23,6 +23,7 @@ target_compile_options(aicpu_api PRIVATE | |||
| 23 | -fvisibility=hidden | 23 | -fvisibility=hidden |
| 24 | -fvisibility-inlines-hidden | 24 | -fvisibility-inlines-hidden |
| 25 | -ftrapv | 25 | -ftrapv |
| 26 | + -Werror | ||
| 26 | ) | 27 | ) |
| 27 | 28 | ||
| 28 | if(BUILD_OPEN_PROJECT) | 29 | if(BUILD_OPEN_PROJECT) |
Dimpl/utils/.gitkeep+0-2
| @@ -1,2 +0,0 @@ | |||
| 1 | -# This .gitkeep file ensures the directory is tracked by Git. | ||
| 2 | -# Remove this file when addding actual content to the directory. | ||
| @@ -38,7 +38,7 @@ enum class SocVersion { | |||
| 38 | ASCEND910B, // Ascend910B1~4, Ascend910B2C, Ascend910_93 Serials | 38 | ASCEND910B, // Ascend910B1~4, Ascend910B2C, Ascend910_93 Serials |
| 39 | ASCEND310P, // Ascend310P1, Ascend310P3 | 39 | ASCEND310P, // Ascend310P1, Ascend310P3 |
| 40 | ASCEND310B, // Ascend310B1, Ascend310B2, Ascend310B3, Ascend310B4 | 40 | ASCEND310B, // Ascend310B1, Ascend310B2, Ascend310B3, Ascend310B4 |
| 41 | - ASCEND910_95, // ASCEND910_95, __DAV_C310__ | 41 | + ASCEND950, // ASCEND950, __DAV_C310__ |
| 42 | RESERVED_VERSION = 99999 | 42 | RESERVED_VERSION = 99999 |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| @@ -267,7 +267,7 @@ ContextBuilder &ContextBuilder::AddPlatformInfo(const char *customSocVersion) | |||
| 267 | {"Ascend910B", SocVersion::ASCEND910B}, | 267 | {"Ascend910B", SocVersion::ASCEND910B}, |
| 268 | {"Ascend910_93", SocVersion::ASCEND910B}, | 268 | {"Ascend910_93", SocVersion::ASCEND910B}, |
| 269 | {"Ascend310B", SocVersion::ASCEND310B}, | 269 | {"Ascend310B", SocVersion::ASCEND310B}, |
| 270 | - {"Ascend910_95", SocVersion::ASCEND910_95}, | 270 | + {"Ascend950", SocVersion::ASCEND950}, |
| 271 | }; | 271 | }; |
| 272 | const static std::string labelVersion = "version"; | 272 | const static std::string labelVersion = "version"; |
| 273 | const static std::string labelShortSocVersion = "Short_SoC_version"; | 273 | const static std::string labelShortSocVersion = "Short_SoC_version"; |
Dimpl/utils/stub/tilingdata_base.cc+0-149
| @@ -1,149 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | -* Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| 3 | -* This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | -* CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | -* Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | -* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 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. | ||
| 9 | -*/ | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | -namespace optiling { | ||
| 16 | -std::vector<FieldInfo> TilingDef::GetFieldInfo() const { | ||
| 17 | - return field_info_; | ||
| 18 | -} | ||
| 19 | - | ||
| 20 | -const char *TilingDef::GetTilingClassName() const { | ||
| 21 | - return class_name_; | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -size_t TilingDef::GetDataSize() const { | ||
| 25 | - return data_size_; | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -bool CheckPathIsHeader(std::string file) { | ||
| 29 | - const std::string suffix = ".h"; | ||
| 30 | - if (suffix.size() > file.size()) { | ||
| 31 | - return false; | ||
| 32 | - } | ||
| 33 | - return file.substr(file.size() - suffix.size()) == suffix; | ||
| 34 | -} | ||
| 35 | - | ||
| 36 | -const char* GetFileName(const char* path) { | ||
| 37 | - const char* file_name = strrchr(path, '/'); | ||
| 38 | - if (!file_name) { | ||
| 39 | - return path; | ||
| 40 | - } else { | ||
| 41 | - file_name++; | ||
| 42 | - return file_name; | ||
| 43 | - } | ||
| 44 | -} | ||
| 45 | - | ||
| 46 | -uint32_t __attribute__((weak)) TilingDataStructBase::RecordTilingStruct(const char* name, const char* file, \ | ||
| 47 | - uint32_t line) { | ||
| 48 | - const char* file_name = GetFileName(file); | ||
| 49 | - bool is_header = CheckPathIsHeader(std::string(file_name)); | ||
| 50 | - auto it = records.find(name); | ||
| 51 | - if (it != records.end()) { | ||
| 52 | - std::pair<const char *, uint32_t> item = it->second; | ||
| 53 | - if (!is_header) { | ||
| 54 | - if (item.second != line) { | ||
| 55 | - printf("[Warning]: tiling struct [%s] is conflict with one in file %s, line %d\n", \ | ||
| 56 | - name, item.first, item.second); | ||
| 57 | - } | ||
| 58 | - return 0; | ||
| 59 | - } | ||
| 60 | - if (!CheckPathIsHeader(std::string(item.first))) { | ||
| 61 | - return 0; | ||
| 62 | - } | ||
| 63 | - if ((strcmp(item.first, file_name) == 0) && item.second == line) { | ||
| 64 | - return 0; | ||
| 65 | - } | ||
| 66 | - printf("[Warning]: tiling struct [%s] is conflict with one in file %s, line %d\n", \ | ||
| 67 | - name, item.first, item.second); | ||
| 68 | - } else { | ||
| 69 | - records.emplace(name, std::make_pair(file_name, line)); | ||
| 70 | - } | ||
| 71 | - return 0; | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -void TilingDef::GeLogError(const std::string &str) const { | ||
| 75 | - (void)str; | ||
| 76 | -} | ||
| 77 | - | ||
| 78 | -void TilingDef::SetDataPtr(void *dataPtr) { | ||
| 79 | - if (!inited_data_ptr && data_ptr_ != nullptr) { | ||
| 80 | - delete[] data_ptr_; | ||
| 81 | - } | ||
| 82 | - inited_data_ptr = true; | ||
| 83 | - data_ptr_ = (uint8_t*)dataPtr; | ||
| 84 | - for (auto &ptr : saveBufferPtr) { | ||
| 85 | - TilingDef* sub_ptr = (TilingDef *)ptr.first; | ||
| 86 | - size_t offset = ptr.second; | ||
| 87 | - uint8_t* struct_ptr = data_ptr_ + offset; | ||
| 88 | - sub_ptr->SetDataPtr(struct_ptr); | ||
| 89 | - } | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -void TilingDef::SaveToBuffer(void *pdata, size_t capacity) { | ||
| 93 | - if (inited_data_ptr) { | ||
| 94 | - return; | ||
| 95 | - } | ||
| 96 | - // copy tilingdata to buffer without struct tiling data. | ||
| 97 | - auto mem_ret = memcpy_s(pdata, capacity, data_ptr_, data_size_); | ||
| 98 | - if (mem_ret != EOK) { | ||
| 99 | - } | ||
| 100 | -} | ||
| 101 | - | ||
| 102 | -void TilingDef::CheckAlignAndGenPlaceHolder(const char *name, size_t typeSize) { | ||
| 103 | - if (data_size_ % typeSize == 0) { | ||
| 104 | - return; | ||
| 105 | - } | ||
| 106 | - size_t alignSize = typeSize - (data_size_ % typeSize); | ||
| 107 | - field_info_.emplace_back(FieldInfo("uint8_t", name, alignSize)); | ||
| 108 | - data_size_ += alignSize; | ||
| 109 | - return; | ||
| 110 | -} | ||
| 111 | - | ||
| 112 | -void TilingDef::InitData() { | ||
| 113 | - data_ptr_ = new (std::nothrow)uint8_t[data_size_](); | ||
| 114 | - if (data_ptr_ == nullptr) { | ||
| 115 | - return; | ||
| 116 | - } | ||
| 117 | - for (auto &ptr : saveBufferPtr) { | ||
| 118 | - TilingDef* sub_ptr = (TilingDef *)ptr.first; | ||
| 119 | - size_t offset = ptr.second; | ||
| 120 | - uint8_t* struct_ptr = data_ptr_ + offset; | ||
| 121 | - sub_ptr->SetDataPtr(struct_ptr); | ||
| 122 | - } | ||
| 123 | -} | ||
| 124 | - | ||
| 125 | -CTilingDataClassFactory &CTilingDataClassFactory::GetInstance() | ||
| 126 | -{ | ||
| 127 | - static CTilingDataClassFactory instance; | ||
| 128 | - return instance; | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | -void CTilingDataClassFactory::RegisterTilingData(const char *op_type, | ||
| 132 | - const TilingDataConstructor constructor) { | ||
| 133 | - instance_.emplace(op_type, constructor); | ||
| 134 | -} | ||
| 135 | - | ||
| 136 | -std::shared_ptr<TilingDef> CTilingDataClassFactory::CreateTilingDataInstance(const char *op_type) { | ||
| 137 | - const auto it = instance_.find(op_type); | ||
| 138 | - if (it == instance_.end()) { | ||
| 139 | - return nullptr; | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - const TilingDataConstructor constructor = it->second; | ||
| 143 | - if (constructor == nullptr) { | ||
| 144 | - return nullptr; | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - return (*constructor)(); | ||
| 148 | -} | ||
| 149 | -} // end of namespace optiling | ||
| @@ -25,7 +25,7 @@ | |||
| 25 | namespace platform_ascendc { | 25 | namespace platform_ascendc { |
| 26 | const static uint64_t LOCAL_RESERV_SIZE = 256; | 26 | const static uint64_t LOCAL_RESERV_SIZE = 256; |
| 27 | const static uint32_t WORK_SPACE_SIZE_910B = 16 * 1024 * 1024; | 27 | const static uint32_t WORK_SPACE_SIZE_910B = 16 * 1024 * 1024; |
| 28 | -const static uint32_t WORK_SPACE_SIZE_910_95 = 16 * 1024 * 1024; | 28 | +const static uint32_t WORK_SPACE_SIZE_950 = 16 * 1024 * 1024; |
| 29 | const static uint32_t WORK_SPACE_SIZE = 2 * 1024 * 1024; | 29 | const static uint32_t WORK_SPACE_SIZE = 2 * 1024 * 1024; |
| 30 | const static uint32_t MIX_AIC_AIV_RATION_910B1 = 2; | 30 | const static uint32_t MIX_AIC_AIV_RATION_910B1 = 2; |
| 31 | const static uint32_t CUBE_GROUP_WORK_SPACE_SIZE_910B = 1 * 1024 * 1024; | 31 | const static uint32_t CUBE_GROUP_WORK_SPACE_SIZE_910B = 1 * 1024 * 1024; |
| @@ -49,7 +49,7 @@ static inline SocVersion SocVersionStrMap(const char *socVersionStr) | |||
| 49 | {"Ascend910B", SocVersion::ASCEND910B}, | 49 | {"Ascend910B", SocVersion::ASCEND910B}, |
| 50 | {"Ascend910_93", SocVersion::ASCEND910B}, | 50 | {"Ascend910_93", SocVersion::ASCEND910B}, |
| 51 | {"Ascend310B", SocVersion::ASCEND310B}, | 51 | {"Ascend310B", SocVersion::ASCEND310B}, |
| 52 | - {"Ascend910_95", SocVersion::ASCEND910_95}, | 52 | + {"Ascend950", SocVersion::ASCEND950}, |
| 53 | {"AS31XM1", SocVersion::AS31XM1}, | 53 | {"AS31XM1", SocVersion::AS31XM1}, |
| 54 | {"Ascend031", SocVersion::ASCEND031}, | 54 | {"Ascend031", SocVersion::ASCEND031}, |
| 55 | {"Ascend035", SocVersion::ASCEND035}, | 55 | {"Ascend035", SocVersion::ASCEND035}, |
| @@ -244,7 +244,7 @@ uint32_t PlatformAscendC::GetLibApiWorkSpaceSize(void) const | |||
| 244 | } else if (npuArch == NpuArch::DAV_2201) { | 244 | } else if (npuArch == NpuArch::DAV_2201) { |
| 245 | return WORK_SPACE_SIZE_910B; | 245 | return WORK_SPACE_SIZE_910B; |
| 246 | } else if (npuArch == NpuArch::DAV_3510) { | 246 | } else if (npuArch == NpuArch::DAV_3510) { |
| 247 | - return WORK_SPACE_SIZE_910_95; | 247 | + return WORK_SPACE_SIZE_950; |
| 248 | } | 248 | } |
| 249 | return WORK_SPACE_SIZE; | 249 | return WORK_SPACE_SIZE; |
| 250 | } | 250 | } |
| @@ -304,38 +304,39 @@ const static std::map<std::string, std::string> convertMapInAicpu = { | |||
| 304 | {"Ascend310B2", "Ascend310B"}, | 304 | {"Ascend310B2", "Ascend310B"}, |
| 305 | {"Ascend310B3", "Ascend310B"}, | 305 | {"Ascend310B3", "Ascend310B"}, |
| 306 | {"Ascend310B4", "Ascend310B"}, | 306 | {"Ascend310B4", "Ascend310B"}, |
| 307 | - {"Ascend910_95A1", "Ascend910_95"}, | 307 | + {"Ascend950PR_9599", "Ascend950"}, |
| 308 | - {"Ascend910_95A2", "Ascend910_95"}, | 308 | + {"Ascend950PR_958a", "Ascend950"}, |
| 309 | - {"Ascend910_9591", "Ascend910_95"}, | 309 | + {"Ascend950PR_9589", "Ascend950"}, |
| 310 | - {"Ascend910_9592", "Ascend910_95"}, | 310 | + {"Ascend950PR_958b", "Ascend950"}, |
| 311 | - {"Ascend910_9595", "Ascend910_95"}, | 311 | + {"Ascend950PR_9579", "Ascend950"}, |
| 312 | - {"Ascend910_9596", "Ascend910_95"}, | 312 | + {"Ascend950PR_957b", "Ascend950"}, |
| 313 | - {"Ascend910_9581", "Ascend910_95"}, | 313 | + {"Ascend950PR_957c", "Ascend950"}, |
| 314 | - {"Ascend910_9582", "Ascend910_95"}, | 314 | + {"Ascend950PR_957d", "Ascend950"}, |
| 315 | - {"Ascend910_9583", "Ascend910_95"}, | 315 | + {"Ascend950PR_950z", "Ascend950"}, |
| 316 | - {"Ascend910_9584", "Ascend910_95"}, | 316 | + {"Ascend950DT_950x", "Ascend950"}, |
| 317 | - {"Ascend910_9585", "Ascend910_95"}, | 317 | + {"Ascend950DT_950y", "Ascend950"}, |
| 318 | - {"Ascend910_9586", "Ascend910_95"}, | 318 | + {"Ascend950DT_95A1", "Ascend950"}, |
| 319 | - {"Ascend910_9587", "Ascend910_95"}, | 319 | + {"Ascend950DT_95A2", "Ascend950"}, |
| 320 | - {"Ascend910_9588", "Ascend910_95"}, | 320 | + {"Ascend950DT_9591", "Ascend950"}, |
| 321 | - {"Ascend910_9571", "Ascend910_95"}, | 321 | + {"Ascend950DT_9592", "Ascend950"}, |
| 322 | - {"Ascend910_9572", "Ascend910_95"}, | 322 | + {"Ascend950DT_9595", "Ascend950"}, |
| 323 | - {"Ascend910_9573", "Ascend910_95"}, | 323 | + {"Ascend950DT_9596", "Ascend950"}, |
| 324 | - {"Ascend910_9574", "Ascend910_95"}, | 324 | + {"Ascend950DT_9581", "Ascend950"}, |
| 325 | - {"Ascend910_9575", "Ascend910_95"}, | 325 | + {"Ascend950DT_9582", "Ascend950"}, |
| 326 | - {"Ascend910_9576", "Ascend910_95"}, | 326 | + {"Ascend950DT_9583", "Ascend950"}, |
| 327 | - {"Ascend910_9577", "Ascend910_95"}, | 327 | + {"Ascend950DT_9584", "Ascend950"}, |
| 328 | - {"Ascend910_9578", "Ascend910_95"}, | 328 | + {"Ascend950DT_9585", "Ascend950"}, |
| 329 | - {"Ascend910_957b", "Ascend910_95"}, | 329 | + {"Ascend950DT_9586", "Ascend950"}, |
| 330 | - {"Ascend910_950x", "Ascend910_95"}, | 330 | + {"Ascend950DT_9587", "Ascend950"}, |
| 331 | - {"Ascend910_950y", "Ascend910_95"}, | 331 | + {"Ascend950DT_9588", "Ascend950"}, |
| 332 | - {"Ascend910_950z", "Ascend910_95"}, | 332 | + {"Ascend950DT_9571", "Ascend950"}, |
| 333 | - {"Ascend910_958b", "Ascend910_95"}, | 333 | + {"Ascend950DT_9572", "Ascend950"}, |
| 334 | - {"Ascend910_958a", "Ascend910_95"}, | 334 | + {"Ascend950DT_9573", "Ascend950"}, |
| 335 | - {"Ascend910_9599", "Ascend910_95"}, | 335 | + {"Ascend950DT_9574", "Ascend950"}, |
| 336 | - {"Ascend910_957d", "Ascend910_95"}, | 336 | + {"Ascend950DT_9575", "Ascend950"}, |
| 337 | - {"Ascend910_957c", "Ascend910_95"}, | 337 | + {"Ascend950DT_9576", "Ascend950"}, |
| 338 | - {"Ascend910_9589", "Ascend910_95"}, // ascend910_95_list | 338 | + {"Ascend950DT_9577", "Ascend950"}, |
| 339 | + {"Ascend950DT_9578", "Ascend950"}, // ascend950_list | ||
| 339 | {"MC62CM12AA", "MC62CM12A"}, | 340 | {"MC62CM12AA", "MC62CM12A"}, |
| 340 | {"KirinX90", "KirinX90"}, | 341 | {"KirinX90", "KirinX90"}, |
| 341 | {"Kirin9030", "Kirin9030"} | 342 | {"Kirin9030", "Kirin9030"} |
| @@ -345,7 +346,7 @@ const static std::map<std::string, std::string> AICPUshortVersionToNpuArchMap = | |||
| 345 | {"Ascend910B", "2201"}, // ascend910b_list | 346 | {"Ascend910B", "2201"}, // ascend910b_list |
| 346 | {"Ascend910", "1001"}, | 347 | {"Ascend910", "1001"}, |
| 347 | {"Ascend310B", "3002"}, | 348 | {"Ascend310B", "3002"}, |
| 348 | - {"Ascend910_95", "3510"}, // ascend910_95_list | 349 | + {"Ascend950", "3510"}, |
| 349 | {"MC62CM12A", "5102"}, | 350 | {"MC62CM12A", "5102"}, |
| 350 | {"KirinX90", "3003"}, | 351 | {"KirinX90", "3003"}, |
| 351 | {"Kirin9030", "3113"} | 352 | {"Kirin9030", "3113"} |
| @@ -62,8 +62,7 @@ enum class SocVersion { | |||
| 62 | ASCEND910B, // Ascend910B1~4, Ascend910B2C, Ascend910_93 Serials | 62 | ASCEND910B, // Ascend910B1~4, Ascend910B2C, Ascend910_93 Serials |
| 63 | ASCEND310P, // Ascend310P1, Ascend310P3 | 63 | ASCEND310P, // Ascend310P1, Ascend310P3 |
| 64 | ASCEND310B, // Ascend310B1, Ascend310B2, Ascend310B3, Ascend310B4 | 64 | ASCEND310B, // Ascend310B1, Ascend310B2, Ascend310B3, Ascend310B4 |
| 65 | - ASCEND950, // ASCEND950, __DAV_C310__ | 65 | + ASCEND950, // ASCEND950, __DAV_C310__ |
| 66 | - ASCEND910_95, // ASCEND910_95, __DAV_C310__ | ||
| 67 | ASCEND910_55, // ASCEND910_55, __DAV_310R6__ | 66 | ASCEND910_55, // ASCEND910_55, __DAV_310R6__ |
| 68 | AS31XM1, | 67 | AS31XM1, |
| 69 | ASCEND031, | 68 | ASCEND031, |
| @@ -506,10 +506,50 @@ del_prereq_check() { | |||
| 506 | 506 | ||
| 507 | # 设置环境变量 | 507 | # 设置环境变量 |
| 508 | add_setenv() { | 508 | add_setenv() { |
| 509 | + local install_path="$1" | ||
| 510 | + local package="$2" | ||
| 511 | + local setenv="$3" | ||
| 512 | + local username="$4" | ||
| 513 | + local usergroup="$5" | ||
| 514 | + local add_multi_version_param="$6" | ||
| 515 | + local docker_root="$7" | ||
| 516 | + | ||
| 517 | + for type in ${ENV_SHELL_TYPES}; do | ||
| 518 | + local shell_path_pair shell_path shell_path_real | ||
| 519 | + | ||
| 520 | + get_shell_path_and_shell_path_real "shell_path_pair" "${install_path}" "${package}" "setenv.${type}" "${docker_root}" | ||
| 521 | + __index_list "${shell_path_pair}" 0 "shell_path" 1 "shell_path_real" | ||
| 522 | + [ ! -f "${shell_path_real}" ] && continue | ||
| 523 | + | ||
| 524 | + add_env_rc "${install_path}" "${shell_path}" "${package}" "${type}" "${setenv}" "${username}" "${usergroup}" "${add_multi_version_param}" "${docker_root}" | ||
| 525 | + if [ $? -ne 0 ]; then | ||
| 526 | + log "ERROR" "failed to set ${package} ${type} env." | ||
| 527 | + return 1 | ||
| 528 | + fi | ||
| 529 | + done | ||
| 530 | + | ||
| 509 | return 0 | 531 | return 0 |
| 510 | } | 532 | } |
| 511 | 533 | ||
| 512 | # 删除环境变量 | 534 | # 删除环境变量 |
| 513 | del_setenv() { | 535 | del_setenv() { |
| 536 | + local install_path="$1" | ||
| 537 | + local package="$2" | ||
| 538 | + local username="$3" | ||
| 539 | + local docker_root="$4" | ||
| 540 | + | ||
| 541 | + for type in $ENV_SHELL_TYPES; do | ||
| 542 | + local shell_path_pair shell_path shell_path_real | ||
| 543 | + | ||
| 544 | + get_shell_path_and_shell_path_real "shell_path_pair" "${install_path}" "${package}" "setenv.${type}" "${docker_root}" | ||
| 545 | + __index_list "${shell_path_pair}" 0 "shell_path" 1 "shell_path_real" | ||
| 546 | + | ||
| 547 | + del_env_rc "${install_path}" "${shell_path}" "${type}" "${username}" "${docker_root}" | ||
| 548 | + if [ $? -ne 0 ]; then | ||
| 549 | + log "ERROR" "failed to unset ${package} ${type} env." | ||
| 550 | + return 1 | ||
| 551 | + fi | ||
| 552 | + done | ||
| 553 | + | ||
| 514 | return 0 | 554 | return 0 |
| 515 | } | 555 | } |
| @@ -0,0 +1,214 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ascendc kernel feature manager | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +import threading | ||
| 17 | +from abc import ABC, abstractmethod | ||
| 18 | +from typing import Dict, Type, Any, Callable, Optional | ||
| 19 | +from .log_utils import LogUtil, AscendCLogLevel | ||
| 20 | +from .global_storage import global_var_storage | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +class BaseFeature(ABC): | ||
| 24 | + """ | ||
| 25 | + base feature class | ||
| 26 | + """ | ||
| 27 | + def __init__(self, feature_name: str, feature_version: int): | ||
| 28 | + if not isinstance(feature_name, str): | ||
| 29 | + raise TypeError(f"feature_name's type must be str, current type is {type(feature_name).__name__}") | ||
| 30 | + if not isinstance(feature_version, int): | ||
| 31 | + raise TypeError(f"feature_version's type must be int, current type is {type(feature_version).__name__}") | ||
| 32 | + self.feature_name = feature_name | ||
| 33 | + self.feature_version = feature_version | ||
| 34 | + | ||
| 35 | + def get_intersection_version(self, others_value: int) -> int: | ||
| 36 | + """ | ||
| 37 | + Get the minimum version between current feature version and another version. | ||
| 38 | + | ||
| 39 | + Args: | ||
| 40 | + other_version: The version to compare with. | ||
| 41 | + | ||
| 42 | + Return: | ||
| 43 | + The minimum version of the two. | ||
| 44 | + """ | ||
| 45 | + return min(self.feature_version, others_value) | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + def get_feature_version_of_value(self, feature_value: any) -> int: | ||
| 49 | + """ | ||
| 50 | + Abstract method to get feature version from feature value. | ||
| 51 | + """ | ||
| 52 | + pass | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + def get_feature_value_of_version(self, feature_version: int) -> any: | ||
| 56 | + """ | ||
| 57 | + Abstract method to get feature value from feature version. | ||
| 58 | + """ | ||
| 59 | + pass | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + | ||
| 63 | +class AscendCKernelFeatureManager: | ||
| 64 | + """ | ||
| 65 | + super kernel feature manager | ||
| 66 | + """ | ||
| 67 | + _instance = None | ||
| 68 | + _lock = threading.Lock() | ||
| 69 | + | ||
| 70 | + def __new__(cls, *args, **kwargs): | ||
| 71 | + with cls._lock: | ||
| 72 | + if not cls._instance: | ||
| 73 | + cls._instance = super(AscendCKernelFeatureManager, cls).__new__(cls, *args, **kwargs) | ||
| 74 | + return cls._instance | ||
| 75 | + | ||
| 76 | + def __init__(self, use_ordered: bool = False): | ||
| 77 | + # store registered feature class: {feature_name, feature_class_instance} | ||
| 78 | + self._support_features_instances: Dict[str, BaseFeature] = {} | ||
| 79 | + self._support_feature_version_map: dict = {} | ||
| 80 | + self._available_feature_version_map: dict = {} | ||
| 81 | + self._enable_features_base: dict = {} | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + def init_available_and_enable_features(self): | ||
| 85 | + if global_var_storage.get_variable("ascendc_enable_super_kernel") is False: | ||
| 86 | + return | ||
| 87 | + | ||
| 88 | + input_features = {} | ||
| 89 | + import tbe.common.context.op_context as op_context | ||
| 90 | + input_features = op_context.get_context().get_addition("feature_list") | ||
| 91 | + if input_features is None: | ||
| 92 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 93 | + f"get feature versions from te_fusion is None", AscendCLogLevel.LOG_INFO) | ||
| 94 | + return | ||
| 95 | + else: | ||
| 96 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 97 | + f"get feature versions from te_fusion is {input_features}", AscendCLogLevel.LOG_INFO) | ||
| 98 | + | ||
| 99 | + for feature_name in input_features.keys(): | ||
| 100 | + if feature_name not in self._support_features_instances.keys(): | ||
| 101 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 102 | + f"{feature_name} does not support in ascendc compile, please upgrade the CANN version", \ | ||
| 103 | + AscendCLogLevel.LOG_INFO) | ||
| 104 | + else: | ||
| 105 | + feature_instance = self._support_features_instances[feature_name] | ||
| 106 | + self._available_feature_version_map[feature_name] = \ | ||
| 107 | + feature_instance.get_intersection_version(input_features[feature_name]) | ||
| 108 | + | ||
| 109 | + self._enable_features_base[feature_name] = \ | ||
| 110 | + feature_instance.get_feature_value_of_version(self._available_feature_version_map[feature_name]) | ||
| 111 | + | ||
| 112 | + | ||
| 113 | + def check_feature_valid(self, feature_name: str, feature_value: any): | ||
| 114 | + available_feature_verison = self._available_feature_version_map[feature_name] | ||
| 115 | + feature_instance = self._support_features_instances[feature_name] | ||
| 116 | + return feature_instance.get_feature_version_of_value(feature_value) <= available_feature_verison | ||
| 117 | + | ||
| 118 | + def register_feature(self, feature_cls: Type[BaseFeature]) -> None: | ||
| 119 | + """ | ||
| 120 | + register feature class | ||
| 121 | + :param feature_cls: feature class base on BaseFeature | ||
| 122 | + :raises ValueError: if duplicated or unimplemented | ||
| 123 | + """ | ||
| 124 | + if not issubclass(feature_cls, BaseFeature): | ||
| 125 | + raise ValueError(f"class {feature_cls.__name__} must be inherited from BaseFeature") | ||
| 126 | + | ||
| 127 | + instance = feature_cls() | ||
| 128 | + if instance.feature_name in self._support_features_instances: | ||
| 129 | + raise ValueError(f"feature {instance.feature_name} already existed") | ||
| 130 | + self._support_features_instances[instance.feature_name] = instance | ||
| 131 | + self._support_feature_version_map[instance.feature_name] = instance.feature_version | ||
| 132 | + | ||
| 133 | + def unregister_feature(self, feature_name: str) -> None: | ||
| 134 | + if feature_name not in self._support_features_instances: | ||
| 135 | + raise KeyError(f"feature {feature_name} does not exists") | ||
| 136 | + | ||
| 137 | + self._support_features_instances.pop(feature_name) | ||
| 138 | + | ||
| 139 | + def set_feature_value(self, feature_name: str, feature_value: any): | ||
| 140 | + """ | ||
| 141 | + set feature value | ||
| 142 | + if the input passes the verification, the input value is used, | ||
| 143 | + otherwise, the default value is used. | ||
| 144 | + """ | ||
| 145 | + if feature_name not in self._enable_features_base.keys(): | ||
| 146 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 147 | + f"{feature_name} does not support in ascendc compile, \ | ||
| 148 | + please upgrade the related software version, i.e. cann, opp, graph-autofusion.", \ | ||
| 149 | + AscendCLogLevel.LOG_INFO) | ||
| 150 | + return | ||
| 151 | + if self.check_feature_valid(feature_name, feature_value): | ||
| 152 | + self._enable_features_base[feature_name] = feature_value | ||
| 153 | + else: | ||
| 154 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 155 | + f"feature {feature_name} does not support {feature_value}, \ | ||
| 156 | + currect support version is {self._available_feature_version_map[feature_name]}, \ | ||
| 157 | + please upgrade the related software version, \ | ||
| 158 | + i.e. cann, opp, graph-autofusion.", AscendCLogLevel.LOG_INFO) | ||
| 159 | + | ||
| 160 | + def get_feature_value(self, feature_name: str) -> any: | ||
| 161 | + """ | ||
| 162 | + get feature value according to feature name | ||
| 163 | + """ | ||
| 164 | + if feature_name not in self._enable_features_base.keys(): | ||
| 165 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 166 | + f"{feature_name} does not support in ascendc compile, \ | ||
| 167 | + please upgrade the related software version, i.e. cann, opp, graph-autofusion.", \ | ||
| 168 | + AscendCLogLevel.LOG_INFO) | ||
| 169 | + return None | ||
| 170 | + return self._enable_features_base[feature_name] | ||
| 171 | + | ||
| 172 | + def get_support_feature_versions(self) -> dict: | ||
| 173 | + return self._support_feature_version_map.copy() | ||
| 174 | + | ||
| 175 | + def get_available_feature_versions(self) -> dict: | ||
| 176 | + return self._available_feature_version_map.copy() | ||
| 177 | + | ||
| 178 | + | ||
| 179 | +def register_feature(manager: AscendCKernelFeatureManager): | ||
| 180 | + """ | ||
| 181 | + decorator: used to quickly register a feature class to a specified manager | ||
| 182 | + :param manager: feature manager instance | ||
| 183 | + example | ||
| 184 | + | ||
| 185 | + class FeatureExample(BaseFeature): | ||
| 186 | + def __init__(self): | ||
| 187 | + super().__init__("test_feature", 1) # feature value | ||
| 188 | + | ||
| 189 | + def get_feature_version_of_value(self, feature_value: any) -> int: | ||
| 190 | + if feature_value == True: | ||
| 191 | + return 1 | ||
| 192 | + else: | ||
| 193 | + return 0 | ||
| 194 | + | ||
| 195 | + def get_feature_value_of_version(self, feature_version: int) -> any: | ||
| 196 | + if feature_version == 1: | ||
| 197 | + return True | ||
| 198 | + elif feature_version == 0: | ||
| 199 | + return False | ||
| 200 | + else: | ||
| 201 | + raise ValueError(f"{self.feature_name} does not support {feature_version}") | ||
| 202 | + """ | ||
| 203 | + def decorator(feature_cls: Type[BaseFeature]) -> Type[BaseFeature]: | ||
| 204 | + manager.register_feature(feature_cls) | ||
| 205 | + return feature_cls | ||
| 206 | + | ||
| 207 | + return decorator | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +global_ascendc_kernel_feature_manager = AscendCKernelFeatureManager() | ||
| 211 | + | ||
| 212 | + | ||
| 213 | +def get_features(): | ||
| 214 | + return global_ascendc_kernel_feature_manager.get_support_feature_versions() | ||
| @@ -0,0 +1,214 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ascendc kernel feature manager | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +import threading | ||
| 17 | +from abc import ABC, abstractmethod | ||
| 18 | +from typing import Dict, Type, Any, Callable, Optional | ||
| 19 | +from asc_op_compile_base.common.utils.log_utils import LogUtil, AscendCLogLevel | ||
| 20 | +from .global_storage import global_var_storage | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +class BaseFeature(ABC): | ||
| 24 | + """ | ||
| 25 | + base feature class | ||
| 26 | + """ | ||
| 27 | + def __init__(self, feature_name: str, feature_version: int): | ||
| 28 | + if not isinstance(feature_name, str): | ||
| 29 | + raise TypeError(f"feature_name's type must be str, current type is {type(feature_name).__name__}") | ||
| 30 | + if not isinstance(feature_version, int): | ||
| 31 | + raise TypeError(f"feature_version's type must be int, current type is {type(feature_version).__name__}") | ||
| 32 | + self.feature_name = feature_name | ||
| 33 | + self.feature_version = feature_version | ||
| 34 | + | ||
| 35 | + def get_intersection_version(self, others_value: int) -> int: | ||
| 36 | + """ | ||
| 37 | + Get the minimum version between current feature version and another version. | ||
| 38 | + | ||
| 39 | + Args: | ||
| 40 | + other_version: The version to compare with. | ||
| 41 | + | ||
| 42 | + Return: | ||
| 43 | + The minimum version of the two. | ||
| 44 | + """ | ||
| 45 | + return min(self.feature_version, others_value) | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + def get_feature_version_of_value(self, feature_value: any) -> int: | ||
| 49 | + """ | ||
| 50 | + Abstract method to get feature version from feature value. | ||
| 51 | + """ | ||
| 52 | + pass | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + def get_feature_value_of_version(self, feature_version: int) -> any: | ||
| 56 | + """ | ||
| 57 | + Abstract method to get feature value from feature version. | ||
| 58 | + """ | ||
| 59 | + pass | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + | ||
| 63 | +class AscendCKernelFeatureManager: | ||
| 64 | + """ | ||
| 65 | + super kernel feature manager | ||
| 66 | + """ | ||
| 67 | + _instance = None | ||
| 68 | + _lock = threading.Lock() | ||
| 69 | + | ||
| 70 | + def __new__(cls, *args, **kwargs): | ||
| 71 | + with cls._lock: | ||
| 72 | + if not cls._instance: | ||
| 73 | + cls._instance = super(AscendCKernelFeatureManager, cls).__new__(cls, *args, **kwargs) | ||
| 74 | + return cls._instance | ||
| 75 | + | ||
| 76 | + def __init__(self, use_ordered: bool = False): | ||
| 77 | + # store registered feature class: {feature_name, feature_class_instance} | ||
| 78 | + self._support_features_instances: Dict[str, BaseFeature] = {} | ||
| 79 | + self._support_feature_version_map: dict = {} | ||
| 80 | + self._available_feature_version_map: dict = {} | ||
| 81 | + self._enable_features_base: dict = {} | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + def init_available_and_enable_features(self): | ||
| 85 | + if global_var_storage.get_variable("ascendc_enable_super_kernel") is False: | ||
| 86 | + return | ||
| 87 | + | ||
| 88 | + input_features = {} | ||
| 89 | + import asc_op_compile_base.common.context.op_context as op_context | ||
| 90 | + input_features = op_context.get_context().get_addition("feature_list") | ||
| 91 | + if input_features is None: | ||
| 92 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 93 | + f"get feature versions from te_fusion is None", AscendCLogLevel.LOG_INFO) | ||
| 94 | + return | ||
| 95 | + else: | ||
| 96 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 97 | + f"get feature versions from te_fusion is {input_features}", AscendCLogLevel.LOG_INFO) | ||
| 98 | + | ||
| 99 | + for feature_name in input_features.keys(): | ||
| 100 | + if feature_name not in self._support_features_instances.keys(): | ||
| 101 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 102 | + f"{feature_name} does not support in ascendc compile, please upgrade the CANN version", \ | ||
| 103 | + AscendCLogLevel.LOG_INFO) | ||
| 104 | + else: | ||
| 105 | + feature_instance = self._support_features_instances[feature_name] | ||
| 106 | + self._available_feature_version_map[feature_name] = \ | ||
| 107 | + feature_instance.get_intersection_version(input_features[feature_name]) | ||
| 108 | + | ||
| 109 | + self._enable_features_base[feature_name] = \ | ||
| 110 | + feature_instance.get_feature_value_of_version(self._available_feature_version_map[feature_name]) | ||
| 111 | + | ||
| 112 | + | ||
| 113 | + def check_feature_valid(self, feature_name: str, feature_value: any): | ||
| 114 | + available_feature_verison = self._available_feature_version_map[feature_name] | ||
| 115 | + feature_instance = self._support_features_instances[feature_name] | ||
| 116 | + return feature_instance.get_feature_version_of_value(feature_value) <= available_feature_verison | ||
| 117 | + | ||
| 118 | + def register_feature(self, feature_cls: Type[BaseFeature]) -> None: | ||
| 119 | + """ | ||
| 120 | + register feature class | ||
| 121 | + :param feature_cls: feature class base on BaseFeature | ||
| 122 | + :raises ValueError: if duplicated or unimplemented | ||
| 123 | + """ | ||
| 124 | + if not issubclass(feature_cls, BaseFeature): | ||
| 125 | + raise ValueError(f"class {feature_cls.__name__} must be inherited from BaseFeature") | ||
| 126 | + | ||
| 127 | + instance = feature_cls() | ||
| 128 | + if instance.feature_name in self._support_features_instances: | ||
| 129 | + raise ValueError(f"feature {instance.feature_name} already existed") | ||
| 130 | + self._support_features_instances[instance.feature_name] = instance | ||
| 131 | + self._support_feature_version_map[instance.feature_name] = instance.feature_version | ||
| 132 | + | ||
| 133 | + def unregister_feature(self, feature_name: str) -> None: | ||
| 134 | + if feature_name not in self._support_features_instances: | ||
| 135 | + raise KeyError(f"feature {feature_name} does not exists") | ||
| 136 | + | ||
| 137 | + self._support_features_instances.pop(feature_name) | ||
| 138 | + | ||
| 139 | + def set_feature_value(self, feature_name: str, feature_value: any): | ||
| 140 | + """ | ||
| 141 | + set feature value | ||
| 142 | + if the input passes the verification, the input value is used, | ||
| 143 | + otherwise, the default value is used. | ||
| 144 | + """ | ||
| 145 | + if feature_name not in self._enable_features_base.keys(): | ||
| 146 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 147 | + f"{feature_name} does not support in ascendc compile, \ | ||
| 148 | + please upgrade the related software version, i.e. cann, opp, graph-autofusion.", \ | ||
| 149 | + AscendCLogLevel.LOG_INFO) | ||
| 150 | + return | ||
| 151 | + if self.check_feature_valid(feature_name, feature_value): | ||
| 152 | + self._enable_features_base[feature_name] = feature_value | ||
| 153 | + else: | ||
| 154 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 155 | + f"feature {feature_name} does not support {feature_value}, \ | ||
| 156 | + currect support version is {self._available_feature_version_map[feature_name]}, \ | ||
| 157 | + please upgrade the related software version, \ | ||
| 158 | + i.e. cann, opp, graph-autofusion.", AscendCLogLevel.LOG_INFO) | ||
| 159 | + | ||
| 160 | + def get_feature_value(self, feature_name: str) -> any: | ||
| 161 | + """ | ||
| 162 | + get feature value according to feature name | ||
| 163 | + """ | ||
| 164 | + if feature_name not in self._enable_features_base.keys(): | ||
| 165 | + LogUtil.print_compile_log("AscendC Feature Manager", \ | ||
| 166 | + f"{feature_name} does not support in ascendc compile, \ | ||
| 167 | + please upgrade the related software version, i.e. cann, opp, graph-autofusion.", \ | ||
| 168 | + AscendCLogLevel.LOG_INFO) | ||
| 169 | + return None | ||
| 170 | + return self._enable_features_base[feature_name] | ||
| 171 | + | ||
| 172 | + def get_support_feature_versions(self) -> dict: | ||
| 173 | + return self._support_feature_version_map.copy() | ||
| 174 | + | ||
| 175 | + def get_available_feature_versions(self) -> dict: | ||
| 176 | + return self._available_feature_version_map.copy() | ||
| 177 | + | ||
| 178 | + | ||
| 179 | +def register_feature(manager: AscendCKernelFeatureManager): | ||
| 180 | + """ | ||
| 181 | + decorator: used to quickly register a feature class to a specified manager | ||
| 182 | + :param manager: feature manager instance | ||
| 183 | + example | ||
| 184 | + | ||
| 185 | + class FeatureExample(BaseFeature): | ||
| 186 | + def __init__(self): | ||
| 187 | + super().__init__("test_feature", 1) # feature value | ||
| 188 | + | ||
| 189 | + def get_feature_version_of_value(self, feature_value: any) -> int: | ||
| 190 | + if feature_value == True: | ||
| 191 | + return 1 | ||
| 192 | + else: | ||
| 193 | + return 0 | ||
| 194 | + | ||
| 195 | + def get_feature_value_of_version(self, feature_version: int) -> any: | ||
| 196 | + if feature_version == 1: | ||
| 197 | + return True | ||
| 198 | + elif feature_version == 0: | ||
| 199 | + return False | ||
| 200 | + else: | ||
| 201 | + raise ValueError(f"{self.feature_name} does not support {feature_version}") | ||
| 202 | + """ | ||
| 203 | + def decorator(feature_cls: Type[BaseFeature]) -> Type[BaseFeature]: | ||
| 204 | + manager.register_feature(feature_cls) | ||
| 205 | + return feature_cls | ||
| 206 | + | ||
| 207 | + return decorator | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +global_ascendc_kernel_feature_manager = AscendCKernelFeatureManager() | ||
| 211 | + | ||
| 212 | + | ||
| 213 | +def get_features(): | ||
| 214 | + return global_ascendc_kernel_feature_manager.get_support_feature_versions() | ||
| @@ -0,0 +1,155 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend910b | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = True | ||
| 32 | + support_super_kernel = False | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_DEFAULT | ||
| 36 | + set_default_code_channel = True | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = False | ||
| 39 | + enable_kernel_type_mix = False | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint64" | ||
| 50 | + macro_def = ["false", "false", "false", "false", "true", "__DAV_C100__"] | ||
| 51 | + need_const_tiling_qualifier = False | ||
| 52 | + | ||
| 53 | + # Code Generator Config | ||
| 54 | + transform_kernel_type = False | ||
| 55 | + dfx_gen_meta_info = False | ||
| 56 | + dfx_param_byte_unit = False | ||
| 57 | + need_clear_workspace = True | ||
| 58 | + gen_code_for_l2_cache = False | ||
| 59 | + write_back_overflow = True | ||
| 60 | + needs_ffts = True | ||
| 61 | + support_dci = False | ||
| 62 | + support_raw_aic_only_dump_tensor = False | ||
| 63 | + support_mix = False | ||
| 64 | + dci_macro = "false" | ||
| 65 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_DEFAULT | ||
| 66 | + cube_core_type_macro = "__DAV_M200__" | ||
| 67 | + vec_core_type_macro = "__DAV_M200_VEC__" | ||
| 68 | + support_workspace_offset = False | ||
| 69 | + | ||
| 70 | + # Cmd Compiler Config | ||
| 71 | + compiler_path_o_level = "-O3" | ||
| 72 | + self_defined_options = [] | ||
| 73 | + enable_sanitizer = False | ||
| 74 | + enable_jump_expand = False | ||
| 75 | + self_defined_debug_config = [] | ||
| 76 | + meta_info_options = [] | ||
| 77 | + gen_assembel = False | ||
| 78 | + | ||
| 79 | + # Op Compiler Config | ||
| 80 | + dfx_set_kernel_type_mix = False | ||
| 81 | + dfx_set_kernel_type_aic = False | ||
| 82 | + support_raw_aic_only_dump_tensor = False | ||
| 83 | + chip_version = "" | ||
| 84 | + compile_type = CompileType.COMPILE_TYPE_DEFAULT | ||
| 85 | + | ||
| 86 | + # Genrate Config | ||
| 87 | + initializer_config = InitializerConfig( | ||
| 88 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 89 | + ) | ||
| 90 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 91 | + pre_compile_type, | ||
| 92 | + set_default_code_channel, | ||
| 93 | + need_find_kernel_type, | ||
| 94 | + enable_kernel_type_mix_n, | ||
| 95 | + enable_kernel_type_mix, | ||
| 96 | + enable_simt, | ||
| 97 | + dump_size_multiples, | ||
| 98 | + chip_version, | ||
| 99 | + decode_mode_v310, | ||
| 100 | + ) | ||
| 101 | + code_generator_config = CodeGeneratorConfig( | ||
| 102 | + transform_kernel_type, | ||
| 103 | + dfx_gen_meta_info, | ||
| 104 | + dfx_param_byte_unit, | ||
| 105 | + need_clear_workspace, | ||
| 106 | + gen_code_for_l2_cache, | ||
| 107 | + write_back_overflow, | ||
| 108 | + needs_ffts, | ||
| 109 | + support_dci, | ||
| 110 | + support_raw_aic_only_dump_tensor, | ||
| 111 | + support_mix, | ||
| 112 | + dci_macro, | ||
| 113 | + gen_isolation_macro_type, | ||
| 114 | + cube_core_type_macro, | ||
| 115 | + vec_core_type_macro, | ||
| 116 | + support_workspace_offset, | ||
| 117 | + ) | ||
| 118 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 119 | + enable_vd, | ||
| 120 | + with_time_stamp_dynamic, | ||
| 121 | + with_time_stamp_static, | ||
| 122 | + tiling_format, | ||
| 123 | + macro_def, | ||
| 124 | + need_const_tiling_qualifier, | ||
| 125 | + ) | ||
| 126 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 127 | + compiler_path_o_level, | ||
| 128 | + self_defined_options, | ||
| 129 | + enable_sanitizer, | ||
| 130 | + enable_jump_expand, | ||
| 131 | + self_defined_debug_config, | ||
| 132 | + meta_info_options, | ||
| 133 | + gen_assembel, | ||
| 134 | + ) | ||
| 135 | + op_compiler_config = OpCompilerConfig( | ||
| 136 | + cube_core_type_macro, | ||
| 137 | + vec_core_type_macro, | ||
| 138 | + dfx_gen_meta_info, | ||
| 139 | + dfx_set_kernel_type_mix, | ||
| 140 | + dfx_set_kernel_type_aic, | ||
| 141 | + support_raw_aic_only_dump_tensor, | ||
| 142 | + chip_version, | ||
| 143 | + compile_type, | ||
| 144 | + ) | ||
| 145 | + kernel_compile_config = KernelCompilerConfig() | ||
| 146 | + super().__init__( | ||
| 147 | + initializer_config, | ||
| 148 | + compile_info_generator_config, | ||
| 149 | + tiling_info_generator_config, | ||
| 150 | + code_generator_config, | ||
| 151 | + op_compiler_config, | ||
| 152 | + kernel_compile_config, | ||
| 153 | + cmd_compiler_config, | ||
| 154 | + ) | ||
| 155 | + | ||
| @@ -0,0 +1,155 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend310p | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = True | ||
| 32 | + support_super_kernel = False | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_DEFAULT | ||
| 36 | + set_default_code_channel = True | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = False | ||
| 39 | + enable_kernel_type_mix = True | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "v200" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint8" | ||
| 50 | + macro_def = ["false", "false", "false", "false", "true", "__DAV_C100__"] | ||
| 51 | + need_const_tiling_qualifier = False | ||
| 52 | + | ||
| 53 | + # Code Generator Config | ||
| 54 | + transform_kernel_type = False | ||
| 55 | + dfx_gen_meta_info = False | ||
| 56 | + dfx_param_byte_unit = False | ||
| 57 | + need_clear_workspace = True | ||
| 58 | + gen_code_for_l2_cache = False | ||
| 59 | + write_back_overflow = False | ||
| 60 | + needs_ffts = False | ||
| 61 | + support_dci = False | ||
| 62 | + support_raw_aic_only_dump_tensor = False | ||
| 63 | + support_mix = False | ||
| 64 | + dci_macro = "false" | ||
| 65 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_MIX | ||
| 66 | + support_workspace_offset = False | ||
| 67 | + | ||
| 68 | + # Cmd Compiler Config | ||
| 69 | + compiler_path_o_level = "-O3" | ||
| 70 | + self_defined_options = [] | ||
| 71 | + enable_sanitizer = True | ||
| 72 | + enable_jump_expand = False | ||
| 73 | + self_defined_debug_config = [] | ||
| 74 | + meta_info_options = [] | ||
| 75 | + gen_assembel = False | ||
| 76 | + | ||
| 77 | + # Op Compiler Config | ||
| 78 | + cube_core_type_macro = "__DAV_M200__" | ||
| 79 | + vec_core_type_macro = "__DAV_M200_VEC__" | ||
| 80 | + dfx_set_kernel_type_mix = False | ||
| 81 | + dfx_set_kernel_type_aic = False | ||
| 82 | + support_raw_aic_only_dump_tensor = False | ||
| 83 | + chip_version = "" | ||
| 84 | + compile_type = CompileType.COMPILE_TYPE_DEFAULT | ||
| 85 | + | ||
| 86 | + # Genrate Config | ||
| 87 | + initializer_config = InitializerConfig( | ||
| 88 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 89 | + ) | ||
| 90 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 91 | + pre_compile_type, | ||
| 92 | + set_default_code_channel, | ||
| 93 | + need_find_kernel_type, | ||
| 94 | + enable_kernel_type_mix_n, | ||
| 95 | + enable_kernel_type_mix, | ||
| 96 | + enable_simt, | ||
| 97 | + dump_size_multiples, | ||
| 98 | + chip_version, | ||
| 99 | + decode_mode_v310, | ||
| 100 | + ) | ||
| 101 | + code_generator_config = CodeGeneratorConfig( | ||
| 102 | + transform_kernel_type, | ||
| 103 | + dfx_gen_meta_info, | ||
| 104 | + dfx_param_byte_unit, | ||
| 105 | + need_clear_workspace, | ||
| 106 | + gen_code_for_l2_cache, | ||
| 107 | + write_back_overflow, | ||
| 108 | + needs_ffts, | ||
| 109 | + support_dci, | ||
| 110 | + support_raw_aic_only_dump_tensor, | ||
| 111 | + support_mix, | ||
| 112 | + dci_macro, | ||
| 113 | + gen_isolation_macro_type, | ||
| 114 | + cube_core_type_macro, | ||
| 115 | + vec_core_type_macro, | ||
| 116 | + support_workspace_offset, | ||
| 117 | + ) | ||
| 118 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 119 | + enable_vd, | ||
| 120 | + with_time_stamp_dynamic, | ||
| 121 | + with_time_stamp_static, | ||
| 122 | + tiling_format, | ||
| 123 | + macro_def, | ||
| 124 | + need_const_tiling_qualifier, | ||
| 125 | + ) | ||
| 126 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 127 | + compiler_path_o_level, | ||
| 128 | + self_defined_options, | ||
| 129 | + enable_sanitizer, | ||
| 130 | + enable_jump_expand, | ||
| 131 | + self_defined_debug_config, | ||
| 132 | + meta_info_options, | ||
| 133 | + gen_assembel, | ||
| 134 | + ) | ||
| 135 | + op_compiler_config = OpCompilerConfig( | ||
| 136 | + cube_core_type_macro, | ||
| 137 | + vec_core_type_macro, | ||
| 138 | + dfx_gen_meta_info, | ||
| 139 | + dfx_set_kernel_type_mix, | ||
| 140 | + dfx_set_kernel_type_aic, | ||
| 141 | + support_raw_aic_only_dump_tensor, | ||
| 142 | + chip_version, | ||
| 143 | + compile_type, | ||
| 144 | + ) | ||
| 145 | + kernel_compile_config = KernelCompilerConfig() | ||
| 146 | + super().__init__( | ||
| 147 | + initializer_config, | ||
| 148 | + compile_info_generator_config, | ||
| 149 | + tiling_info_generator_config, | ||
| 150 | + code_generator_config, | ||
| 151 | + op_compiler_config, | ||
| 152 | + kernel_compile_config, | ||
| 153 | + cmd_compiler_config, | ||
| 154 | + ) | ||
| 155 | + | ||
| @@ -0,0 +1,156 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend610 | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = True | ||
| 32 | + support_super_kernel = False | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_DEFAULT | ||
| 36 | + set_default_code_channel = True | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = False | ||
| 39 | + enable_kernel_type_mix = True | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "v200" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint8" | ||
| 50 | + macro_def = ["false", "false", "false", "false", "true", "__DAV_C100__"] | ||
| 51 | + need_const_tiling_qualifier = False | ||
| 52 | + | ||
| 53 | + # Code Generator Config | ||
| 54 | + transform_kernel_type = False | ||
| 55 | + dfx_gen_meta_info = False | ||
| 56 | + dfx_param_byte_unit = False | ||
| 57 | + need_clear_workspace = True | ||
| 58 | + gen_code_for_l2_cache = False | ||
| 59 | + write_back_overflow = False | ||
| 60 | + needs_ffts = False | ||
| 61 | + support_dci = False | ||
| 62 | + support_raw_aic_only_dump_tensor = False | ||
| 63 | + support_mix = False | ||
| 64 | + dci_macro = "false" | ||
| 65 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_MIX | ||
| 66 | + support_workspace_offset = False | ||
| 67 | + | ||
| 68 | + # Cmd Compiler Config | ||
| 69 | + compiler_path_o_level = "-O3" | ||
| 70 | + self_defined_options = [] | ||
| 71 | + enable_sanitizer = True | ||
| 72 | + enable_jump_expand = False | ||
| 73 | + self_defined_debug_config = [] | ||
| 74 | + meta_info_options = [] | ||
| 75 | + gen_assembel = False | ||
| 76 | + | ||
| 77 | + # Op Compiler Config | ||
| 78 | + cube_core_type_macro = "__DAV_M200__" | ||
| 79 | + vec_core_type_macro = "__DAV_M200_VEC__" | ||
| 80 | + dfx_gen_meta_info = False | ||
| 81 | + dfx_set_kernel_type_mix = False | ||
| 82 | + dfx_set_kernel_type_aic = False | ||
| 83 | + support_raw_aic_only_dump_tensor = False | ||
| 84 | + chip_version = "c200" | ||
| 85 | + compile_type = CompileType.COMPILE_TYPE_DEFAULT | ||
| 86 | + | ||
| 87 | + # Genrate Config | ||
| 88 | + initializer_config = InitializerConfig( | ||
| 89 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 90 | + ) | ||
| 91 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 92 | + pre_compile_type, | ||
| 93 | + set_default_code_channel, | ||
| 94 | + need_find_kernel_type, | ||
| 95 | + enable_kernel_type_mix_n, | ||
| 96 | + enable_kernel_type_mix, | ||
| 97 | + enable_simt, | ||
| 98 | + dump_size_multiples, | ||
| 99 | + chip_version, | ||
| 100 | + decode_mode_v310, | ||
| 101 | + ) | ||
| 102 | + code_generator_config = CodeGeneratorConfig( | ||
| 103 | + transform_kernel_type, | ||
| 104 | + dfx_gen_meta_info, | ||
| 105 | + dfx_param_byte_unit, | ||
| 106 | + need_clear_workspace, | ||
| 107 | + gen_code_for_l2_cache, | ||
| 108 | + write_back_overflow, | ||
| 109 | + needs_ffts, | ||
| 110 | + support_dci, | ||
| 111 | + support_raw_aic_only_dump_tensor, | ||
| 112 | + support_mix, | ||
| 113 | + dci_macro, | ||
| 114 | + gen_isolation_macro_type, | ||
| 115 | + cube_core_type_macro, | ||
| 116 | + vec_core_type_macro, | ||
| 117 | + support_workspace_offset, | ||
| 118 | + ) | ||
| 119 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 120 | + enable_vd, | ||
| 121 | + with_time_stamp_dynamic, | ||
| 122 | + with_time_stamp_static, | ||
| 123 | + tiling_format, | ||
| 124 | + macro_def, | ||
| 125 | + need_const_tiling_qualifier, | ||
| 126 | + ) | ||
| 127 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 128 | + compiler_path_o_level, | ||
| 129 | + self_defined_options, | ||
| 130 | + enable_sanitizer, | ||
| 131 | + enable_jump_expand, | ||
| 132 | + self_defined_debug_config, | ||
| 133 | + meta_info_options, | ||
| 134 | + gen_assembel, | ||
| 135 | + ) | ||
| 136 | + op_compiler_config = OpCompilerConfig( | ||
| 137 | + cube_core_type_macro, | ||
| 138 | + vec_core_type_macro, | ||
| 139 | + dfx_gen_meta_info, | ||
| 140 | + dfx_set_kernel_type_mix, | ||
| 141 | + dfx_set_kernel_type_aic, | ||
| 142 | + support_raw_aic_only_dump_tensor, | ||
| 143 | + chip_version, | ||
| 144 | + compile_type, | ||
| 145 | + ) | ||
| 146 | + kernel_compile_config = KernelCompilerConfig() | ||
| 147 | + super().__init__( | ||
| 148 | + initializer_config, | ||
| 149 | + compile_info_generator_config, | ||
| 150 | + tiling_info_generator_config, | ||
| 151 | + code_generator_config, | ||
| 152 | + op_compiler_config, | ||
| 153 | + kernel_compile_config, | ||
| 154 | + cmd_compiler_config, | ||
| 155 | + ) | ||
| 156 | + | ||
| @@ -0,0 +1,155 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend910 | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = False | ||
| 32 | + support_super_kernel = False | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_DEFAULT | ||
| 36 | + set_default_code_channel = True | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = False | ||
| 39 | + enable_kernel_type_mix = False | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "v100" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint64" | ||
| 50 | + macro_def = ["false", "__DAV_C100__", "false", "false", "true", "__DAV_C100__"] | ||
| 51 | + need_const_tiling_qualifier = False | ||
| 52 | + | ||
| 53 | + # Code Generator Config | ||
| 54 | + transform_kernel_type = False | ||
| 55 | + dfx_gen_meta_info = False | ||
| 56 | + dfx_param_byte_unit = False | ||
| 57 | + need_clear_workspace = True | ||
| 58 | + gen_code_for_l2_cache = False | ||
| 59 | + write_back_overflow = True | ||
| 60 | + needs_ffts = True | ||
| 61 | + support_dci = False | ||
| 62 | + support_raw_aic_only_dump_tensor = False | ||
| 63 | + support_mix = False | ||
| 64 | + dci_macro = "false" | ||
| 65 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_DEFAULT | ||
| 66 | + cube_core_type_macro = "__DAV_C100__" | ||
| 67 | + vec_core_type_macro = "__DAV_C100__" | ||
| 68 | + support_workspace_offset = False | ||
| 69 | + | ||
| 70 | + # Cmd Compiler Config | ||
| 71 | + compiler_path_o_level = "-O3" | ||
| 72 | + self_defined_options = [] | ||
| 73 | + enable_sanitizer = False | ||
| 74 | + enable_jump_expand = False | ||
| 75 | + self_defined_debug_config = [] | ||
| 76 | + meta_info_options = [] | ||
| 77 | + gen_assembel = False | ||
| 78 | + | ||
| 79 | + # Op Compiler Config | ||
| 80 | + dfx_set_kernel_type_mix = False | ||
| 81 | + dfx_set_kernel_type_aic = False | ||
| 82 | + support_raw_aic_only_dump_tensor = False | ||
| 83 | + chip_version = "v100" | ||
| 84 | + compile_type = CompileType.COMPILE_TYPE_DEFAULT | ||
| 85 | + | ||
| 86 | + # Genrate Config | ||
| 87 | + initializer_config = InitializerConfig( | ||
| 88 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 89 | + ) | ||
| 90 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 91 | + pre_compile_type, | ||
| 92 | + set_default_code_channel, | ||
| 93 | + need_find_kernel_type, | ||
| 94 | + enable_kernel_type_mix_n, | ||
| 95 | + enable_kernel_type_mix, | ||
| 96 | + enable_simt, | ||
| 97 | + dump_size_multiples, | ||
| 98 | + chip_version, | ||
| 99 | + decode_mode_v310, | ||
| 100 | + ) | ||
| 101 | + code_generator_config = CodeGeneratorConfig( | ||
| 102 | + transform_kernel_type, | ||
| 103 | + dfx_gen_meta_info, | ||
| 104 | + dfx_param_byte_unit, | ||
| 105 | + need_clear_workspace, | ||
| 106 | + gen_code_for_l2_cache, | ||
| 107 | + write_back_overflow, | ||
| 108 | + needs_ffts, | ||
| 109 | + support_dci, | ||
| 110 | + support_raw_aic_only_dump_tensor, | ||
| 111 | + support_mix, | ||
| 112 | + dci_macro, | ||
| 113 | + gen_isolation_macro_type, | ||
| 114 | + cube_core_type_macro, | ||
| 115 | + vec_core_type_macro, | ||
| 116 | + support_workspace_offset, | ||
| 117 | + ) | ||
| 118 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 119 | + enable_vd, | ||
| 120 | + with_time_stamp_dynamic, | ||
| 121 | + with_time_stamp_static, | ||
| 122 | + tiling_format, | ||
| 123 | + macro_def, | ||
| 124 | + need_const_tiling_qualifier, | ||
| 125 | + ) | ||
| 126 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 127 | + compiler_path_o_level, | ||
| 128 | + self_defined_options, | ||
| 129 | + enable_sanitizer, | ||
| 130 | + enable_jump_expand, | ||
| 131 | + self_defined_debug_config, | ||
| 132 | + meta_info_options, | ||
| 133 | + gen_assembel, | ||
| 134 | + ) | ||
| 135 | + op_compiler_config = OpCompilerConfig( | ||
| 136 | + cube_core_type_macro, | ||
| 137 | + vec_core_type_macro, | ||
| 138 | + dfx_gen_meta_info, | ||
| 139 | + dfx_set_kernel_type_mix, | ||
| 140 | + dfx_set_kernel_type_aic, | ||
| 141 | + support_raw_aic_only_dump_tensor, | ||
| 142 | + chip_version, | ||
| 143 | + compile_type, | ||
| 144 | + ) | ||
| 145 | + kernel_compile_config = KernelCompilerConfig() | ||
| 146 | + super().__init__( | ||
| 147 | + initializer_config, | ||
| 148 | + compile_info_generator_config, | ||
| 149 | + tiling_info_generator_config, | ||
| 150 | + code_generator_config, | ||
| 151 | + op_compiler_config, | ||
| 152 | + kernel_compile_config, | ||
| 153 | + cmd_compiler_config, | ||
| 154 | + ) | ||
| 155 | + | ||
| @@ -0,0 +1,173 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend910_93 | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = True | ||
| 32 | + support_super_kernel = True | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_MIX | ||
| 36 | + set_default_code_channel = False | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = True | ||
| 39 | + enable_kernel_type_mix = False | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "c220" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint64" | ||
| 50 | + macro_def = [ | ||
| 51 | + "defined(__DAV_C220_CUBE__)", | ||
| 52 | + "false", | ||
| 53 | + "false", | ||
| 54 | + "false", | ||
| 55 | + "true", | ||
| 56 | + "false", | ||
| 57 | + ] | ||
| 58 | + need_const_tiling_qualifier = False | ||
| 59 | + | ||
| 60 | + # Code Generator Config | ||
| 61 | + transform_kernel_type = False | ||
| 62 | + dfx_gen_meta_info = False | ||
| 63 | + dfx_param_byte_unit = True | ||
| 64 | + need_clear_workspace = True | ||
| 65 | + gen_code_for_l2_cache = True | ||
| 66 | + write_back_overflow = False | ||
| 67 | + needs_ffts = True | ||
| 68 | + support_dci = False | ||
| 69 | + support_raw_aic_only_dump_tensor = False | ||
| 70 | + support_mix = True | ||
| 71 | + dci_macro = "false" | ||
| 72 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_MIX | ||
| 73 | + cube_core_type_macro = "__DAV_C220_CUBE__" | ||
| 74 | + vec_core_type_macro = "__DAV_C220_VEC__" | ||
| 75 | + support_workspace_offset = False | ||
| 76 | + | ||
| 77 | + # Cmd Compiler Config | ||
| 78 | + compiler_path_o_level = "-O3" | ||
| 79 | + self_defined_options = [ | ||
| 80 | + "-mllvm", | ||
| 81 | + "-cce-aicore-stack-size=0x8000", | ||
| 82 | + "-mllvm", | ||
| 83 | + "-cce-aicore-function-stack-size=0x8000", | ||
| 84 | + "-mllvm", | ||
| 85 | + "-cce-aicore-record-overflow=false", | ||
| 86 | + "-mllvm", | ||
| 87 | + "-cce-aicore-addr-transform", | ||
| 88 | + "-mllvm", | ||
| 89 | + "-cce-aicore-dcci-insert-for-scalar=false", | ||
| 90 | + ] | ||
| 91 | + enable_sanitizer = True | ||
| 92 | + enable_jump_expand = False | ||
| 93 | + self_defined_debug_config = [] | ||
| 94 | + meta_info_options = [] | ||
| 95 | + gen_assembel = False | ||
| 96 | + | ||
| 97 | + # Op Compiler Config | ||
| 98 | + dfx_set_kernel_type_mix = True | ||
| 99 | + dfx_set_kernel_type_aic = False | ||
| 100 | + support_raw_aic_only_dump_tensor = False | ||
| 101 | + chip_version = "c220" | ||
| 102 | + compile_type = CompileType.COMPILE_TYPE_0 | ||
| 103 | + | ||
| 104 | + # Genrate Config | ||
| 105 | + initializer_config = InitializerConfig( | ||
| 106 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 107 | + ) | ||
| 108 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 109 | + pre_compile_type, | ||
| 110 | + set_default_code_channel, | ||
| 111 | + need_find_kernel_type, | ||
| 112 | + enable_kernel_type_mix_n, | ||
| 113 | + enable_kernel_type_mix, | ||
| 114 | + enable_simt, | ||
| 115 | + dump_size_multiples, | ||
| 116 | + chip_version, | ||
| 117 | + decode_mode_v310, | ||
| 118 | + ) | ||
| 119 | + code_generator_config = CodeGeneratorConfig( | ||
| 120 | + transform_kernel_type, | ||
| 121 | + dfx_gen_meta_info, | ||
| 122 | + dfx_param_byte_unit, | ||
| 123 | + need_clear_workspace, | ||
| 124 | + gen_code_for_l2_cache, | ||
| 125 | + write_back_overflow, | ||
| 126 | + needs_ffts, | ||
| 127 | + support_dci, | ||
| 128 | + support_raw_aic_only_dump_tensor, | ||
| 129 | + support_mix, | ||
| 130 | + dci_macro, | ||
| 131 | + gen_isolation_macro_type, | ||
| 132 | + cube_core_type_macro, | ||
| 133 | + vec_core_type_macro, | ||
| 134 | + support_workspace_offset, | ||
| 135 | + ) | ||
| 136 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 137 | + enable_vd, | ||
| 138 | + with_time_stamp_dynamic, | ||
| 139 | + with_time_stamp_static, | ||
| 140 | + tiling_format, | ||
| 141 | + macro_def, | ||
| 142 | + need_const_tiling_qualifier, | ||
| 143 | + ) | ||
| 144 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 145 | + compiler_path_o_level, | ||
| 146 | + self_defined_options, | ||
| 147 | + enable_sanitizer, | ||
| 148 | + enable_jump_expand, | ||
| 149 | + self_defined_debug_config, | ||
| 150 | + meta_info_options, | ||
| 151 | + gen_assembel, | ||
| 152 | + ) | ||
| 153 | + op_compiler_config = OpCompilerConfig( | ||
| 154 | + cube_core_type_macro, | ||
| 155 | + vec_core_type_macro, | ||
| 156 | + dfx_gen_meta_info, | ||
| 157 | + dfx_set_kernel_type_mix, | ||
| 158 | + dfx_set_kernel_type_aic, | ||
| 159 | + support_raw_aic_only_dump_tensor, | ||
| 160 | + chip_version, | ||
| 161 | + compile_type, | ||
| 162 | + ) | ||
| 163 | + kernel_compile_config = KernelCompilerConfig() | ||
| 164 | + super().__init__( | ||
| 165 | + initializer_config, | ||
| 166 | + compile_info_generator_config, | ||
| 167 | + tiling_info_generator_config, | ||
| 168 | + code_generator_config, | ||
| 169 | + op_compiler_config, | ||
| 170 | + kernel_compile_config, | ||
| 171 | + cmd_compiler_config, | ||
| 172 | + ) | ||
| 173 | + | ||
| @@ -0,0 +1,173 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend910b | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = True | ||
| 32 | + support_super_kernel = True | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_MIX | ||
| 36 | + set_default_code_channel = False | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = True | ||
| 39 | + enable_kernel_type_mix = False | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "c220" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint64" | ||
| 50 | + macro_def = [ | ||
| 51 | + "defined(__DAV_C220_CUBE__)", | ||
| 52 | + "false", | ||
| 53 | + "false", | ||
| 54 | + "false", | ||
| 55 | + "true", | ||
| 56 | + "false", | ||
| 57 | + ] | ||
| 58 | + need_const_tiling_qualifier = False | ||
| 59 | + | ||
| 60 | + # Code Generator Config | ||
| 61 | + transform_kernel_type = False | ||
| 62 | + dfx_gen_meta_info = False | ||
| 63 | + dfx_param_byte_unit = True | ||
| 64 | + need_clear_workspace = True | ||
| 65 | + gen_code_for_l2_cache = True | ||
| 66 | + write_back_overflow = False | ||
| 67 | + needs_ffts = True | ||
| 68 | + support_dci = False | ||
| 69 | + support_raw_aic_only_dump_tensor = False | ||
| 70 | + support_mix = True | ||
| 71 | + dci_macro = "false" | ||
| 72 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_MIX | ||
| 73 | + cube_core_type_macro = "__DAV_C220_CUBE__" | ||
| 74 | + vec_core_type_macro = "__DAV_C220_VEC__" | ||
| 75 | + support_workspace_offset = False | ||
| 76 | + | ||
| 77 | + # Cmd Compiler Config | ||
| 78 | + compiler_path_o_level = "-O3" | ||
| 79 | + self_defined_options = [ | ||
| 80 | + "-mllvm", | ||
| 81 | + "-cce-aicore-stack-size=0x8000", | ||
| 82 | + "-mllvm", | ||
| 83 | + "-cce-aicore-function-stack-size=0x8000", | ||
| 84 | + "-mllvm", | ||
| 85 | + "-cce-aicore-record-overflow=false", | ||
| 86 | + "-mllvm", | ||
| 87 | + "-cce-aicore-addr-transform", | ||
| 88 | + "-mllvm", | ||
| 89 | + "-cce-aicore-dcci-insert-for-scalar=false", | ||
| 90 | + ] | ||
| 91 | + enable_sanitizer = True | ||
| 92 | + enable_jump_expand = False | ||
| 93 | + self_defined_debug_config = [] | ||
| 94 | + meta_info_options = [] | ||
| 95 | + gen_assembel = False | ||
| 96 | + | ||
| 97 | + # Op Compiler Config | ||
| 98 | + dfx_set_kernel_type_mix = True | ||
| 99 | + dfx_set_kernel_type_aic = False | ||
| 100 | + support_raw_aic_only_dump_tensor = False | ||
| 101 | + chip_version = "c220" | ||
| 102 | + compile_type = CompileType.COMPILE_TYPE_0 | ||
| 103 | + | ||
| 104 | + # Genrate Config | ||
| 105 | + initializer_config = InitializerConfig( | ||
| 106 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 107 | + ) | ||
| 108 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 109 | + pre_compile_type, | ||
| 110 | + set_default_code_channel, | ||
| 111 | + need_find_kernel_type, | ||
| 112 | + enable_kernel_type_mix_n, | ||
| 113 | + enable_kernel_type_mix, | ||
| 114 | + enable_simt, | ||
| 115 | + dump_size_multiples, | ||
| 116 | + chip_version, | ||
| 117 | + decode_mode_v310, | ||
| 118 | + ) | ||
| 119 | + code_generator_config = CodeGeneratorConfig( | ||
| 120 | + transform_kernel_type, | ||
| 121 | + dfx_gen_meta_info, | ||
| 122 | + dfx_param_byte_unit, | ||
| 123 | + need_clear_workspace, | ||
| 124 | + gen_code_for_l2_cache, | ||
| 125 | + write_back_overflow, | ||
| 126 | + needs_ffts, | ||
| 127 | + support_dci, | ||
| 128 | + support_raw_aic_only_dump_tensor, | ||
| 129 | + support_mix, | ||
| 130 | + dci_macro, | ||
| 131 | + gen_isolation_macro_type, | ||
| 132 | + cube_core_type_macro, | ||
| 133 | + vec_core_type_macro, | ||
| 134 | + support_workspace_offset, | ||
| 135 | + ) | ||
| 136 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 137 | + enable_vd, | ||
| 138 | + with_time_stamp_dynamic, | ||
| 139 | + with_time_stamp_static, | ||
| 140 | + tiling_format, | ||
| 141 | + macro_def, | ||
| 142 | + need_const_tiling_qualifier, | ||
| 143 | + ) | ||
| 144 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 145 | + compiler_path_o_level, | ||
| 146 | + self_defined_options, | ||
| 147 | + enable_sanitizer, | ||
| 148 | + enable_jump_expand, | ||
| 149 | + self_defined_debug_config, | ||
| 150 | + meta_info_options, | ||
| 151 | + gen_assembel, | ||
| 152 | + ) | ||
| 153 | + op_compiler_config = OpCompilerConfig( | ||
| 154 | + cube_core_type_macro, | ||
| 155 | + vec_core_type_macro, | ||
| 156 | + dfx_gen_meta_info, | ||
| 157 | + dfx_set_kernel_type_mix, | ||
| 158 | + dfx_set_kernel_type_aic, | ||
| 159 | + support_raw_aic_only_dump_tensor, | ||
| 160 | + chip_version, | ||
| 161 | + compile_type, | ||
| 162 | + ) | ||
| 163 | + kernel_compile_config = KernelCompilerConfig() | ||
| 164 | + super().__init__( | ||
| 165 | + initializer_config, | ||
| 166 | + compile_info_generator_config, | ||
| 167 | + tiling_info_generator_config, | ||
| 168 | + code_generator_config, | ||
| 169 | + op_compiler_config, | ||
| 170 | + kernel_compile_config, | ||
| 171 | + cmd_compiler_config, | ||
| 172 | + ) | ||
| 173 | + | ||
| @@ -0,0 +1,173 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig ascend950 | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = False | ||
| 31 | + is_support_dfx = True | ||
| 32 | + support_super_kernel = True | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_MIX | ||
| 36 | + set_default_code_channel = False | ||
| 37 | + need_find_kernel_type = True | ||
| 38 | + enable_kernel_type_mix_n = True | ||
| 39 | + enable_kernel_type_mix = False | ||
| 40 | + enable_simt = False | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "c220" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = True | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint64" | ||
| 50 | + macro_def = [ | ||
| 51 | + "defined(__DAV_C220_CUBE__)", | ||
| 52 | + "false", | ||
| 53 | + "false", | ||
| 54 | + "false", | ||
| 55 | + "true", | ||
| 56 | + "false", | ||
| 57 | + ] | ||
| 58 | + need_const_tiling_qualifier = False | ||
| 59 | + | ||
| 60 | + # Code Generator Config | ||
| 61 | + transform_kernel_type = False | ||
| 62 | + dfx_gen_meta_info = False | ||
| 63 | + dfx_param_byte_unit = True | ||
| 64 | + need_clear_workspace = True | ||
| 65 | + gen_code_for_l2_cache = True | ||
| 66 | + write_back_overflow = False | ||
| 67 | + needs_ffts = True | ||
| 68 | + support_dci = False | ||
| 69 | + support_raw_aic_only_dump_tensor = False | ||
| 70 | + support_mix = True | ||
| 71 | + dci_macro = "false" | ||
| 72 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_MIX | ||
| 73 | + cube_core_type_macro = "__DAV_C220_CUBE__" | ||
| 74 | + vec_core_type_macro = "__DAV_C220_VEC__" | ||
| 75 | + support_workspace_offset = False | ||
| 76 | + | ||
| 77 | + # Cmd Compiler Config | ||
| 78 | + compiler_path_o_level = "-O3" | ||
| 79 | + self_defined_options = [ | ||
| 80 | + "-mllvm", | ||
| 81 | + "-cce-aicore-stack-size=0x8000", | ||
| 82 | + "-mllvm", | ||
| 83 | + "-cce-aicore-function-stack-size=0x8000", | ||
| 84 | + "-mllvm", | ||
| 85 | + "-cce-aicore-record-overflow=false", | ||
| 86 | + "-mllvm", | ||
| 87 | + "-cce-aicore-addr-transform", | ||
| 88 | + "-mllvm", | ||
| 89 | + "-cce-aicore-dcci-insert-for-scalar=false", | ||
| 90 | + ] | ||
| 91 | + enable_sanitizer = True | ||
| 92 | + enable_jump_expand = False | ||
| 93 | + self_defined_debug_config = [] | ||
| 94 | + meta_info_options = [] | ||
| 95 | + gen_assembel = False | ||
| 96 | + | ||
| 97 | + # Op Compiler Config | ||
| 98 | + dfx_set_kernel_type_mix = True | ||
| 99 | + dfx_set_kernel_type_aic = False | ||
| 100 | + support_raw_aic_only_dump_tensor = False | ||
| 101 | + chip_version = "c220" | ||
| 102 | + compile_type = CompileType.COMPILE_TYPE_0 | ||
| 103 | + | ||
| 104 | + # Genrate Config | ||
| 105 | + initializer_config = InitializerConfig( | ||
| 106 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 107 | + ) | ||
| 108 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 109 | + pre_compile_type, | ||
| 110 | + set_default_code_channel, | ||
| 111 | + need_find_kernel_type, | ||
| 112 | + enable_kernel_type_mix_n, | ||
| 113 | + enable_kernel_type_mix, | ||
| 114 | + enable_simt, | ||
| 115 | + dump_size_multiples, | ||
| 116 | + chip_version, | ||
| 117 | + decode_mode_v310, | ||
| 118 | + ) | ||
| 119 | + code_generator_config = CodeGeneratorConfig( | ||
| 120 | + transform_kernel_type, | ||
| 121 | + dfx_gen_meta_info, | ||
| 122 | + dfx_param_byte_unit, | ||
| 123 | + need_clear_workspace, | ||
| 124 | + gen_code_for_l2_cache, | ||
| 125 | + write_back_overflow, | ||
| 126 | + needs_ffts, | ||
| 127 | + support_dci, | ||
| 128 | + support_raw_aic_only_dump_tensor, | ||
| 129 | + support_mix, | ||
| 130 | + dci_macro, | ||
| 131 | + gen_isolation_macro_type, | ||
| 132 | + cube_core_type_macro, | ||
| 133 | + vec_core_type_macro, | ||
| 134 | + support_workspace_offset, | ||
| 135 | + ) | ||
| 136 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 137 | + enable_vd, | ||
| 138 | + with_time_stamp_dynamic, | ||
| 139 | + with_time_stamp_static, | ||
| 140 | + tiling_format, | ||
| 141 | + macro_def, | ||
| 142 | + need_const_tiling_qualifier, | ||
| 143 | + ) | ||
| 144 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 145 | + compiler_path_o_level, | ||
| 146 | + self_defined_options, | ||
| 147 | + enable_sanitizer, | ||
| 148 | + enable_jump_expand, | ||
| 149 | + self_defined_debug_config, | ||
| 150 | + meta_info_options, | ||
| 151 | + gen_assembel, | ||
| 152 | + ) | ||
| 153 | + op_compiler_config = OpCompilerConfig( | ||
| 154 | + cube_core_type_macro, | ||
| 155 | + vec_core_type_macro, | ||
| 156 | + dfx_gen_meta_info, | ||
| 157 | + dfx_set_kernel_type_mix, | ||
| 158 | + dfx_set_kernel_type_aic, | ||
| 159 | + support_raw_aic_only_dump_tensor, | ||
| 160 | + chip_version, | ||
| 161 | + compile_type, | ||
| 162 | + ) | ||
| 163 | + kernel_compile_config = KernelCompilerConfig() | ||
| 164 | + super().__init__( | ||
| 165 | + initializer_config, | ||
| 166 | + compile_info_generator_config, | ||
| 167 | + tiling_info_generator_config, | ||
| 168 | + code_generator_config, | ||
| 169 | + op_compiler_config, | ||
| 170 | + kernel_compile_config, | ||
| 171 | + cmd_compiler_config, | ||
| 172 | + ) | ||
| 173 | + | ||
| @@ -0,0 +1,170 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +ArchRuntimeConfig mc62cm12a | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.config.run_settings import RuntimeConfig | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +class ArchRuntimeConfig(RuntimeConfig): | ||
| 28 | + def __init__(self): | ||
| 29 | + # Initialize Config | ||
| 30 | + support_impl_mode = True | ||
| 31 | + is_support_dfx = False | ||
| 32 | + support_super_kernel = False | ||
| 33 | + | ||
| 34 | + # Compile Info Generator Config | ||
| 35 | + pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_MIX_COUPLING | ||
| 36 | + set_default_code_channel = True | ||
| 37 | + need_find_kernel_type = False | ||
| 38 | + enable_kernel_type_mix_n = False | ||
| 39 | + enable_kernel_type_mix = False | ||
| 40 | + enable_simt = True | ||
| 41 | + dump_size_multiples = 75 | ||
| 42 | + chip_version = "m510" | ||
| 43 | + decode_mode_v310 = False | ||
| 44 | + | ||
| 45 | + # Tiling Info Generator Config | ||
| 46 | + enable_vd = False | ||
| 47 | + with_time_stamp_dynamic = False | ||
| 48 | + with_time_stamp_static = True | ||
| 49 | + tiling_format = "uint64" | ||
| 50 | + macro_def = ["false", "false", "false", "__NPU_ARCH__ == 5102", "true", "false"] | ||
| 51 | + need_const_tiling_qualifier = False | ||
| 52 | + | ||
| 53 | + # Code Generator Config | ||
| 54 | + transform_kernel_type = False | ||
| 55 | + dfx_gen_meta_info = False | ||
| 56 | + dfx_param_byte_unit = False | ||
| 57 | + need_clear_workspace = True | ||
| 58 | + gen_code_for_l2_cache = False | ||
| 59 | + write_back_overflow = False | ||
| 60 | + needs_ffts = False | ||
| 61 | + support_dci = True | ||
| 62 | + support_raw_aic_only_dump_tensor = False | ||
| 63 | + support_mix = False | ||
| 64 | + dci_macro = "(__NPU_ARCH__ == 5102)" | ||
| 65 | + gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_DEFAULT | ||
| 66 | + | ||
| 67 | + cube_core_type_macro = "__DAV_M200__" | ||
| 68 | + vec_core_type_macro = "__DAV_M200_VEC__" | ||
| 69 | + support_workspace_offset = True | ||
| 70 | + | ||
| 71 | + # Cmd Compiler Config | ||
| 72 | + compiler_path_o_level = "-O3" | ||
| 73 | + self_defined_options = [ | ||
| 74 | + "-D__DAV_C310__", | ||
| 75 | + "-mllvm", | ||
| 76 | + "-cce-aicore-stack-size=0x8000", | ||
| 77 | + "-mllvm", | ||
| 78 | + "-cce-aicore-function-stack-size=0x8000", | ||
| 79 | + "-mllvm", | ||
| 80 | + "-cce-aicore-record-overflow=false", | ||
| 81 | + "-mllvm", | ||
| 82 | + "-cce-aicore-addr-transform", | ||
| 83 | + "-mllvm", | ||
| 84 | + "--cce-aicore-jump-expand=true", | ||
| 85 | + "-mllvm", | ||
| 86 | + "-cce-aicore-dcci-insert-for-scalar=false", | ||
| 87 | + ] | ||
| 88 | + enable_sanitizer = True | ||
| 89 | + enable_jump_expand = False | ||
| 90 | + self_defined_debug_config = [] | ||
| 91 | + meta_info_options = [] | ||
| 92 | + gen_assembel = False | ||
| 93 | + | ||
| 94 | + # Op Compiler Config | ||
| 95 | + dfx_set_kernel_type_mix = False | ||
| 96 | + dfx_set_kernel_type_aic = False | ||
| 97 | + support_raw_aic_only_dump_tensor = False | ||
| 98 | + chip_version = "m510" | ||
| 99 | + compile_type = CompileType.COMPILE_TYPE_1 | ||
| 100 | + | ||
| 101 | + # Genrate Config | ||
| 102 | + initializer_config = InitializerConfig( | ||
| 103 | + support_impl_mode, is_support_dfx, support_super_kernel | ||
| 104 | + ) | ||
| 105 | + compile_info_generator_config = CompileInfoGeneratorConfig( | ||
| 106 | + pre_compile_type, | ||
| 107 | + set_default_code_channel, | ||
| 108 | + need_find_kernel_type, | ||
| 109 | + enable_kernel_type_mix_n, | ||
| 110 | + enable_kernel_type_mix, | ||
| 111 | + enable_simt, | ||
| 112 | + dump_size_multiples, | ||
| 113 | + chip_version, | ||
| 114 | + decode_mode_v310, | ||
| 115 | + ) | ||
| 116 | + code_generator_config = CodeGeneratorConfig( | ||
| 117 | + transform_kernel_type, | ||
| 118 | + dfx_gen_meta_info, | ||
| 119 | + dfx_param_byte_unit, | ||
| 120 | + need_clear_workspace, | ||
| 121 | + gen_code_for_l2_cache, | ||
| 122 | + write_back_overflow, | ||
| 123 | + needs_ffts, | ||
| 124 | + support_dci, | ||
| 125 | + support_raw_aic_only_dump_tensor, | ||
| 126 | + support_mix, | ||
| 127 | + dci_macro, | ||
| 128 | + gen_isolation_macro_type, | ||
| 129 | + cube_core_type_macro, | ||
| 130 | + vec_core_type_macro, | ||
| 131 | + support_workspace_offset, | ||
| 132 | + ) | ||
| 133 | + tiling_info_generator_config = TilingInfoGeneratorConfig( | ||
| 134 | + enable_vd, | ||
| 135 | + with_time_stamp_dynamic, | ||
| 136 | + with_time_stamp_static, | ||
| 137 | + tiling_format, | ||
| 138 | + macro_def, | ||
| 139 | + need_const_tiling_qualifier, | ||
| 140 | + ) | ||
| 141 | + cmd_compiler_config = CmdCompilerConfig( | ||
| 142 | + compiler_path_o_level, | ||
| 143 | + self_defined_options, | ||
| 144 | + enable_sanitizer, | ||
| 145 | + enable_jump_expand, | ||
| 146 | + self_defined_debug_config, | ||
| 147 | + meta_info_options, | ||
| 148 | + gen_assembel, | ||
| 149 | + ) | ||
| 150 | + op_compiler_config = OpCompilerConfig( | ||
| 151 | + cube_core_type_macro, | ||
| 152 | + vec_core_type_macro, | ||
| 153 | + dfx_gen_meta_info, | ||
| 154 | + dfx_set_kernel_type_mix, | ||
| 155 | + dfx_set_kernel_type_aic, | ||
| 156 | + support_raw_aic_only_dump_tensor, | ||
| 157 | + chip_version, | ||
| 158 | + compile_type, | ||
| 159 | + ) | ||
| 160 | + kernel_compile_config = KernelCompilerConfig() | ||
| 161 | + super().__init__( | ||
| 162 | + initializer_config, | ||
| 163 | + compile_info_generator_config, | ||
| 164 | + tiling_info_generator_config, | ||
| 165 | + code_generator_config, | ||
| 166 | + op_compiler_config, | ||
| 167 | + kernel_compile_config, | ||
| 168 | + cmd_compiler_config, | ||
| 169 | + ) | ||
| 170 | + | ||
| @@ -0,0 +1,103 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +run_settings | ||
| 14 | +""" | ||
| 15 | + | ||
| 16 | +from asc_op_compile_base.asc_op_compiler.ascendc_constants import PreCompileType, CompileType, IsolationMacroType | ||
| 17 | +from asc_op_compile_base.asc_op_compiler.generator.initialize import InitializerConfig | ||
| 18 | +from asc_op_compile_base.asc_op_compiler.generator.compile_info_generator import CompileInfoGeneratorConfig | ||
| 19 | +from asc_op_compile_base.asc_op_compiler.generator.tiling_info_generator import TilingInfoGeneratorConfig | ||
| 20 | +from asc_op_compile_base.asc_op_compiler.generator.code_generator import CodeGeneratorConfig | ||
| 21 | +from asc_op_compile_base.asc_op_compiler.generator.op_compiler import OpCompilerConfig | ||
| 22 | +from asc_op_compile_base.asc_op_compiler.generator.kernel_compiler import KernelCompilerConfig | ||
| 23 | +from asc_op_compile_base.asc_op_compiler.generator.cmd_compiler import CmdCompilerConfig | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +class RuntimeConfig: | ||
| 27 | + def __init__( | ||
| 28 | + self, | ||
| 29 | + initializer_config: InitializerConfig = None, | ||
| 30 | + compile_info_generator_config: CompileInfoGeneratorConfig = None, | ||
| 31 | + tiling_info_generator_config: TilingInfoGeneratorConfig = None, | ||
| 32 | + code_generator_config: CodeGeneratorConfig = None, | ||
| 33 | + op_compiler_config: OpCompilerConfig = None, | ||
| 34 | + kernel_compile_config: KernelCompilerConfig = None, | ||
| 35 | + cmd_compiler_config: CmdCompilerConfig = None, | ||
| 36 | + ): | ||
| 37 | + # Initialize Config | ||
| 38 | + self.support_impl_mode = False | ||
| 39 | + self.is_support_dfx = False | ||
| 40 | + self.support_super_kernel = False | ||
| 41 | + | ||
| 42 | + # Compile Info Genrator Config | ||
| 43 | + self.pre_compile_type = PreCompileType.PRE_COMPILE_KERNEL_DEFAULT | ||
| 44 | + self.set_default_code_channel = True | ||
| 45 | + self.need_find_kernel_type = True | ||
| 46 | + self.enable_kernel_type_mix_n = False | ||
| 47 | + self.enable_kernel_type_mix = False | ||
| 48 | + self.enable_simt = False | ||
| 49 | + self.dump_size_multiples = 75 | ||
| 50 | + self.chip_version = "c220" | ||
| 51 | + self.decode_mode_v310 = False | ||
| 52 | + | ||
| 53 | + # Tiling Info Generator Config | ||
| 54 | + self.enable_vd = False | ||
| 55 | + self.with_time_stamp_dynamic = True | ||
| 56 | + self.with_time_stamp_static = True | ||
| 57 | + self.tiling_format = "uint8" | ||
| 58 | + self.macro_def = ["", "", "", "", "", ""] | ||
| 59 | + self.need_const_tiling_qualifier = False | ||
| 60 | + | ||
| 61 | + # Code Generator Config | ||
| 62 | + self.transform_kernel_type = False | ||
| 63 | + self.dfx_gen_meta_info = False | ||
| 64 | + self.dfx_param_byte_unit = False | ||
| 65 | + self.need_clear_workspace = True | ||
| 66 | + self.gen_code_for_l2_cache = False | ||
| 67 | + self.write_back_overflow = False | ||
| 68 | + self.needs_ffts = False | ||
| 69 | + self.support_dci = False | ||
| 70 | + self.support_raw_aic_only_dump_tensor = False | ||
| 71 | + self.support_mix = False | ||
| 72 | + self.dci_macro = "false" | ||
| 73 | + self.gen_isolation_macro_type = IsolationMacroType.ISOLATION_MACRO_MIX | ||
| 74 | + self.support_workspace_offset = False | ||
| 75 | + | ||
| 76 | + # Cmd Compiler Config | ||
| 77 | + self.compiler_path_o_level = "-O3" | ||
| 78 | + self.self_defined_options = [] | ||
| 79 | + self.enable_sanitizer = True | ||
| 80 | + self.enable_jump_expand = False | ||
| 81 | + self.self_defined_debug_config = [] | ||
| 82 | + self.meta_info_options = [] | ||
| 83 | + self.gen_assembel = False | ||
| 84 | + | ||
| 85 | + # Op Compiler Config | ||
| 86 | + self.cube_core_type_macro = "__DAV_M200__" | ||
| 87 | + self.vec_core_type_macro = "__DAV_M200_VEC__" | ||
| 88 | + self.dfx_gen_meta_info = False | ||
| 89 | + self.dfx_set_kernel_type_mix = False | ||
| 90 | + self.dfx_set_kernel_type_aic = False | ||
| 91 | + self.support_raw_aic_only_dump_tensor = False | ||
| 92 | + self.chip_version = "c220" | ||
| 93 | + self.compile_type = CompileType.COMPILE_TYPE_DEFAULT | ||
| 94 | + # Kernel Compiler Config | ||
| 95 | + | ||
| 96 | + # Init Config | ||
| 97 | + self.initializer_config = initializer_config | ||
| 98 | + self.compile_info_generator_config = compile_info_generator_config | ||
| 99 | + self.tiling_info_generator_config = tiling_info_generator_config | ||
| 100 | + self.code_generator_config = code_generator_config | ||
| 101 | + self.op_compiler_config = op_compiler_config | ||
| 102 | + self.kernel_compile_config = kernel_compile_config | ||
| 103 | + self.cmd_compiler_config = cmd_compiler_config | ||
| @@ -0,0 +1,33 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +class CmdCompilerConfig: | ||
| 14 | + def __init__(self, compiler_path_o_level, self_defined_options, enable_sanitizer, enable_jump_expand, \ | ||
| 15 | + self_defined_debug_config, meta_info_options, gen_assembel): | ||
| 16 | + self.compiler_path_o_level = compiler_path_o_level | ||
| 17 | + self.self_defined_options = self_defined_options | ||
| 18 | + self.enable_sanitizer = enable_sanitizer | ||
| 19 | + self.enable_jump_expand = enable_jump_expand | ||
| 20 | + self.self_defined_debug_config = self_defined_debug_config | ||
| 21 | + self.meta_info_options = meta_info_options | ||
| 22 | + self.gen_assembel = gen_assembel | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +class CmdCompilerParams: | ||
| 26 | + def __init__(self): | ||
| 27 | + pass | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +class CmdCompiler: | ||
| 31 | + def __init__(self, params: CmdCompilerParams, config: CmdCompilerConfig): | ||
| 32 | + pass | ||
| 33 | + | ||
| @@ -0,0 +1,46 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | + | ||
| 14 | +class CodeGeneratorConfig: | ||
| 15 | + def __init__(self, transform_kernel_type, dfx_gen_meta_info, dfx_param_byte_unit, \ | ||
| 16 | + need_clear_workspace, gen_code_for_l2_cache, write_back_overflow, needs_ffts, \ | ||
| 17 | + support_dci, support_raw_aic_only_dump_tensor, support_mix, dci_macro, \ | ||
| 18 | + gen_isolation_macro_type, cube_core_type_macro, vec_core_type_macro, support_workspace_offset): | ||
| 19 | + self.transform_kernel_type = transform_kernel_type | ||
| 20 | + self.dfx_gen_meta_info = dfx_gen_meta_info | ||
| 21 | + self.dfx_param_byte_unit = dfx_param_byte_unit | ||
| 22 | + self.need_clear_workspace = need_clear_workspace | ||
| 23 | + self.gen_code_for_l2_cache = gen_code_for_l2_cache | ||
| 24 | + self.write_back_overflow = write_back_overflow | ||
| 25 | + self.needs_ffts = need_ffts | ||
| 26 | + self.support_dci = support_dci | ||
| 27 | + self.support_raw_aic_only_dump_tensor = support_raw_aic_only_dump_tensor | ||
| 28 | + self.support_mix = support_mix | ||
| 29 | + self.dci_macro = dci_macro | ||
| 30 | + self.gen_isolation_macro_type = gen_isolation_macro_type | ||
| 31 | + self.cube_core_type_macro = cube_core_type_macro | ||
| 32 | + self.vec_core_type_macro = vec_core_type_macro | ||
| 33 | + self.support_workspace_offset = support_workspace_offset | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +class CodeGeneratorParams: | ||
| 37 | + def __init__(self, compile_info, op_info, compile_option_tuple, tiling_info, configuration, kernel_func_name): | ||
| 38 | + pass | ||
| 39 | + | ||
| 40 | + | ||
| 41 | +class CodeGenerator: | ||
| 42 | + def __init__(self, params: CodeGeneratorParams, config: CodeGeneratorConfig): | ||
| 43 | + pass | ||
| 44 | + | ||
| 45 | + def generate(self): | ||
| 46 | + pass | ||
| @@ -0,0 +1,49 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +from ..ascendc_constants import InferChannelParams | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +class CompileInfoGeneratorConfig: | ||
| 16 | + def __init__(self, pre_compile_type, set_default_code_channel, need_find_kernel_type, \ | ||
| 17 | + enable_kernel_type_mix_n, enable_kernel_type_mix, enable_simt, dump_size_multiples, \ | ||
| 18 | + chip_version, decode_mode_v310): | ||
| 19 | + self.pre_compile_type = pre_compile_type | ||
| 20 | + self.set_default_code_channel = set_default_code_channel | ||
| 21 | + self.need_find_kernel_type = need_find_kernel_type | ||
| 22 | + self.enable_kernel_type_mix_n = enable_kernel_type_mix_n | ||
| 23 | + self.enable_kernel_type_mix = enable_kernel_type_mix | ||
| 24 | + self.enable_simt = enable_simt | ||
| 25 | + self.dump_size_multiples = dump_size_multiples | ||
| 26 | + self.chip_version = chip_version | ||
| 27 | + self.decode_mode_v310 = decode_mode_v310 | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +class CompileInfoGeneratorParams: | ||
| 31 | + def __init__(self, kernel_file, kernel_func_name, op_info, compile_option_tuple, cmd_compiler): | ||
| 32 | + pass | ||
| 33 | + | ||
| 34 | + | ||
| 35 | +class CompileInfoGenerator(object): | ||
| 36 | + def __init__(self, params: CompileInfoGeneratorParams, config: CompileInfoGeneratorConfig): | ||
| 37 | + pass | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + def collect_by_precompile(self): | ||
| 41 | + pass | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + def get_compile_info(self): | ||
| 45 | + pass | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + def collect_by_tiling_compile(self, configuration, tiling_info): | ||
| 49 | + pass | ||
| @@ -0,0 +1,33 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +from ..ascendc_constants import CompileOptionTuple | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +class InitializerConfig: | ||
| 16 | + def __init__(self, support_impl_mode: bool, is_support_dfx: bool, support_super_kernel: bool): | ||
| 17 | + self.support_impl_mode = support_impl_mode | ||
| 18 | + self.is_support_dfx = is_support_dfx | ||
| 19 | + self.support_super_kernel = support_super_kernel | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +class InitializerParams: | ||
| 23 | + def __init__(self, kernel_file, origin_func_name, op_info, compile_option_tuple, code_channel, | ||
| 24 | + op_compile_option, extend_options): | ||
| 25 | + pass | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +class Initializer(object): | ||
| 29 | + def __init__(self, params: InitializerParams, config: InitializerConfig): | ||
| 30 | + pass | ||
| 31 | + | ||
| 32 | + def initialize(self): | ||
| 33 | + pass | ||
| @@ -0,0 +1,25 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +class KernelCompilerConfig: | ||
| 13 | + def __init__(self): | ||
| 14 | + pass | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +class KernelCompilerParams: | ||
| 18 | + def __init__(self): | ||
| 19 | + pass | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +class KernelCompiler: | ||
| 23 | + def __init__(self): | ||
| 24 | + pass | ||
| 25 | + | ||
| @@ -0,0 +1,46 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +from ..ascendc_constants import KernelMetaType | ||
| 14 | +from ..ascendc_common_utility import CompileInfo | ||
| 15 | +from ..ascendc_compile_base import SingleTilingKeyCompileParams | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +class OpCompilerConfig: | ||
| 19 | + def __init__(self, cube_core_type_macro, vec_core_type_macro, dfx_gen_meta_info, dfx_set_kernel_type_mix, | ||
| 20 | + dfx_set_kernel_type_aic, support_raw_aic_only_dump_tensor, chip_version, compile_type): | ||
| 21 | + self.cube_core_type_macro = cube_core_type_macro | ||
| 22 | + self.vec_core_type_macro = vec_core_type_macro | ||
| 23 | + self.dfx_gen_meta_info = dfx_gen_meta_info | ||
| 24 | + self.dfx_set_kernel_type_mix = dfx_set_kernel_type_mix | ||
| 25 | + self.dfx_set_kernel_type_aic = dfx_set_kernel_type_aic | ||
| 26 | + self.support_raw_aic_only_dump_tensor = support_raw_aic_only_dump_tensor | ||
| 27 | + self.chip_version = chip_version | ||
| 28 | + self.compile_type = compile_type | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +class OpCompilerParams: | ||
| 32 | + def __init__(self, compile_info, op_info, compile_option_tuple, tiling_info, cmd_compiler): | ||
| 33 | + pass | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +class OpCompiler: | ||
| 37 | + def __init__(self, params: OpCompilerParams, config: OpCompilerConfig): | ||
| 38 | + pass | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + def run(self): | ||
| 42 | + pass | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + def post_process(self): | ||
| 46 | + pass | ||
| @@ -0,0 +1,42 @@ | |||
| 1 | +#!/usr/bin/python | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ---------------------------------------------------------------------------------------------------------- | ||
| 4 | +# Copyright (c) 2025 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 | +from ..get_op_tiling import OpInfo | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +class TilingInfoGeneratorConfig: | ||
| 16 | + def __init__(self, | ||
| 17 | + enable_vd: bool, | ||
| 18 | + with_time_stamp_dynamic: bool, | ||
| 19 | + with_time_stamp_static: bool, | ||
| 20 | + tiling_format, | ||
| 21 | + macro_def, | ||
| 22 | + need_const_tiling_qualifier, | ||
| 23 | + ): | ||
| 24 | + self.enable_vd = enable_vd | ||
| 25 | + self.with_time_stamp_dynamic = with_time_stamp_dynamic | ||
| 26 | + self.with_time_stamp_static = with_time_stamp_static | ||
| 27 | + self.tiling_format = tiling_format | ||
| 28 | + self.macro_def = macro_def | ||
| 29 | + self.need_const_tiling_qualifier = need_const_tiling_qualifier | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +class TilingInfoGeneratorParams: | ||
| 33 | + def __init__(self, op_info, configuration, extend_options): | ||
| 34 | + pass | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +class TilingInfoGenerator(object): | ||
| 38 | + def __init__(self, params: TilingInfoGeneratorParams, config: TilingInfoGeneratorConfig): | ||
| 39 | + pass | ||
| 40 | + | ||
| 41 | + def parse(self): | ||
| 42 | + pass | ||
| @@ -155,7 +155,7 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg) | |||
| 155 | for (char c : curSocVersion) { | 155 | for (char c : curSocVersion) { |
| 156 | lowerCurSocVersion += std::tolower(c); | 156 | lowerCurSocVersion += std::tolower(c); |
| 157 | } | 157 | } |
| 158 | - // ascend950 | 158 | + // ascend950 |
| 159 | if (AscendCheckSoC950Version(lowerCurSocVersion.c_str())) { | 159 | if (AscendCheckSoC950Version(lowerCurSocVersion.c_str())) { |
| 160 | return true; | 160 | return true; |
| 161 | } | 161 | } |
| @@ -207,13 +207,14 @@ static SocVersion GetSocVersion() { | |||
| 207 | ASCENDLOGE("aclrtGetSocName failed\n"); | 207 | ASCENDLOGE("aclrtGetSocName failed\n"); |
| 208 | return SocVersion::UNKNOWN; | 208 | return SocVersion::UNKNOWN; |
| 209 | } | 209 | } |
| 210 | - if (std::strncmp(socName, "Ascend310P", 10) == 0) { | 210 | + if (std::strncmp(socName, "Ascend310P", sizeof("Ascend310P") - 1) == 0) { |
| 211 | return SocVersion::ASCEND310P; | 211 | return SocVersion::ASCEND310P; |
| 212 | } | 212 | } |
| 213 | - if (std::strncmp(socName, "Ascend910B", 10) == 0) { | 213 | + if (std::strncmp(socName, "Ascend910B", sizeof("Ascend910B") - 1) == 0 || |
| 214 | + std::strncmp(socName, "Ascend910_93", sizeof("Ascend910_93") - 1) == 0) { | ||
| 214 | return SocVersion::ASCEND910B; | 215 | return SocVersion::ASCEND910B; |
| 215 | } | 216 | } |
| 216 | - if (std::strncmp(socName, "Ascend950", 12) == 0) { | 217 | + if (std::strncmp(socName, "Ascend950", sizeof("Ascend950") - 1) == 0) { |
| 217 | return SocVersion::ASCEND950; | 218 | return SocVersion::ASCEND950; |
| 218 | } | 219 | } |
| 219 | ASCENDLOGE("unsupport soc name: %s\n", socName); | 220 | ASCENDLOGE("unsupport soc name: %s\n", socName); |