已合并
soc整改math仓common同步到非dev仓 #802
chenfeng创建于 1月20日
soc整改math仓common同步到非dev仓 #802
已合并
共 4 个文件变更+27-19
| @@ -26,6 +26,7 @@ target_include_directories(${COMMON_NAME}_obj | |||
| 26 | ${PLATFORM_INC_DIRS} | 26 | ${PLATFORM_INC_DIRS} |
| 27 | ${METADEF_INCLUDE_DIRS} | 27 | ${METADEF_INCLUDE_DIRS} |
| 28 | ${OPS_MATH_DIR}/common/inc | 28 | ${OPS_MATH_DIR}/common/inc |
| 29 | + ${ASCEND_DIR}/pkg_inc | ||
| 29 | ) | 30 | ) |
| 30 | 31 | ||
| 31 | target_link_libraries(${COMMON_NAME}_obj | 32 | target_link_libraries(${COMMON_NAME}_obj |
| @@ -39,4 +40,4 @@ foreach(SUB_DIR ${CURRENT_DIRS}) | |||
| 39 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/framework/CMakeLists.txt") | 40 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUB_DIR}/framework/CMakeLists.txt") |
| 40 | add_subdirectory(${SUB_DIR}/framework) | 41 | add_subdirectory(${SUB_DIR}/framework) |
| 41 | endif() | 42 | endif() |
| 42 | -endforeach() | 43 | +endforeach() |
| @@ -11,7 +11,9 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | + | ||
| 14 | 15 | ||
| 16 | + | ||
| 15 | 17 | ||
| 16 | 18 | ||
| 17 | 19 | ||
| @@ -99,8 +101,7 @@ namespace op { | |||
| 99 | [[maybe_unused]] static const std::initializer_list<DataType>& GetDtypeSupportListV1( | 101 | [[maybe_unused]] static const std::initializer_list<DataType>& GetDtypeSupportListV1( |
| 100 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) | 102 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) |
| 101 | { | 103 | { |
| 102 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 104 | + if (GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201) { |
| 103 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93) { | ||
| 104 | return l1; | 105 | return l1; |
| 105 | } else { | 106 | } else { |
| 106 | return l2; | 107 | return l2; |
| @@ -114,8 +115,8 @@ namespace op { | |||
| 114 | [[maybe_unused]] static const std::initializer_list<DataType>& GetDtypeSupportListV2( | 115 | [[maybe_unused]] static const std::initializer_list<DataType>& GetDtypeSupportListV2( |
| 115 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) | 116 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) |
| 116 | { | 117 | { |
| 117 | - if (GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 118 | + auto curArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 118 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E) { | 119 | + if(curArch == NpuArch::DAV_2201 || IsRegBase(curArch)) { |
| 119 | return l1; | 120 | return l1; |
| 120 | } else { | 121 | } else { |
| 121 | return l2; | 122 | return l2; |
| @@ -125,14 +126,13 @@ namespace op { | |||
| 125 | [[maybe_unused]] static const std::initializer_list<op::DataType> GetDtypeSupportListV3( | 126 | [[maybe_unused]] static const std::initializer_list<op::DataType> GetDtypeSupportListV3( |
| 126 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) | 127 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) |
| 127 | { | 128 | { |
| 128 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 129 | + auto curArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 129 | - switch (socVersion) { | 130 | + switch (curArch) { |
| 130 | - case SocVersion::ASCEND910_93: | 131 | + case NpuArch::DAV_2201: |
| 131 | - case SocVersion::ASCEND910_95: | 132 | + case NpuArch::DAV_3510: { |
| 132 | - case SocVersion::ASCEND910B: { | ||
| 133 | return l1; | 133 | return l1; |
| 134 | } | 134 | } |
| 135 | - case SocVersion::ASCEND910: { | 135 | + case NpuArch::DAV_1001: { |
| 136 | return l2; | 136 | return l2; |
| 137 | } | 137 | } |
| 138 | default: { | 138 | default: { |
| @@ -22,26 +22,26 @@ namespace Math { | |||
| 22 | namespace OpTiling { | 22 | namespace OpTiling { |
| 23 | static const gert::Shape g_vec_1_shape = {1}; | 23 | static const gert::Shape g_vec_1_shape = {1}; |
| 24 | 24 | ||
| 25 | -static bool IsRegbaseSocVersion(platform_ascendc::SocVersion version) | 25 | +static bool IsRegbaseSocVersion(NpuArch npuArch) |
| 26 | { | 26 | { |
| 27 | - const static std::set<platform_ascendc::SocVersion> regbaseSocVersions = { | 27 | + const static std::set<NpuArch> regbaseArch = { |
| 28 | - platform_ascendc::SocVersion::ASCEND910_95}; | 28 | + NpuArch::DAV_3510}; |
| 29 | 29 | ||
| 30 | - return regbaseSocVersions.find(version) != regbaseSocVersions.end(); | 30 | + return regbaseArch.find(npuArch) != regbaseArch.end(); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | bool IsRegbaseSocVersion(const gert::TilingParseContext* context) | 33 | bool IsRegbaseSocVersion(const gert::TilingParseContext* context) |
| 34 | { | 34 | { |
| 35 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | 35 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); |
| 36 | - auto socVersion = ascendcPlatform.GetSocVersion(); | 36 | + auto arch = ascendcPlatform.GetCurNpuArch(); |
| 37 | - return IsRegbaseSocVersion(socVersion); | 37 | + return IsRegbaseSocVersion(arch); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | bool IsRegbaseSocVersion(const gert::TilingContext* context) | 40 | bool IsRegbaseSocVersion(const gert::TilingContext* context) |
| 41 | { | 41 | { |
| 42 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | 42 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); |
| 43 | - auto socVersion = ascendcPlatform.GetSocVersion(); | 43 | + auto arch = ascendcPlatform.GetCurNpuArch(); |
| 44 | - return IsRegbaseSocVersion(socVersion); | 44 | + return IsRegbaseSocVersion(arch); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | const gert::Shape &EnsureNotScalar(const gert::Shape &inShape) { | 47 | const gert::Shape &EnsureNotScalar(const gert::Shape &inShape) { |


代码重复: 新增的IsRegBase()函数与已有的IsRegBase(NpuArch arch)函数存在代码重复。两个函数都定义了相同的静态集合regbaseArch = {NpuArch::DAV_3510},这违反了DRY(Don't Repeat Yourself)原则。当需要修改支持的架构列表时,需要在两个地方进行修改,增加了维护成本和出错风险。
问题类型: 代码重复 文件路径:
common/inc/op_api/aclnn_check.h行号: 140 问题代码:修改建议:
此评论由代码审查工具自动生成