已合并
[matmul]socversion整改 #1085
littlemons创建于 1月28日
[matmul]socversion整改 #1085
已合并
共 68 个文件变更+572-541
| @@ -65,8 +65,8 @@ static const std::initializer_list<op::DataType> dtypeSupportListWithoutBf16 = { | |||
| 65 | 65 | ||
| 66 | static inline bool CheckSocVersionIsSupportBf16(void) | 66 | static inline bool CheckSocVersionIsSupportBf16(void) |
| 67 | { | 67 | { |
| 68 | - return GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 68 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 69 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E; | 69 | + return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static bool CheckShape(const aclTensor* selfTensor, const aclTensor* batch1Tensor, const aclTensor* batch2Tensor) | 72 | static bool CheckShape(const aclTensor* selfTensor, const aclTensor* batch1Tensor, const aclTensor* batch2Tensor) |
| @@ -178,9 +178,9 @@ static aclnnStatus CheckInputParams( | |||
| 178 | CHECK_RET(CheckOutputNotNull(out), ACLNN_ERR_PARAM_NULLPTR); | 178 | CHECK_RET(CheckOutputNotNull(out), ACLNN_ERR_PARAM_NULLPTR); |
| 179 | 179 | ||
| 180 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 | 180 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 |
| 181 | - auto socRule = SocMatMulRule::getInstance(); | 181 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 182 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 182 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 183 | - CHECK_RET(socRule->CheckInput(batch1, batch2, self, out, cubeMathType), ACLNN_ERR_PARAM_INVALID); | 183 | + CHECK_RET(archRule->CheckInput(batch1, batch2, self, out, cubeMathType), ACLNN_ERR_PARAM_INVALID); |
| 184 | 184 | ||
| 185 | // 3. 检查batch1和batch2是否满足Shape、广播、Empty条件 | 185 | // 3. 检查batch1和batch2是否满足Shape、广播、Empty条件 |
| 186 | CHECK_RET(CheckShape(self, batch1, batch2), ACLNN_ERR_PARAM_INVALID); | 186 | CHECK_RET(CheckShape(self, batch1, batch2), ACLNN_ERR_PARAM_INVALID); |
| @@ -46,23 +46,24 @@ static const std::initializer_list<op::DataType> ASCEND310P_DTYPE_SUPPORT_LIST = | |||
| 46 | op::DataType::DT_UINT16, op::DataType::DT_UINT32, op::DataType::DT_UINT64 | 46 | op::DataType::DT_UINT16, op::DataType::DT_UINT32, op::DataType::DT_UINT64 |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | -static const std::initializer_list<op::DataType> ASCEND910B_DTYPE_SUPPORT_LIST = { | 49 | +static const std::initializer_list<op::DataType> DAV_2201_DTYPE_SUPPORT_LIST = { |
| 50 | op::DataType::DT_FLOAT16, op::DataType::DT_FLOAT, | 50 | op::DataType::DT_FLOAT16, op::DataType::DT_FLOAT, |
| 51 | op::DataType::DT_INT16, op::DataType::DT_INT32, op::DataType::DT_INT64, | 51 | op::DataType::DT_INT16, op::DataType::DT_INT32, op::DataType::DT_INT64, |
| 52 | op::DataType::DT_UINT16, op::DataType::DT_UINT32, op::DataType::DT_UINT64 | 52 | op::DataType::DT_UINT16, op::DataType::DT_UINT32, op::DataType::DT_UINT64 |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | static const std::initializer_list<DataType>& GetDtypeSupportList() { | 55 | static const std::initializer_list<DataType>& GetDtypeSupportList() { |
| 56 | - if (GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 56 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 57 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E) { | 57 | + if ((npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510)) { |
| 58 | - return ASCEND910B_DTYPE_SUPPORT_LIST; | 58 | + return DAV_2201_DTYPE_SUPPORT_LIST; |
| 59 | } else { | 59 | } else { |
| 60 | return ASCEND310P_DTYPE_SUPPORT_LIST; | 60 | return ASCEND310P_DTYPE_SUPPORT_LIST; |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | // define 回调函数类型 | 64 | // define 回调函数类型 |
| 65 | -typedef aclnnStatus (*callback)(const aclTensorList *tensors, aclTensor *output, uint64_t *workspaceSize, aclOpExecutor **executor); | 65 | +using callback = |
| 66 | + aclnnStatus (*)(const aclTensorList *tensors, aclTensor *output, uint64_t *workspaceSize, aclOpExecutor **executor); | ||
| 66 | 67 | ||
| 67 | typedef struct { | 68 | typedef struct { |
| 68 | std::string equation; | 69 | std::string equation; |
| @@ -128,8 +129,7 @@ aclnnStatus HandleABCDxABCED2ABCE(const aclTensorList *tensors, aclTensor *outpu | |||
| 128 | auto ret = CheckABCDxABCED2ABCE(tensors, output); | 129 | auto ret = CheckABCDxABCED2ABCE(tensors, output); |
| 129 | CHECK_RET(ret == ACLNN_SUCCESS, ret); | 130 | CHECK_RET(ret == ACLNN_SUCCESS, ret); |
| 130 | 131 | ||
| 131 | - auto cubeMathType = (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 132 | + auto cubeMathType = (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201) ? 0 : g_useFP16; |
| 132 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93) ? 0 : g_useFP16; | ||
| 133 | 133 | ||
| 134 | auto tensor0Contigous = l0op::Contiguous((*tensors)[0], uniqueExecutor.get()); | 134 | auto tensor0Contigous = l0op::Contiguous((*tensors)[0], uniqueExecutor.get()); |
| 135 | auto tensor1Contigous = l0op::Contiguous((*tensors)[1], uniqueExecutor.get()); | 135 | auto tensor1Contigous = l0op::Contiguous((*tensors)[1], uniqueExecutor.get()); |
Mmatmul/batch_mat_mul_v3/op_host/op_tiling/arch35/batch_matmul_v3_asw_al1_full_load_basic_tiling.cpp+1-1
| @@ -22,7 +22,7 @@ | |||
| 22 | namespace optiling { | 22 | namespace optiling { |
| 23 | namespace batch_matmul_v3_advanced { | 23 | namespace batch_matmul_v3_advanced { |
| 24 | using namespace strategy; | 24 | using namespace strategy; |
| 25 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswAL1FullLoadBasicTiling, ASCEND950, AL1_FULL_LOAD_BASIC); | 25 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswAL1FullLoadBasicTiling, DAV_3510, AL1_FULL_LOAD_BASIC); |
| 26 | 26 | ||
| 27 | bool BatchMatMulV3AswAL1FullLoadBasicTiling::IsCapable() | 27 | bool BatchMatMulV3AswAL1FullLoadBasicTiling::IsCapable() |
| 28 | { | 28 | { |
| @@ -22,7 +22,7 @@ | |||
| 22 | namespace optiling { | 22 | namespace optiling { |
| 23 | namespace batch_matmul_v3_advanced { | 23 | namespace batch_matmul_v3_advanced { |
| 24 | using namespace strategy; | 24 | using namespace strategy; |
| 25 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswBasicTiling, ASCEND950, ASW_BASIC); | 25 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswBasicTiling, DAV_3510, ASW_BASIC); |
| 26 | 26 | ||
| 27 | bool BatchMatMulV3AswBasicTiling::IsCapable() | 27 | bool BatchMatMulV3AswBasicTiling::IsCapable() |
| 28 | { | 28 | { |
Mmatmul/batch_mat_mul_v3/op_host/op_tiling/arch35/batch_matmul_v3_asw_bl1_full_load_basic_tiling.cpp+1-1
| @@ -22,7 +22,7 @@ | |||
| 22 | namespace optiling { | 22 | namespace optiling { |
| 23 | namespace batch_matmul_v3_advanced { | 23 | namespace batch_matmul_v3_advanced { |
| 24 | using namespace strategy; | 24 | using namespace strategy; |
| 25 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswBL1FullLoadBasicTiling, ASCEND950, BL1_FULL_LOAD_BASIC); | 25 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswBL1FullLoadBasicTiling, DAV_3510, BL1_FULL_LOAD_BASIC); |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | bool BatchMatMulV3AswBL1FullLoadBasicTiling::IsCapable() | 28 | bool BatchMatMulV3AswBL1FullLoadBasicTiling::IsCapable() |
| @@ -22,9 +22,9 @@ | |||
| 22 | namespace optiling { | 22 | namespace optiling { |
| 23 | namespace batch_matmul_v3_advanced { | 23 | namespace batch_matmul_v3_advanced { |
| 24 | using namespace strategy; | 24 | using namespace strategy; |
| 25 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswTiling, ASCEND950, BASE); | 25 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswTiling, DAV_3510, BASE); |
| 26 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswTiling, RESERVED_VERSION, BASE); //supportMmadS8S4平台 | 26 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3AswTiling, DAV_RESV, BASE); //supportMmadS8S4平台 |
| 27 | -MM_REGISTER_TILING_TEMPLATE(FusedMatMul, BatchMatMulV3AswTiling, RESERVED_VERSION, BASE); //supportMmadS8S4平台 | 27 | +MM_REGISTER_TILING_TEMPLATE(FusedMatMul, BatchMatMulV3AswTiling, DAV_RESV, BASE); //supportMmadS8S4平台 |
| 28 | 28 | ||
| 29 | ge::graphStatus BatchMatMulV3AswTiling::DoOpTiling() | 29 | ge::graphStatus BatchMatMulV3AswTiling::DoOpTiling() |
| 30 | { | 30 | { |
| @@ -22,7 +22,7 @@ namespace optiling { | |||
| 22 | namespace batch_matmul_v3_advanced { | 22 | namespace batch_matmul_v3_advanced { |
| 23 | using namespace strategy; | 23 | using namespace strategy; |
| 24 | using StrideIndexPairs = std::vector<std::pair<int64_t, std::pair<int64_t, int64_t>>>; | 24 | using StrideIndexPairs = std::vector<std::pair<int64_t, std::pair<int64_t, int64_t>>>; |
| 25 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3IterBatchBasicApiTiling, ASCEND950, ITER_BATCH_BASICAPI); | 25 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3IterBatchBasicApiTiling, DAV_3510, ITER_BATCH_BASICAPI); |
| 26 | 26 | ||
| 27 | bool BatchMatMulV3IterBatchBasicApiTiling::IsContiguousStride(StrideIndexPairs& strideIndexPairs) const | 27 | bool BatchMatMulV3IterBatchBasicApiTiling::IsContiguousStride(StrideIndexPairs& strideIndexPairs) const |
| 28 | { | 28 | { |
| @@ -21,9 +21,9 @@ | |||
| 21 | namespace optiling { | 21 | namespace optiling { |
| 22 | namespace batch_matmul_v3_advanced { | 22 | namespace batch_matmul_v3_advanced { |
| 23 | using namespace strategy; | 23 | using namespace strategy; |
| 24 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3IterBatchTiling, ASCEND950, ITER_BATCH); | 24 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3IterBatchTiling, DAV_3510, ITER_BATCH); |
| 25 | //supportMmadS8S4平台 | 25 | //supportMmadS8S4平台 |
| 26 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3IterBatchTiling, RESERVED_VERSION, ITER_BATCH); | 26 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3IterBatchTiling, DAV_RESV, ITER_BATCH); |
| 27 | 27 | ||
| 28 | ge::graphStatus BatchMatMulV3IterBatchTiling::DoOpTiling() | 28 | ge::graphStatus BatchMatMulV3IterBatchTiling::DoOpTiling() |
| 29 | { | 29 | { |
| @@ -23,7 +23,7 @@ namespace optiling { | |||
| 23 | namespace batch_matmul_v3_advanced { | 23 | namespace batch_matmul_v3_advanced { |
| 24 | using namespace strategy; | 24 | using namespace strategy; |
| 25 | 25 | ||
| 26 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3KEqZeroTiling, ASCEND950, BATCH_MATMUL_INPUT_K_EQUAL_ZERO); | 26 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3KEqZeroTiling, DAV_3510, BATCH_MATMUL_INPUT_K_EQUAL_ZERO); |
| 27 | 27 | ||
| 28 | bool BatchMatMulV3KEqZeroTiling::IsCapable() | 28 | bool BatchMatMulV3KEqZeroTiling::IsCapable() |
| 29 | { | 29 | { |
| @@ -23,7 +23,7 @@ namespace optiling { | |||
| 23 | namespace batch_matmul_v3_advanced { | 23 | namespace batch_matmul_v3_advanced { |
| 24 | 24 | ||
| 25 | using namespace strategy; | 25 | using namespace strategy; |
| 26 | -MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3ToMulTiling, ASCEND950, BATCH_MATMUL_TO_MUL); | 26 | +MM_REGISTER_TILING_TEMPLATE(BatchMatMulV3, BatchMatMulV3ToMulTiling, DAV_3510, BATCH_MATMUL_TO_MUL); |
| 27 | 27 | ||
| 28 | ge::graphStatus BatchMatMulV3ToMulTiling::DoOpTiling() | 28 | ge::graphStatus BatchMatMulV3ToMulTiling::DoOpTiling() |
| 29 | { | 29 | { |
| @@ -40,9 +40,8 @@ ge::graphStatus BatchMatMulV3Tiling::DoTiling() | |||
| 40 | args_.batchInfo = &tempBatchInfo; | 40 | args_.batchInfo = &tempBatchInfo; |
| 41 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void *>(&args_)); | 41 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void *>(&args_)); |
| 42 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); | 42 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); |
| 43 | - platform_ascendc::SocVersion socVersion = | 43 | + NpuArch npuArch = static_cast<const MatmulV3CompileInfo *>(tilingCfg.compileInfo)->npuArch; |
| 44 | - static_cast<const MatmulV3CompileInfo *>(tilingCfg.compileInfo)->socVersion; | 44 | + MMRegisterCfg registerCfg{ "BatchMatMulV3", npuArch, strategy::GetBatchMatMulV3Priorities(npuArch) }; |
| 45 | - MMRegisterCfg registerCfg{ "BatchMatMulV3", socVersion, strategy::GetBatchMatMulV3Priorities(socVersion) }; | ||
| 46 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); | 45 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); |
| 47 | } | 46 | } |
| 48 | 47 | ||
| @@ -34,19 +34,19 @@ constexpr int32_t BL1_FULL_LOAD_BASIC = 5; | |||
| 34 | constexpr int32_t ASW_BASIC = 6; | 34 | constexpr int32_t ASW_BASIC = 6; |
| 35 | constexpr int32_t BASE = 999; | 35 | constexpr int32_t BASE = 999; |
| 36 | 36 | ||
| 37 | -const static std::map<platform_ascendc::SocVersion, std::vector<int32_t>> BatchMatMulV3PrioritiesMap = { | 37 | +const static std::map<NpuArch, std::vector<int32_t>> BatchMatMulV3PrioritiesMap = { |
| 38 | - {platform_ascendc::SocVersion::ASCEND950, | 38 | + {NpuArch::DAV_3510, |
| 39 | {strategy::BATCH_MATMUL_INPUT_K_EQUAL_ZERO, strategy::BATCH_MATMUL_TO_MUL, strategy::ITER_BATCH_BASICAPI, | 39 | {strategy::BATCH_MATMUL_INPUT_K_EQUAL_ZERO, strategy::BATCH_MATMUL_TO_MUL, strategy::ITER_BATCH_BASICAPI, |
| 40 | strategy::ITER_BATCH, strategy::AL1_FULL_LOAD_BASIC, strategy::BL1_FULL_LOAD_BASIC, strategy::ASW_BASIC, | 40 | strategy::ITER_BATCH, strategy::AL1_FULL_LOAD_BASIC, strategy::BL1_FULL_LOAD_BASIC, strategy::ASW_BASIC, |
| 41 | strategy::BASE}}, | 41 | strategy::BASE}}, |
| 42 | - {platform_ascendc::SocVersion::RESERVED_VERSION, {strategy::ITER_BATCH, strategy::BASE}}, // supportMmadS8S4平台 | 42 | + {NpuArch::DAV_RESV, {strategy::ITER_BATCH, strategy::BASE}}, // supportMmadS8S4平台 |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | -inline std::vector<int32_t> GetBatchMatMulV3Priorities(platform_ascendc::SocVersion socVersion) | 45 | +inline std::vector<int32_t> GetBatchMatMulV3Priorities(NpuArch NpuArch) |
| 46 | { | 46 | { |
| 47 | std::vector<int32_t> priorities = {}; | 47 | std::vector<int32_t> priorities = {}; |
| 48 | - if (BatchMatMulV3PrioritiesMap.find(socVersion) != BatchMatMulV3PrioritiesMap.end()) { | 48 | + if (BatchMatMulV3PrioritiesMap.find(NpuArch) != BatchMatMulV3PrioritiesMap.end()) { |
| 49 | - priorities = BatchMatMulV3PrioritiesMap.at(socVersion); | 49 | + priorities = BatchMatMulV3PrioritiesMap.at(NpuArch); |
| 50 | } | 50 | } |
| 51 | return priorities; | 51 | return priorities; |
| 52 | }; | 52 | }; |
| @@ -935,7 +935,7 @@ static void UpdateUsedCoreNum(uint64_t batchC, uint64_t aicNum, BatchMatmulTilin | |||
| 935 | 935 | ||
| 936 | void BatchMatmulV3BaseTiling::DoL1FullLoadTiling() | 936 | void BatchMatmulV3BaseTiling::DoL1FullLoadTiling() |
| 937 | { | 937 | { |
| 938 | - if (compileInfo_.socVersion == platform_ascendc::SocVersion::ASCEND310P || | 938 | + if (compileInfo_.npuArch == NpuArch::DAV_2002 || |
| 939 | std::string(context_->GetNodeType()) == "TransposeBatchMatMul") { | 939 | std::string(context_->GetNodeType()) == "TransposeBatchMatMul") { |
| 940 | return; // currently not support weight NZ | 940 | return; // currently not support weight NZ |
| 941 | } | 941 | } |
| @@ -71,6 +71,7 @@ static ge::graphStatus TilingPrepareForBatchMatMulV3(gert::TilingParseContext *c | |||
| 71 | compileInfoPtr->aivNum = ascendcPlatform.GetCoreNumAiv(); | 71 | compileInfoPtr->aivNum = ascendcPlatform.GetCoreNumAiv(); |
| 72 | compileInfoPtr->socVersion = | 72 | compileInfoPtr->socVersion = |
| 73 | supportMmadS8S4 ? platform_ascendc::SocVersion::RESERVED_VERSION : ascendcPlatform.GetSocVersion(); | 73 | supportMmadS8S4 ? platform_ascendc::SocVersion::RESERVED_VERSION : ascendcPlatform.GetSocVersion(); |
| 74 | + compileInfoPtr->npuArch = supportMmadS8S4 ? NpuArch::DAV_RESV : ascendcPlatform.GetCurNpuArch(); | ||
| 74 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize | 75 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize |
| 75 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize | 76 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize |
| 76 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 77 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -86,8 +87,8 @@ static ge::graphStatus TilingPrepareForBatchMatMulV3(gert::TilingParseContext *c | |||
| 86 | } | 87 | } |
| 87 | OP_LOGI( | 88 | OP_LOGI( |
| 88 | context->GetNodeName(), | 89 | context->GetNodeName(), |
| 89 | - "compile info success soc:%d, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", | 90 | + "compile info success soc:%d, npu arch: %u, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", |
| 90 | - static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->l1Size, compileInfoPtr->l2Size, | 91 | + static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->npuArch, compileInfoPtr->l1Size, compileInfoPtr->l2Size, |
| 91 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); | 92 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); |
| 92 | return ge::GRAPH_SUCCESS; | 93 | return ge::GRAPH_SUCCESS; |
| 93 | } | 94 | } |
| @@ -22,24 +22,24 @@ static const std::initializer_list<DataType> V100_DTYPE_SUPPORT_LIST = {DataType | |||
| 22 | static const std::initializer_list<DataType> V200_DTYPE_SUPPORT_LIST = {DataType::DT_FLOAT, | 22 | static const std::initializer_list<DataType> V200_DTYPE_SUPPORT_LIST = {DataType::DT_FLOAT, |
| 23 | DataType::DT_FLOAT16, DataType::DT_BF16}; | 23 | DataType::DT_FLOAT16, DataType::DT_BF16}; |
| 24 | namespace { | 24 | namespace { |
| 25 | -static const std::initializer_list<DataType> ASCEND950_DTYPE_SUPPORT_LIST = {DataType::DT_FLOAT, | 25 | +static const std::initializer_list<DataType> DAV_3510_DTYPE_SUPPORT_LIST = {DataType::DT_FLOAT, |
| 26 | DataType::DT_FLOAT16, DataType::DT_BF16, DataType::DT_HIFLOAT8}; | 26 | DataType::DT_FLOAT16, DataType::DT_BF16, DataType::DT_HIFLOAT8}; |
| 27 | -static const std::initializer_list<DataType> ASCEND950_CONVBP_DTYPE_SUPPORT_LIST = {DataType::DT_FLOAT, | 27 | +static const std::initializer_list<DataType> DAV_3510_CONVBP_DTYPE_SUPPORT_LIST = {DataType::DT_FLOAT, |
| 28 | DataType::DT_FLOAT16, DataType::DT_BF16, DataType::DT_HIFLOAT8, DataType::DT_FLOAT8_E4M3FN}; | 28 | DataType::DT_FLOAT16, DataType::DT_BF16, DataType::DT_HIFLOAT8, DataType::DT_FLOAT8_E4M3FN}; |
| 29 | } | 29 | } |
| 30 | // 根据dtype进行初步拦截,后续需要再和cubemathtype + 芯片再进行一次拦截 | 30 | // 根据dtype进行初步拦截,后续需要再和cubemathtype + 芯片再进行一次拦截 |
| 31 | const std::initializer_list<DataType>& GetDtypeSupportListBySocVersion() { | 31 | const std::initializer_list<DataType>& GetDtypeSupportListBySocVersion() { |
| 32 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 32 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 33 | - if (socVersion == SocVersion::ASCEND950) { | 33 | + if (npuArch == NpuArch::DAV_3510) { |
| 34 | - return ASCEND950_DTYPE_SUPPORT_LIST; | 34 | + return DAV_3510_DTYPE_SUPPORT_LIST; |
| 35 | } | 35 | } |
| 36 | return (IsCubeSupportFp32()) ? V200_DTYPE_SUPPORT_LIST : V100_DTYPE_SUPPORT_LIST; | 36 | return (IsCubeSupportFp32()) ? V200_DTYPE_SUPPORT_LIST : V100_DTYPE_SUPPORT_LIST; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | const std::initializer_list<DataType>& GetDtypeSupportListBySocVersion4ConvBackward(bool transposed) { | 39 | const std::initializer_list<DataType>& GetDtypeSupportListBySocVersion4ConvBackward(bool transposed) { |
| 40 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 40 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 41 | - if (socVersion == SocVersion::ASCEND950) { | 41 | + if (npuArch == NpuArch::DAV_3510) { |
| 42 | - return transposed ? ASCEND950_DTYPE_SUPPORT_LIST : ASCEND950_CONVBP_DTYPE_SUPPORT_LIST; | 42 | + return transposed ? DAV_3510_DTYPE_SUPPORT_LIST : DAV_3510_CONVBP_DTYPE_SUPPORT_LIST; |
| 43 | } | 43 | } |
| 44 | return (IsCubeSupportFp32()) ? V200_DTYPE_SUPPORT_LIST : V100_DTYPE_SUPPORT_LIST; | 44 | return (IsCubeSupportFp32()) ? V200_DTYPE_SUPPORT_LIST : V100_DTYPE_SUPPORT_LIST; |
| 45 | } | 45 | } |
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | namespace Ops { | 18 | namespace Ops { |
| 19 | namespace NN { | 19 | namespace NN { |
| 20 | +using namespace op; | ||
| 20 | // 校验针对cube tensor的dtype,cubeMathType的值是否符合预期 | 21 | // 校验针对cube tensor的dtype,cubeMathType的值是否符合预期 |
| 21 | bool CheckCubeMathType(const op::DataType cubeTensorDtype, int8_t cubeMathType); | 22 | bool CheckCubeMathType(const op::DataType cubeTensorDtype, int8_t cubeMathType); |
| 22 | 23 | ||
| @@ -40,10 +41,8 @@ bool NeedCubeGoHF32(const op::DataType cubeTensorPromoteType, int8_t cubeMathTyp | |||
| 40 | 41 | ||
| 41 | // 检查针对x芯片,cube算子是否支持FP32 | 42 | // 检查针对x芯片,cube算子是否支持FP32 |
| 42 | inline bool IsCubeSupportFp32() { | 43 | inline bool IsCubeSupportFp32() { |
| 43 | - if (op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910B && | 44 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 44 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910_93 && | 45 | + if ((npuArch != NpuArch::DAV_2201) && (npuArch != NpuArch::DAV_3510) && (npuArch != NpuArch::DAV_3002)) { |
| 45 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND950 && | ||
| 46 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND310B) { | ||
| 47 | return false; | 46 | return false; |
| 48 | } | 47 | } |
| 49 | return true; | 48 | return true; |
| @@ -51,10 +50,8 @@ inline bool IsCubeSupportFp32() { | |||
| 51 | 50 | ||
| 52 | // 检查针对x芯片,cube算子是否支持HF32 | 51 | // 检查针对x芯片,cube算子是否支持HF32 |
| 53 | inline bool IsCubeSupportHf32() { | 52 | inline bool IsCubeSupportHf32() { |
| 54 | - if (op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910B && | 53 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 55 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910_93 && | 54 | + if ((npuArch != NpuArch::DAV_2201) && (npuArch != NpuArch::DAV_3510) && (npuArch != NpuArch::DAV_3002)) { |
| 56 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND950 && | ||
| 57 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND310B) { | ||
| 58 | return false; | 55 | return false; |
| 59 | } | 56 | } |
| 60 | return true; | 57 | return true; |
| @@ -27,7 +27,6 @@ | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | - | ||
| 31 | 30 | ||
| 32 | 31 | ||
| 33 | 32 | ||
| @@ -99,14 +98,13 @@ static inline bool CheckMathType(const aclTensor* self, const aclTensor* mat2, i | |||
| 99 | 98 | ||
| 100 | static inline bool CheckKEqual1Support(void) | 99 | static inline bool CheckKEqual1Support(void) |
| 101 | { | 100 | { |
| 102 | - return GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 101 | + return (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201); |
| 103 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93; | ||
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | -static inline bool CheckSocVersionIsSupportBf16(void) | 104 | +static inline bool CheckNpuArchIsSupportBf16(void) |
| 107 | { | 105 | { |
| 108 | - return GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E && | 106 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 109 | - GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B; | 107 | + return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510); |
| 110 | } | 108 | } |
| 111 | 109 | ||
| 112 | static inline bool CheckMMV3NzNzNdSupport(const aclTensor* mat2) | 110 | static inline bool CheckMMV3NzNzNdSupport(const aclTensor* mat2) |
| @@ -118,7 +116,7 @@ static inline bool CheckMMV3NzNzNdSupport(const aclTensor* mat2) | |||
| 118 | static bool CheckDtypeValid( | 116 | static bool CheckDtypeValid( |
| 119 | const aclTensor* self, const aclTensor* mat2, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) | 117 | const aclTensor* self, const aclTensor* mat2, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) |
| 120 | { | 118 | { |
| 121 | - bool bf16flag = CheckSocVersionIsSupportBf16(); | 119 | + bool bf16flag = CheckNpuArchIsSupportBf16(); |
| 122 | if (bf16flag) { | 120 | if (bf16flag) { |
| 123 | OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); | 121 | OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); |
| 124 | OP_CHECK_DTYPE_NOT_SUPPORT(mat2, DTYPE_SUPPORT_LIST, return false); | 122 | OP_CHECK_DTYPE_NOT_SUPPORT(mat2, DTYPE_SUPPORT_LIST, return false); |
| @@ -249,9 +247,8 @@ static bool CheckSupportSingleSplitKFp16Bf16( | |||
| 249 | // 2. 在K轴非256字节对齐场景下,输入数据大小不超过INT32最大值 | 247 | // 2. 在K轴非256字节对齐场景下,输入数据大小不超过INT32最大值 |
| 250 | // 3. K轴大于27392 | 248 | // 3. K轴大于27392 |
| 251 | // 4. M、N中最大不超过K轴的一半 | 249 | // 4. M、N中最大不超过K轴的一半 |
| 252 | - bool supportCurrentSoc = GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 250 | + bool supportCurrentArch = (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201); |
| 253 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93; | 251 | + if (!supportCurrentArch) { |
| 254 | - if (!supportCurrentSoc) { | ||
| 255 | return false; | 252 | return false; |
| 256 | } | 253 | } |
| 257 | op::Shape selfShape = self->GetViewShape(); | 254 | op::Shape selfShape = self->GetViewShape(); |
| @@ -290,9 +287,10 @@ static aclnnStatus SetMatmulOpSupportInfo( | |||
| 290 | 287 | ||
| 291 | if (IsSplitk(&SpTensor_sefl, &SpTensor_mat2)) { | 288 | if (IsSplitk(&SpTensor_sefl, &SpTensor_mat2)) { |
| 292 | mmOpInfo.supporSplitK = true; | 289 | mmOpInfo.supporSplitK = true; |
| 293 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310P) { | 290 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 291 | + if (npuArch == NpuArch::DAV_2002) { | ||
| 294 | mmOpInfo.support_info.output_dtype = DataType::DT_FLOAT; | 292 | mmOpInfo.support_info.output_dtype = DataType::DT_FLOAT; |
| 295 | - } else if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910) { | 293 | + } else if (npuArch == NpuArch::DAV_1001) { |
| 296 | mmOpInfo.support_info.output_format = Format::FORMAT_FRACTAL_NZ; | 294 | mmOpInfo.support_info.output_format = Format::FORMAT_FRACTAL_NZ; |
| 297 | mmOpInfo.support_info.output_dtype = DataType::DT_FLOAT; | 295 | mmOpInfo.support_info.output_dtype = DataType::DT_FLOAT; |
| 298 | } | 296 | } |
| @@ -343,8 +341,8 @@ static MmOpInfo GetMatmulOpInfoWithTrans( | |||
| 343 | mmOpInfo.support_info = mmOpInfo.ori_info; | 341 | mmOpInfo.support_info = mmOpInfo.ori_info; |
| 344 | // 如果允许降精度处理, 则开启HF32模式(0x40),否则采用默认模式; 后续此字段配置需要按照字段表进行配置 | 342 | // 如果允许降精度处理, 则开启HF32模式(0x40),否则采用默认模式; 后续此字段配置需要按照字段表进行配置 |
| 345 | mmOpInfo.enableHf32 = (cubeMathType == ALLOW_FP32_DOWN_PRECISION) || (cubeMathType == USE_HF32); | 343 | mmOpInfo.enableHf32 = (cubeMathType == ALLOW_FP32_DOWN_PRECISION) || (cubeMathType == USE_HF32); |
| 346 | - mmOpInfo.enableForceGrpAccForFp32 = cubeMathType == FORCE_GRP_ACC_FOR_FP32 && (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 344 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 347 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93); | 345 | + mmOpInfo.enableForceGrpAccForFp32 = cubeMathType == FORCE_GRP_ACC_FOR_FP32 && (npuArch == NpuArch::DAV_2201); |
| 348 | mmOpInfo.opImplModeEnum = mmOpInfo.enableHf32 ? 0x40 : (mmOpInfo.enableForceGrpAccForFp32 ? 0x4 : 0x1); | 346 | mmOpInfo.opImplModeEnum = mmOpInfo.enableHf32 ? 0x40 : (mmOpInfo.enableForceGrpAccForFp32 ? 0x4 : 0x1); |
| 349 | OP_LOGD( | 347 | OP_LOGD( |
| 350 | "opImplModeEnum=%ld, enableHf32=%d, enableForceGrpAccForFp32=%d cubeMathType=%d", mmOpInfo.opImplModeEnum, | 348 | "opImplModeEnum=%ld, enableHf32=%d, enableForceGrpAccForFp32=%d cubeMathType=%d", mmOpInfo.opImplModeEnum, |
| @@ -371,14 +369,13 @@ static bool CheckAscendCScenario( | |||
| 371 | const aclTensor* x1, const aclTensor* x2, const aclTensor* bias, const MmOpInfo& mmOpInfo, const bool transposeX1, | 369 | const aclTensor* x1, const aclTensor* x2, const aclTensor* bias, const MmOpInfo& mmOpInfo, const bool transposeX1, |
| 372 | const bool transposeX2) | 370 | const bool transposeX2) |
| 373 | { | 371 | { |
| 374 | - if ((GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND910B && | 372 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 375 | - GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND910_93 && | 373 | + if ((npuArch != NpuArch::DAV_2201 && npuArch != NpuArch::DAV_3510) || |
| 376 | - GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND950) || | 374 | + (mmOpInfo.support_info.self_format != ge::FORMAT_ND)) { |
| 377 | - mmOpInfo.support_info.self_format != ge::FORMAT_ND) { | 375 | + OP_LOGI("Not mat_mul_v3 case for unsupported npu arch or unsupported Format."); |
| 378 | - OP_LOGI("Not mat_mul_v3 case for unsupported SOC version or unsupported Format."); | ||
| 379 | return false; | 376 | return false; |
| 380 | } | 377 | } |
| 381 | - bool alwaysUseV3 = GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND950; | 378 | + bool alwaysUseV3 = (npuArch == NpuArch::DAV_3510); |
| 382 | return (alwaysUseV3 || Ops::NN::MmCheckHitV3Shape(x1, x2, bias, transposeX1, transposeX2, | 379 | return (alwaysUseV3 || Ops::NN::MmCheckHitV3Shape(x1, x2, bias, transposeX1, transposeX2, |
| 383 | mmOpInfo.support_info.mat2_format, mmOpInfo.supporSplitK)); | 380 | mmOpInfo.support_info.mat2_format, mmOpInfo.supporSplitK)); |
| 384 | } | 381 | } |
| @@ -386,7 +383,8 @@ static bool CheckAscendCScenario( | |||
| 386 | static bool CheckAscendCScenario2( | 383 | static bool CheckAscendCScenario2( |
| 387 | const aclTensor* x1, const aclTensor* x2, const MmOpInfo& mmOpInfo, const bool transposeX1, const bool transposeX2) | 384 | const aclTensor* x1, const aclTensor* x2, const MmOpInfo& mmOpInfo, const bool transposeX1, const bool transposeX2) |
| 388 | { | 385 | { |
| 389 | - if ((GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND310P)) { | 386 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 387 | + if (npuArch != NpuArch::DAV_2002) { | ||
| 390 | return false; | 388 | return false; |
| 391 | } | 389 | } |
| 392 | if (x1->GetDataType() != DataType::DT_FLOAT16 || x2->GetDataType() != DataType::DT_FLOAT16) { | 390 | if (x1->GetDataType() != DataType::DT_FLOAT16 || x2->GetDataType() != DataType::DT_FLOAT16) { |
| @@ -607,9 +605,8 @@ static const aclTensor* HandleEmptyTensor(const aclTensor* self, const aclTensor | |||
| 607 | auto emptyOut = ProcessEmptyTensor(self, mat2, executor); | 605 | auto emptyOut = ProcessEmptyTensor(self, mat2, executor); |
| 608 | CHECK_RET(emptyOut != nullptr, nullptr); | 606 | CHECK_RET(emptyOut != nullptr, nullptr); |
| 609 | // output cast | 607 | // output cast |
| 610 | - if ((GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 608 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 611 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93) && | 609 | + if ((npuArch == NpuArch::DAV_2201) && cubeMathType == FP16FP32_KEEP_DTYPE) { |
| 612 | - cubeMathType == FP16FP32_KEEP_DTYPE) { | ||
| 613 | auto castOut = l0op::Cast(emptyOut, DataType::DT_FLOAT, executor); | 610 | auto castOut = l0op::Cast(emptyOut, DataType::DT_FLOAT, executor); |
| 614 | CHECK_RET(castOut != nullptr, nullptr); | 611 | CHECK_RET(castOut != nullptr, nullptr); |
| 615 | return castOut; | 612 | return castOut; |
| @@ -619,8 +616,9 @@ static const aclTensor* HandleEmptyTensor(const aclTensor* self, const aclTensor | |||
| 619 | 616 | ||
| 620 | static bool IsUseNonContiguous(const aclTensor* tensor) | 617 | static bool IsUseNonContiguous(const aclTensor* tensor) |
| 621 | { | 618 | { |
| 622 | - // Only support ASCEND950 | 619 | + // Only support 3510 |
| 623 | - if (GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND950) { | 620 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 621 | + if (npuArch != NpuArch::DAV_3510) { | ||
| 624 | return false; | 622 | return false; |
| 625 | } | 623 | } |
| 626 | return !IsContiguous(tensor); | 624 | return !IsContiguous(tensor); |
| @@ -707,9 +705,10 @@ static aclnnStatus SetMatmulOpSupportFormat( | |||
| 707 | 705 | ||
| 708 | if (IsSplitk(&SpTensor_sefl, &SpTensor_mat2)) { | 706 | if (IsSplitk(&SpTensor_sefl, &SpTensor_mat2)) { |
| 709 | mmOpInfo.supporSplitK = true; | 707 | mmOpInfo.supporSplitK = true; |
| 710 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310P) { | 708 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 709 | + if (npuArch == NpuArch::DAV_2002) { | ||
| 711 | mmOpInfo.support_info.output_dtype = DataType::DT_FLOAT; | 710 | mmOpInfo.support_info.output_dtype = DataType::DT_FLOAT; |
| 712 | - } else if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910) { | 711 | + } else if (npuArch == NpuArch::DAV_1001) { |
| 713 | if(CheckMMV3NzNzNdSupport(mat2)){ | 712 | if(CheckMMV3NzNzNdSupport(mat2)){ |
| 714 | mmOpInfo.support_info.output_format = Format::FORMAT_ND; | 713 | mmOpInfo.support_info.output_format = Format::FORMAT_ND; |
| 715 | }else{ | 714 | }else{ |
| @@ -969,8 +968,8 @@ MmOpInfo GetMatmulOpInfo(const aclTensor* self, const aclTensor* mat2, int8_t cu | |||
| 969 | mmOpInfo.support_info.mat2_dtype == DataType::DT_FLOAT; | 968 | mmOpInfo.support_info.mat2_dtype == DataType::DT_FLOAT; |
| 970 | // 如果允许降精度处理, 则开启HF32模式(0x40),否则采用默认模式; 后续此字段配置需要按照字段表进行配置 | 969 | // 如果允许降精度处理, 则开启HF32模式(0x40),否则采用默认模式; 后续此字段配置需要按照字段表进行配置 |
| 971 | mmOpInfo.enableHf32 = (cubeMathType == ALLOW_FP32_DOWN_PRECISION) || (cubeMathType == USE_HF32); | 970 | mmOpInfo.enableHf32 = (cubeMathType == ALLOW_FP32_DOWN_PRECISION) || (cubeMathType == USE_HF32); |
| 972 | - mmOpInfo.enableForceGrpAccForFp32 = cubeMathType == FORCE_GRP_ACC_FOR_FP32 && (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 971 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 973 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93); | 972 | + mmOpInfo.enableForceGrpAccForFp32 = cubeMathType == FORCE_GRP_ACC_FOR_FP32 && (npuArch == NpuArch::DAV_2201); |
| 974 | mmOpInfo.opImplModeEnum = mmOpInfo.enableHf32 ? 0x40 : (mmOpInfo.enableForceGrpAccForFp32 ? 0x4 : 0x1); | 973 | mmOpInfo.opImplModeEnum = mmOpInfo.enableHf32 ? 0x40 : (mmOpInfo.enableForceGrpAccForFp32 ? 0x4 : 0x1); |
| 975 | OP_LOGD( | 974 | OP_LOGD( |
| 976 | "opImplModeEnum=%ld, enableHf32=%d, enableForceGrpAccForFp32=%d cubeMathType=%d, inputFp32Flag= %d", mmOpInfo.opImplModeEnum, | 975 | "opImplModeEnum=%ld, enableHf32=%d, enableForceGrpAccForFp32=%d cubeMathType=%d, inputFp32Flag= %d", mmOpInfo.opImplModeEnum, |
| @@ -1011,8 +1010,8 @@ aclnnStatus CreateMatmulOpInfo(const aclTensor* self, const aclTensor* mat2, con | |||
| 1011 | mmOpInfo.shapeInfo.dtypeBSize); | 1010 | mmOpInfo.shapeInfo.dtypeBSize); |
| 1012 | 1011 | ||
| 1013 | // 解析当前规格matmulop支持的dtype能力 | 1012 | // 解析当前规格matmulop支持的dtype能力 |
| 1014 | - std::shared_ptr<SocMatMulRuleBase> socRule = SocMatMulRule::getInstance(); | 1013 | + std::shared_ptr<NpuArchMatMulRuleBase> archRule = NpuArchMatMulRule::getInstance(); |
| 1015 | - aclnnStatus status = socRule -> PromoteDtype(self, mat2, bias, out, cubeMathType, mmOpInfo); | 1014 | + aclnnStatus status = archRule -> PromoteDtype(self, mat2, bias, out, cubeMathType, mmOpInfo); |
| 1016 | CHECK_RET(status == ACLNN_SUCCESS, status); | 1015 | CHECK_RET(status == ACLNN_SUCCESS, status); |
| 1017 | 1016 | ||
| 1018 | // 不同芯片能力不同 | 1017 | // 不同芯片能力不同 |
| @@ -1027,8 +1026,8 @@ aclnnStatus CreateMatmulOpInfo(const aclTensor* self, const aclTensor* mat2, con | |||
| 1027 | mmOpInfo.support_info.mat2_dtype == DataType::DT_FLOAT; | 1026 | mmOpInfo.support_info.mat2_dtype == DataType::DT_FLOAT; |
| 1028 | // 如果允许降精度处理, 则开启HF32模式(0x40),否则采用默认模式; 后续此字段配置需要按照字段表进行配置 | 1027 | // 如果允许降精度处理, 则开启HF32模式(0x40),否则采用默认模式; 后续此字段配置需要按照字段表进行配置 |
| 1029 | mmOpInfo.enableHf32 = (cubeMathType == ALLOW_FP32_DOWN_PRECISION) || (cubeMathType == USE_HF32); | 1028 | mmOpInfo.enableHf32 = (cubeMathType == ALLOW_FP32_DOWN_PRECISION) || (cubeMathType == USE_HF32); |
| 1030 | - mmOpInfo.enableForceGrpAccForFp32 = cubeMathType == FORCE_GRP_ACC_FOR_FP32 && (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 1029 | + mmOpInfo.enableForceGrpAccForFp32 = (cubeMathType == FORCE_GRP_ACC_FOR_FP32) && |
| 1031 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93); | 1030 | + (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201); |
| 1032 | mmOpInfo.opImplModeEnum = mmOpInfo.enableHf32 ? 0x40 : (mmOpInfo.enableForceGrpAccForFp32 ? 0x4 : 0x1); | 1031 | mmOpInfo.opImplModeEnum = mmOpInfo.enableHf32 ? 0x40 : (mmOpInfo.enableForceGrpAccForFp32 ? 0x4 : 0x1); |
| 1033 | OP_LOGD( | 1032 | OP_LOGD( |
| 1034 | "opImplModeEnum=%ld, enableHf32=%d, enableForceGrpAccForFp32=%d cubeMathType=%d, inputFp32Flag= %d", mmOpInfo.opImplModeEnum, | 1033 | "opImplModeEnum=%ld, enableHf32=%d, enableForceGrpAccForFp32=%d cubeMathType=%d, inputFp32Flag= %d", mmOpInfo.opImplModeEnum, |
| @@ -1523,14 +1522,13 @@ bool CheckGemmV3Support(const aclTensor* mat1, const aclTensor* mat2, MmOpInfo& | |||
| 1523 | return false; | 1522 | return false; |
| 1524 | } | 1523 | } |
| 1525 | // 当前支持平台 | 1524 | // 当前支持平台 |
| 1526 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 1525 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 1527 | - if (socVersion != SocVersion::ASCEND950 && socVersion != SocVersion::ASCEND910B && | 1526 | + if ((npuArch != NpuArch::DAV_2201) && (npuArch != NpuArch::DAV_3510)) { |
| 1528 | - socVersion != SocVersion::ASCEND910_93) { | 1527 | + OP_LOGI("Current npu arch does not support GemmV3."); |
| 1529 | - OP_LOGI("Current SOC version does not support GemmV3."); | ||
| 1530 | return false; | 1528 | return false; |
| 1531 | } | 1529 | } |
| 1532 | 1530 | ||
| 1533 | - if (socVersion == SocVersion::ASCEND910B || socVersion == SocVersion::ASCEND910_93) { | 1531 | + if (npuArch == NpuArch::DAV_2201) { |
| 1534 | auto dtype_mat1 = mat1->GetDataType(); | 1532 | auto dtype_mat1 = mat1->GetDataType(); |
| 1535 | auto dtype_mat2 = mat2->GetDataType(); | 1533 | auto dtype_mat2 = mat2->GetDataType(); |
| 1536 | if (!((dtype_mat1 == DataType::DT_FLOAT16 && dtype_mat2 == DataType::DT_FLOAT16) || | 1534 | if (!((dtype_mat1 == DataType::DT_FLOAT16 && dtype_mat2 == DataType::DT_FLOAT16) || |
| @@ -1562,14 +1560,13 @@ bool CheckGemmV3Support(const aclTensor* mat1, const aclTensor* mat2, const aclT | |||
| 1562 | return false; | 1560 | return false; |
| 1563 | } | 1561 | } |
| 1564 | // 当前支持平台 | 1562 | // 当前支持平台 |
| 1565 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 1563 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 1566 | - if (socVersion != SocVersion::ASCEND950 && socVersion != SocVersion::ASCEND910B && | 1564 | + if ((npuArch != NpuArch::DAV_2201) && (npuArch != NpuArch::DAV_3510)) { |
| 1567 | - socVersion != SocVersion::ASCEND910_93) { | 1565 | + OP_LOGI("Current npu arch does not support GemmV3."); |
| 1568 | - OP_LOGI("Current SOC version does not support GemmV3."); | ||
| 1569 | return false; | 1566 | return false; |
| 1570 | } | 1567 | } |
| 1571 | 1568 | ||
| 1572 | - if (socVersion == SocVersion::ASCEND910B || socVersion == SocVersion::ASCEND910_93) { | 1569 | + if (npuArch == NpuArch::DAV_2201) { |
| 1573 | auto dtype_mat1 = mat1->GetDataType(); | 1570 | auto dtype_mat1 = mat1->GetDataType(); |
| 1574 | auto dtype_mat2 = mat2->GetDataType(); | 1571 | auto dtype_mat2 = mat2->GetDataType(); |
| 1575 | if (!((dtype_mat1 == DataType::DT_FLOAT16 && dtype_mat2 == DataType::DT_FLOAT16) || | 1572 | if (!((dtype_mat1 == DataType::DT_FLOAT16 && dtype_mat2 == DataType::DT_FLOAT16) || |
| @@ -1636,9 +1633,8 @@ const aclTensor* ExecGemmV3Op( | |||
| 1636 | } | 1633 | } |
| 1637 | 1634 | ||
| 1638 | bool IsInputSupportFp32() { | 1635 | bool IsInputSupportFp32() { |
| 1639 | - if (op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910B && | 1636 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 1640 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910_93 && | 1637 | + if ((npuArch != NpuArch::DAV_2201) && (npuArch != NpuArch::DAV_3510)) { |
| 1641 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND950) { | ||
| 1642 | return false; | 1638 | return false; |
| 1643 | } | 1639 | } |
| 1644 | return true; | 1640 | return true; |
| @@ -1696,9 +1692,8 @@ bool NeedToConvertBias(const aclTensor *self, const aclTensor *mat1, const aclTe | |||
| 1696 | TensorInfo Tensor_mat2 = {mat2, mat2->GetDataType(), Format::FORMAT_ND}; | 1692 | TensorInfo Tensor_mat2 = {mat2, mat2->GetDataType(), Format::FORMAT_ND}; |
| 1697 | 1693 | ||
| 1698 | bool isSplitK = false; | 1694 | bool isSplitK = false; |
| 1699 | - if (op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910B && | 1695 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 1700 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND910_93 && | 1696 | + if ((npuArch != NpuArch::DAV_2201) && (npuArch != NpuArch::DAV_3510)) { |
| 1701 | - op::GetCurrentPlatformInfo().GetSocVersion() != op::SocVersion::ASCEND950) { | ||
| 1702 | isSplitK = IsSplitk(&Tensor_matl, &Tensor_mat2);; | 1697 | isSplitK = IsSplitk(&Tensor_matl, &Tensor_mat2);; |
| 1703 | } | 1698 | } |
| 1704 | op::Shape selfShape = self->GetViewShape(); | 1699 | op::Shape selfShape = self->GetViewShape(); |
| @@ -1760,11 +1755,11 @@ bool IsSplitk(const TensorInfo* self, const TensorInfo* mat2) { | |||
| 1760 | } | 1755 | } |
| 1761 | 1756 | ||
| 1762 | bool IsFormatSupportNd(const aclTensor *self, const aclTensor *mat2) { | 1757 | bool IsFormatSupportNd(const aclTensor *self, const aclTensor *mat2) { |
| 1763 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND950) { | 1758 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 1759 | + if (npuArch == NpuArch::DAV_3510) { | ||
| 1764 | return true; | 1760 | return true; |
| 1765 | } | 1761 | } |
| 1766 | - if (GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND910B && | 1762 | + if (npuArch != NpuArch::DAV_2201) { |
| 1767 | - GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND910_93) { | ||
| 1768 | op::Shape selfShape = self->GetViewShape(); | 1763 | op::Shape selfShape = self->GetViewShape(); |
| 1769 | op::Shape mat2Shape = mat2->GetViewShape(); | 1764 | op::Shape mat2Shape = mat2->GetViewShape(); |
| 1770 | int64_t dimNum = selfShape.GetDimNum(); | 1765 | int64_t dimNum = selfShape.GetDimNum(); |
| @@ -1907,9 +1902,9 @@ aclnnStatus SetMmSupportFormat(const aclTensor* self, const aclTensor* mat2, MmO | |||
| 1907 | mmOpInfo.support_info.mat2_format = Format::FORMAT_ND; | 1902 | mmOpInfo.support_info.mat2_format = Format::FORMAT_ND; |
| 1908 | } else { | 1903 | } else { |
| 1909 | OP_LOGD("Matmul do not support NDNDND"); | 1904 | OP_LOGD("Matmul do not support NDNDND"); |
| 1910 | - // if 310p and n%16==0 | 1905 | + // if Dav2002 and n%16==0 |
| 1911 | - bool is310p = GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310P; | 1906 | + bool isDav2002 = (op::GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2002); |
| 1912 | - if (IsSupportNzNzNd(self, mat2) && is310p) { | 1907 | + if (IsSupportNzNzNd(self, mat2) && isDav2002) { |
| 1913 | mmOpInfo.support_info.output_format = Format::FORMAT_ND; | 1908 | mmOpInfo.support_info.output_format = Format::FORMAT_ND; |
| 1914 | mmOpInfo.support_info.self_format = Format::FORMAT_FRACTAL_NZ; | 1909 | mmOpInfo.support_info.self_format = Format::FORMAT_FRACTAL_NZ; |
| 1915 | mmOpInfo.support_info.mat2_format = Format::FORMAT_FRACTAL_NZ; | 1910 | mmOpInfo.support_info.mat2_format = Format::FORMAT_FRACTAL_NZ; |
| @@ -2118,7 +2113,7 @@ const aclTensor *ContiguousBias(const aclTensor *self, const aclTensor *bias, ac | |||
| 2118 | CHECK_RET(contiguousBias != nullptr, nullptr); | 2113 | CHECK_RET(contiguousBias != nullptr, nullptr); |
| 2119 | // bias为bf16时cast为fp32保证精度 | 2114 | // bias为bf16时cast为fp32保证精度 |
| 2120 | if ((contiguousBias->GetDataType() == DataType::DT_BF16 && | 2115 | if ((contiguousBias->GetDataType() == DataType::DT_BF16 && |
| 2121 | - GetCurrentPlatformInfo().GetSocVersion() != SocVersion::ASCEND950)|| | 2116 | + GetCurrentPlatformInfo().GetCurNpuArch() != NpuArch::DAV_3510)|| |
| 2122 | self->GetDataType() == DataType::DT_FLOAT) { | 2117 | self->GetDataType() == DataType::DT_FLOAT) { |
| 2123 | contiguousBias = l0op::Cast(contiguousBias, op::DataType::DT_FLOAT, executor); | 2118 | contiguousBias = l0op::Cast(contiguousBias, op::DataType::DT_FLOAT, executor); |
| 2124 | CHECK_RET(contiguousBias != nullptr, nullptr); | 2119 | CHECK_RET(contiguousBias != nullptr, nullptr); |
| @@ -2155,9 +2150,9 @@ aclnnStatus MatmulGraphImpl::CommonPostProcessWithReshape(){ | |||
| 2155 | } | 2150 | } |
| 2156 | 2151 | ||
| 2157 | // ========================================================================================================== | 2152 | // ========================================================================================================== |
| 2158 | -// SocMatMulRuleBase | 2153 | +// NpuArchMatMulRuleBase |
| 2159 | 2154 | ||
| 2160 | -bool SocMatMulRuleBase::CheckInputTensorDtypeValid(const aclTensor* self, const aclTensor* mat2, const aclTensor* bias, const aclTensor* out) { | 2155 | +bool NpuArchMatMulRuleBase::CheckInputTensorDtypeValid(const aclTensor* self, const aclTensor* mat2, const aclTensor* bias, const aclTensor* out) { |
| 2161 | auto dtypeList = GetSupportedDTypes(); | 2156 | auto dtypeList = GetSupportedDTypes(); |
| 2162 | OP_CHECK_DTYPE_NOT_SUPPORT(self, dtypeList, return false); | 2157 | OP_CHECK_DTYPE_NOT_SUPPORT(self, dtypeList, return false); |
| 2163 | OP_CHECK_DTYPE_NOT_SUPPORT(mat2, dtypeList, return false); | 2158 | OP_CHECK_DTYPE_NOT_SUPPORT(mat2, dtypeList, return false); |
| @@ -2170,7 +2165,7 @@ bool SocMatMulRuleBase::CheckInputTensorDtypeValid(const aclTensor* self, const | |||
| 2170 | return true; | 2165 | return true; |
| 2171 | } | 2166 | } |
| 2172 | 2167 | ||
| 2173 | -aclnnStatus SocMatMulRuleBase::GetUpperDtype(const aclTensor* matA, const aclTensor* matB, int8_t cubeMathType, op::DataType& upperDtype){ | 2168 | +aclnnStatus NpuArchMatMulRuleBase::GetUpperDtype(const aclTensor* matA, const aclTensor* matB, int8_t cubeMathType, op::DataType& upperDtype){ |
| 2174 | op::DataType typeA = matA -> GetDataType(); | 2169 | op::DataType typeA = matA -> GetDataType(); |
| 2175 | op::DataType typeB = matB -> GetDataType(); | 2170 | op::DataType typeB = matB -> GetDataType(); |
| 2176 | OP_LOGD("The input dtype is %s and %s", op::ToString(typeA).GetString(), op::ToString(typeB).GetString()); | 2171 | OP_LOGD("The input dtype is %s and %s", op::ToString(typeA).GetString(), op::ToString(typeB).GetString()); |
| @@ -2191,9 +2186,9 @@ aclnnStatus SocMatMulRuleBase::GetUpperDtype(const aclTensor* matA, const aclTen | |||
| 2191 | return ACLNN_SUCCESS; | 2186 | return ACLNN_SUCCESS; |
| 2192 | } | 2187 | } |
| 2193 | 2188 | ||
| 2194 | -bool Ascend910BMatMulRule::CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) { | 2189 | +bool Dav2201MatMulRule::CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) { |
| 2195 | if (FP16FP32_KEEP_DTYPE == cubeMathType) { | 2190 | if (FP16FP32_KEEP_DTYPE == cubeMathType) { |
| 2196 | - if (socVersion != op::SocVersion::ASCEND910B || socVersion != op::SocVersion::ASCEND910_93) { | 2191 | + if (npuArch_ != NpuArch::DAV_2201) { |
| 2197 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Unsupported cubeMathType(FP16FP32_KEEP_DTYPE) for Cube"); | 2192 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Unsupported cubeMathType(FP16FP32_KEEP_DTYPE) for Cube"); |
| 2198 | return false; | 2193 | return false; |
| 2199 | } | 2194 | } |
| @@ -2206,7 +2201,7 @@ bool Ascend910BMatMulRule::CheckInput(const aclTensor* matA, const aclTensor* ma | |||
| 2206 | return dtypeVaild; | 2201 | return dtypeVaild; |
| 2207 | } | 2202 | } |
| 2208 | 2203 | ||
| 2209 | -aclnnStatus Ascend910BMatMulRule::PromoteDtype(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType, struct MmOpInfo& mmOpInfo) { | 2204 | +aclnnStatus Dav2201MatMulRule::PromoteDtype(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType, struct MmOpInfo& mmOpInfo) { |
| 2210 | // 输入数据类型 | 2205 | // 输入数据类型 |
| 2211 | mmOpInfo.ori_info.self_dtype = matA->GetDataType(); | 2206 | mmOpInfo.ori_info.self_dtype = matA->GetDataType(); |
| 2212 | mmOpInfo.ori_info.mat2_dtype = matB->GetDataType(); | 2207 | mmOpInfo.ori_info.mat2_dtype = matB->GetDataType(); |
| @@ -2247,13 +2242,13 @@ aclnnStatus Ascend910BMatMulRule::PromoteDtype(const aclTensor* matA, const aclT | |||
| 2247 | } | 2242 | } |
| 2248 | 2243 | ||
| 2249 | 2244 | ||
| 2250 | -std::initializer_list<op::DataType> Ascend910BMatMulRule::GetSupportedDTypes(){ | 2245 | +std::initializer_list<op::DataType> Dav2201MatMulRule::GetSupportedDTypes(){ |
| 2251 | static constexpr std::initializer_list<op::DataType> dtypeSupportList = { | 2246 | static constexpr std::initializer_list<op::DataType> dtypeSupportList = { |
| 2252 | op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_BF16}; | 2247 | op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16, op::DataType::DT_BF16}; |
| 2253 | return dtypeSupportList; | 2248 | return dtypeSupportList; |
| 2254 | } | 2249 | } |
| 2255 | 2250 | ||
| 2256 | -SocMatMulRuleBase::PromoteResult Ascend910BMatMulRule::GetUpperDtypeByLookUpTable(int inputCase, int8_t cubeMathType) { | 2251 | +NpuArchMatMulRuleBase::PromoteResult Dav2201MatMulRule::GetUpperDtypeByLookUpTable(int inputCase, int8_t cubeMathType) { |
| 2257 | static constexpr const char* WARN0 = "The cubeMathType USE_HF32 will be ignored when the input dtype is FP16 or BF16."; | 2252 | static constexpr const char* WARN0 = "The cubeMathType USE_HF32 will be ignored when the input dtype is FP16 or BF16."; |
| 2258 | 2253 | ||
| 2259 | static constexpr const char* WARN1 = "The cubeMathType KEEP_DTYPE will be ignored when the inputs dtype are BF16 and FP16."; | 2254 | static constexpr const char* WARN1 = "The cubeMathType KEEP_DTYPE will be ignored when the inputs dtype are BF16 and FP16."; |
| @@ -2269,7 +2264,7 @@ SocMatMulRuleBase::PromoteResult Ascend910BMatMulRule::GetUpperDtypeByLookUpTabl | |||
| 2269 | static constexpr const char* WARN6 = "The inputs are BF16 and FP32 with cubeMathType USE_FP16, BF16 will be cast to FP16 for computation."; | 2264 | static constexpr const char* WARN6 = "The inputs are BF16 and FP32 with cubeMathType USE_FP16, BF16 will be cast to FP16 for computation."; |
| 2270 | 2265 | ||
| 2271 | if (FP16FP32_KEEP_DTYPE == cubeMathType) { | 2266 | if (FP16FP32_KEEP_DTYPE == cubeMathType) { |
| 2272 | - if (socVersion != op::SocVersion::ASCEND910B || socVersion != op::SocVersion::ASCEND910_93) { | 2267 | + if (npuArch_ != NpuArch::DAV_2201) { |
| 2273 | return {FP32, true, "Unsupported cubeMathType(FP16FP32_KEEP_DTYPE) for Cube"}; | 2268 | return {FP32, true, "Unsupported cubeMathType(FP16FP32_KEEP_DTYPE) for Cube"}; |
| 2274 | } else { | 2269 | } else { |
| 2275 | // cubeMathType为KEEP_DTYPE时保持一致 | 2270 | // cubeMathType为KEEP_DTYPE时保持一致 |
| @@ -2277,7 +2272,7 @@ SocMatMulRuleBase::PromoteResult Ascend910BMatMulRule::GetUpperDtypeByLookUpTabl | |||
| 2277 | } | 2272 | } |
| 2278 | } | 2273 | } |
| 2279 | 2274 | ||
| 2280 | - static constexpr SocMatMulRuleBase::PromoteResult promoteResultTable[][6] = { | 2275 | + static constexpr NpuArchMatMulRuleBase::PromoteResult promoteResultTable[][6] = { |
| 2281 | /* cubeMathType: KEEP_DTYPE, ALLOW_FP32_DOWN_P, USE_FP16, USE_HF32, FORCE_GRP_ACC_FOR_FP32, USE_HIGH_PREC_MODE */ | 2276 | /* cubeMathType: KEEP_DTYPE, ALLOW_FP32_DOWN_P, USE_FP16, USE_HF32, FORCE_GRP_ACC_FOR_FP32, USE_HIGH_PREC_MODE */ |
| 2282 | /*0: FP32+FP32*/ {{FP32, false, ""}, {FP32, false, ""}, {FP16, false, ""}, {FP32, false, ""}, {FP32, false, ""}, {FP32, false, ""}}, | 2277 | /*0: FP32+FP32*/ {{FP32, false, ""}, {FP32, false, ""}, {FP16, false, ""}, {FP32, false, ""}, {FP32, false, ""}, {FP32, false, ""}}, |
| 2283 | /*1: FP32+FP16*/ {{FP32, false, ""}, {FP32, false, ""}, {FP16, false, ""}, {FP32, false, ""}, {FP32, false, ""}, {FP32, false, ""}}, | 2278 | /*1: FP32+FP16*/ {{FP32, false, ""}, {FP32, false, ""}, {FP16, false, ""}, {FP32, false, ""}, {FP32, false, ""}, {FP32, false, ""}}, |
| @@ -2290,32 +2285,31 @@ SocMatMulRuleBase::PromoteResult Ascend910BMatMulRule::GetUpperDtypeByLookUpTabl | |||
| 2290 | return promoteResultTable[inputCase][cubeMathType]; | 2285 | return promoteResultTable[inputCase][cubeMathType]; |
| 2291 | } | 2286 | } |
| 2292 | 2287 | ||
| 2293 | -op::DataType Ascend910BMatMulRule::UpdateOutputDtype( | 2288 | +op::DataType Dav2201MatMulRule::UpdateOutputDtype( |
| 2294 | op::DataType upperDtype, op::DataType outOriDtype, int8_t cubeMathType) const { | 2289 | op::DataType upperDtype, op::DataType outOriDtype, int8_t cubeMathType) const { |
| 2295 | // 支持FP32的类型的out参与计算, out可以保持输入要求的类型,不需要做cast | 2290 | // 支持FP32的类型的out参与计算, out可以保持输入要求的类型,不需要做cast |
| 2296 | - if ((socVersion == op::SocVersion::ASCEND910B || socVersion == op::SocVersion::ASCEND910_93) && | 2291 | + if ((npuArch_ == NpuArch::DAV_2201) && |
| 2297 | (cubeMathType != USE_FP16) && outOriDtype == op::DataType::DT_FLOAT) { | 2292 | (cubeMathType != USE_FP16) && outOriDtype == op::DataType::DT_FLOAT) { |
| 2298 | return op::DataType::DT_FLOAT; | 2293 | return op::DataType::DT_FLOAT; |
| 2299 | } | 2294 | } |
| 2300 | return upperDtype; | 2295 | return upperDtype; |
| 2301 | } | 2296 | } |
| 2302 | 2297 | ||
| 2303 | -op::DataType Ascend910BMatMulRule::UpdateBiasDtype(op::DataType upperDtype, op::DataType biasOriDtype) const { | 2298 | +op::DataType Dav2201MatMulRule::UpdateBiasDtype(op::DataType upperDtype, op::DataType biasOriDtype) const { |
| 2304 | if (biasOriDtype == op::DataType::DT_FLOAT) { | 2299 | if (biasOriDtype == op::DataType::DT_FLOAT) { |
| 2305 | return biasOriDtype; | 2300 | return biasOriDtype; |
| 2306 | } | 2301 | } |
| 2307 | if (biasOriDtype != upperDtype){ | 2302 | if (biasOriDtype != upperDtype){ |
| 2308 | return op::DataType::DT_FLOAT; | 2303 | return op::DataType::DT_FLOAT; |
| 2309 | } | 2304 | } |
| 2310 | - if ((socVersion == op::SocVersion::ASCEND910B || socVersion == op::SocVersion::ASCEND910_93) && upperDtype == op::DataType::DT_BF16){ | 2305 | + if ((npuArch_ == NpuArch::DAV_2201) && (upperDtype == op::DataType::DT_BF16)){ |
| 2311 | - // | ||
| 2312 | return op::DataType::DT_FLOAT; | 2306 | return op::DataType::DT_FLOAT; |
| 2313 | } | 2307 | } |
| 2314 | return upperDtype; | 2308 | return upperDtype; |
| 2315 | } | 2309 | } |
| 2316 | 2310 | ||
| 2317 | 2311 | ||
| 2318 | -bool Ascend310AMatMulRule::CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) { | 2312 | +bool DefaultMatMulRule::CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) { |
| 2319 | bool dtypeVaild = CheckInputTensorDtypeValid(matA, matB, bias, out); | 2313 | bool dtypeVaild = CheckInputTensorDtypeValid(matA, matB, bias, out); |
| 2320 | if (dtypeVaild == false) { | 2314 | if (dtypeVaild == false) { |
| 2321 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Unsupported data types for Cube"); | 2315 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Unsupported data types for Cube"); |
| @@ -2323,19 +2317,19 @@ bool Ascend310AMatMulRule::CheckInput(const aclTensor* matA, const aclTensor* ma | |||
| 2323 | } | 2317 | } |
| 2324 | bool isFp32TypeExist = matA->GetDataType() == op::DataType::DT_FLOAT || matB->GetDataType() == op::DataType::DT_FLOAT; | 2318 | bool isFp32TypeExist = matA->GetDataType() == op::DataType::DT_FLOAT || matB->GetDataType() == op::DataType::DT_FLOAT; |
| 2325 | if(isFp32TypeExist && (cubeMathType == USE_HF32 || cubeMathType == KEEP_DTYPE)) { | 2319 | if(isFp32TypeExist && (cubeMathType == USE_HF32 || cubeMathType == KEEP_DTYPE)) { |
| 2326 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The soc version does not support FP32 for calculations when the cubeMathType is KEEP_DTYPE or USE_HF32, " | 2320 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The npu arch does not support FP32 for calculations when the cubeMathType is KEEP_DTYPE or USE_HF32, " |
| 2327 | "please change the setting of cubeMathType or the Dtype of input tensor."); | 2321 | "please change the setting of cubeMathType or the Dtype of input tensor."); |
| 2328 | return false; | 2322 | return false; |
| 2329 | } | 2323 | } |
| 2330 | if(isFp32TypeExist && cubeMathType == FP16FP32_KEEP_DTYPE) { | 2324 | if(isFp32TypeExist && cubeMathType == FP16FP32_KEEP_DTYPE) { |
| 2331 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The soc version does not support FP32 for calculations when the cubeMathType is FP16FP32_KEEP_DTYPE, " | 2325 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The npu arch does not support FP32 for calculations when the cubeMathType is FP16FP32_KEEP_DTYPE, " |
| 2332 | "please change the setting of cubeMathType or the Dtype of input tensor."); | 2326 | "please change the setting of cubeMathType or the Dtype of input tensor."); |
| 2333 | return false; | 2327 | return false; |
| 2334 | } | 2328 | } |
| 2335 | return true; | 2329 | return true; |
| 2336 | } | 2330 | } |
| 2337 | 2331 | ||
| 2338 | -aclnnStatus Ascend310AMatMulRule::PromoteDtype(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType, struct MmOpInfo& mmOpInfo) { | 2332 | +aclnnStatus DefaultMatMulRule::PromoteDtype(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType, struct MmOpInfo& mmOpInfo) { |
| 2339 | // 输入数据类型 | 2333 | // 输入数据类型 |
| 2340 | mmOpInfo.ori_info.self_dtype = matA->GetDataType(); | 2334 | mmOpInfo.ori_info.self_dtype = matA->GetDataType(); |
| 2341 | mmOpInfo.ori_info.mat2_dtype = matB->GetDataType(); | 2335 | mmOpInfo.ori_info.mat2_dtype = matB->GetDataType(); |
| @@ -2377,17 +2371,18 @@ aclnnStatus Ascend310AMatMulRule::PromoteDtype(const aclTensor* matA, const aclT | |||
| 2377 | return ACLNN_SUCCESS; | 2371 | return ACLNN_SUCCESS; |
| 2378 | } | 2372 | } |
| 2379 | 2373 | ||
| 2380 | -std::initializer_list<op::DataType> Ascend310AMatMulRule::GetSupportedDTypes(){ | 2374 | +std::initializer_list<op::DataType> DefaultMatMulRule::GetSupportedDTypes(){ |
| 2381 | static constexpr std::initializer_list<op::DataType> dtypeSupportList = { | 2375 | static constexpr std::initializer_list<op::DataType> dtypeSupportList = { |
| 2382 | op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16}; | 2376 | op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16}; |
| 2383 | return dtypeSupportList; | 2377 | return dtypeSupportList; |
| 2384 | } | 2378 | } |
| 2385 | 2379 | ||
| 2386 | -SocMatMulRuleBase::PromoteResult Ascend310AMatMulRule::GetUpperDtypeByLookUpTable(int inputCase, int8_t cubeMathType){ | 2380 | +NpuArchMatMulRuleBase::PromoteResult DefaultMatMulRule::GetUpperDtypeByLookUpTable(int inputCase, int8_t cubeMathType){ |
| 2387 | static constexpr const char* WARN0 = "The cubeMathType is USE_HF32. For input FP16, it will not be enabled."; | 2381 | static constexpr const char* WARN0 = "The cubeMathType is USE_HF32. For input FP16, it will not be enabled."; |
| 2388 | 2382 | ||
| 2389 | - static constexpr const char* Err0 = "The soc version does not support FP32 for calculations when the cubeMathType is KEEP_DTYPE or USE_HF32, " | 2383 | + static constexpr const char* Err0 = "The npu arch does not support FP32 for calculations " |
| 2390 | - "please change the setting of cubeMathType or the Dtype of input tensor."; | 2384 | + "when the cubeMathType is KEEP_DTYPE or USE_HF32, " |
| 2385 | + "please change the setting of cubeMathType or the Dtype of input tensor."; | ||
| 2391 | if (FP16FP32_KEEP_DTYPE == cubeMathType) { | 2386 | if (FP16FP32_KEEP_DTYPE == cubeMathType) { |
| 2392 | // 和cubeMathType为KEEP_DTYPE时保持一致 | 2387 | // 和cubeMathType为KEEP_DTYPE时保持一致 |
| 2393 | cubeMathType = KEEP_DTYPE; | 2388 | cubeMathType = KEEP_DTYPE; |
| @@ -2402,7 +2397,7 @@ SocMatMulRuleBase::PromoteResult Ascend310AMatMulRule::GetUpperDtypeByLookUpTabl | |||
| 2402 | return promoteResultTable[inputCase][cubeMathType]; | 2397 | return promoteResultTable[inputCase][cubeMathType]; |
| 2403 | } | 2398 | } |
| 2404 | 2399 | ||
| 2405 | -op::DataType Ascend310AMatMulRule::UpdateOutputDtype(op::DataType upperDtype, op::DataType outOriDtype) const { | 2400 | +op::DataType DefaultMatMulRule::UpdateOutputDtype(op::DataType upperDtype, op::DataType outOriDtype) const { |
| 2406 | // 如果输出类型是FP32,则按照16进32出的逻辑计算 | 2401 | // 如果输出类型是FP32,则按照16进32出的逻辑计算 |
| 2407 | if (outOriDtype == op::DataType::DT_FLOAT) { | 2402 | if (outOriDtype == op::DataType::DT_FLOAT) { |
| 2408 | return outOriDtype; | 2403 | return outOriDtype; |
| @@ -2410,23 +2405,21 @@ op::DataType Ascend310AMatMulRule::UpdateOutputDtype(op::DataType upperDtype, op | |||
| 2410 | return upperDtype; | 2405 | return upperDtype; |
| 2411 | } | 2406 | } |
| 2412 | 2407 | ||
| 2413 | -op::DataType Ascend310AMatMulRule::PromoteOutputAndBiasDtype(op::DataType outputDtype, op::DataType biasOriDtype) const { | 2408 | +op::DataType DefaultMatMulRule::PromoteOutputAndBiasDtype(op::DataType outputDtype, op::DataType biasOriDtype) const { |
| 2414 | if (biasOriDtype == op::DataType::DT_FLOAT || outputDtype == op::DataType::DT_FLOAT) { | 2409 | if (biasOriDtype == op::DataType::DT_FLOAT || outputDtype == op::DataType::DT_FLOAT) { |
| 2415 | return op::DataType::DT_FLOAT; | 2410 | return op::DataType::DT_FLOAT; |
| 2416 | } | 2411 | } |
| 2417 | return op::DataType::DT_FLOAT16; | 2412 | return op::DataType::DT_FLOAT16; |
| 2418 | } | 2413 | } |
| 2419 | 2414 | ||
| 2420 | -std::shared_ptr<SocMatMulRuleBase> SocMatMulRule::instance = nullptr; | 2415 | +std::shared_ptr<NpuArchMatMulRuleBase> NpuArchMatMulRule::instance = nullptr; |
| 2421 | 2416 | ||
| 2422 | -std::shared_ptr<SocMatMulRuleBase> SocMatMulRule::BuildRule() { | 2417 | +std::shared_ptr<NpuArchMatMulRuleBase> NpuArchMatMulRule::BuildRule() { |
| 2423 | - op::SocVersion soc_version = GetCurrentPlatformInfo().GetSocVersion(); | 2418 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 2424 | - if (soc_version == op::SocVersion::ASCEND910B || | 2419 | + if ((npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510)) { |
| 2425 | - soc_version == op::SocVersion::ASCEND910_93 || | 2420 | + return std::make_shared<Dav2201MatMulRule>(npuArch); |
| 2426 | - soc_version == op::SocVersion::ASCEND950) { | ||
| 2427 | - return std::make_shared<Ascend910BMatMulRule>(soc_version); | ||
| 2428 | } else { | 2421 | } else { |
| 2429 | - return std::make_shared<Ascend310AMatMulRule>(soc_version); | 2422 | + return std::make_shared<DefaultMatMulRule>(npuArch); |
| 2430 | } | 2423 | } |
| 2431 | } | 2424 | } |
| 2432 | 2425 | ||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | namespace Ops { | 17 | namespace Ops { |
| 18 | namespace NN { | 18 | namespace NN { |
| 19 | +using namespace op; | ||
| 19 | // These are used to check repo hit | 20 | // These are used to check repo hit |
| 20 | const int32_t FP16_BF16_FLAG = 1; | 21 | const int32_t FP16_BF16_FLAG = 1; |
| 21 | const int32_t FP32_FLAG = 0; | 22 | const int32_t FP32_FLAG = 0; |
| @@ -89,7 +90,7 @@ bool IsTransposeLastTwoDims(const aclTensor* tensor); | |||
| 89 | bool CheckGemmV3Support(const aclTensor* mat1, const aclTensor* mat2, MmOpInfo& mmOpInfo, | 90 | bool CheckGemmV3Support(const aclTensor* mat1, const aclTensor* mat2, MmOpInfo& mmOpInfo, |
| 90 | int8_t cubeMathType); | 91 | int8_t cubeMathType); |
| 91 | 92 | ||
| 92 | -bool IsSliceNonContiguous(const aclTensor* tensor, const aclTensor* mat2); | 93 | +bool IsSliceNonContiguous(const aclTensor* self, const aclTensor* mat2); |
| 93 | 94 | ||
| 94 | bool IsTransposeNonContiguous(const aclTensor* tensor, bool& isNeedSwapInnerTwoDim); | 95 | bool IsTransposeNonContiguous(const aclTensor* tensor, bool& isNeedSwapInnerTwoDim); |
| 95 | 96 | ||
| @@ -248,24 +249,24 @@ protected: | |||
| 248 | 249 | ||
| 249 | // ====================================================================================================== | 250 | // ====================================================================================================== |
| 250 | 251 | ||
| 251 | -// SoC规则基类:抽象不同SoC的校验和数据类型推导逻辑 | 252 | +// NpuArch规则基类:抽象不同NpuArch的校验和数据类型推导逻辑 |
| 252 | -class SocMatMulRuleBase { | 253 | +class NpuArchMatMulRuleBase { |
| 253 | protected: | 254 | protected: |
| 254 | static const op::DataType FP16 = op::DataType::DT_FLOAT16; | 255 | static const op::DataType FP16 = op::DataType::DT_FLOAT16; |
| 255 | static const op::DataType FP32 = op::DataType::DT_FLOAT; | 256 | static const op::DataType FP32 = op::DataType::DT_FLOAT; |
| 256 | static const op::DataType BF16 = op::DataType::DT_BF16; | 257 | static const op::DataType BF16 = op::DataType::DT_BF16; |
| 257 | 258 | ||
| 258 | - // 存储SoC版本 | 259 | + // 存储NpuArch |
| 259 | - op::SocVersion socVersion; | 260 | + NpuArch npuArch_; |
| 260 | 261 | ||
| 261 | // 保护构造函数:禁止直接实例化基类(只能通过派生类构造) | 262 | // 保护构造函数:禁止直接实例化基类(只能通过派生类构造) |
| 262 | - SocMatMulRuleBase(op::SocVersion ascendSocVersion) : socVersion(ascendSocVersion) {} | 263 | + NpuArchMatMulRuleBase(NpuArch npuArch) : npuArch_(npuArch) {} |
| 263 | 264 | ||
| 264 | public: | 265 | public: |
| 265 | // 虚析构函数:确保派生类析构正常调用 | 266 | // 虚析构函数:确保派生类析构正常调用 |
| 266 | - virtual ~SocMatMulRuleBase() = default; | 267 | + virtual ~NpuArchMatMulRuleBase() = default; |
| 267 | 268 | ||
| 268 | - // 校验规则接口:检查当前输入是否符合SoC的约束 | 269 | + // 校验规则接口:检查当前输入是否符合NpuArch的约束 |
| 269 | // 返回:校验通过返回true,否则返回false | 270 | // 返回:校验通过返回true,否则返回false |
| 270 | virtual bool CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) = 0; | 271 | virtual bool CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) = 0; |
| 271 | 272 | ||
| @@ -319,13 +320,13 @@ protected: | |||
| 319 | aclnnStatus GetUpperDtype(const aclTensor* matA, const aclTensor* matB, int8_t cubeMathType, op::DataType& upperDtype); | 320 | aclnnStatus GetUpperDtype(const aclTensor* matA, const aclTensor* matB, int8_t cubeMathType, op::DataType& upperDtype); |
| 320 | }; | 321 | }; |
| 321 | 322 | ||
| 322 | -// 适用soc: ASCEND910B, ASCEND910_93, ASCEND950, | 323 | +// 适用arch: DAV_2201, DAV_3510 |
| 323 | -class Ascend910BMatMulRule : public SocMatMulRuleBase { | 324 | +class Dav2201MatMulRule : public NpuArchMatMulRuleBase { |
| 324 | public: | 325 | public: |
| 325 | - Ascend910BMatMulRule(op::SocVersion soc_version) | 326 | + Dav2201MatMulRule(NpuArch npu_arch) |
| 326 | - : SocMatMulRuleBase(soc_version) {} | 327 | + : NpuArchMatMulRuleBase(npu_arch) {} |
| 327 | 328 | ||
| 328 | - ~Ascend910BMatMulRule() override = default; | 329 | + ~Dav2201MatMulRule() override = default; |
| 329 | 330 | ||
| 330 | bool CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) override; | 331 | bool CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) override; |
| 331 | 332 | ||
| @@ -342,13 +343,13 @@ private: | |||
| 342 | op::DataType UpdateBiasDtype(op::DataType upperDtype, op::DataType biasOriDtype) const; | 343 | op::DataType UpdateBiasDtype(op::DataType upperDtype, op::DataType biasOriDtype) const; |
| 343 | }; | 344 | }; |
| 344 | 345 | ||
| 345 | -// 适用其他soc | 346 | +// 适用其他arch |
| 346 | -class Ascend310AMatMulRule : public SocMatMulRuleBase { | 347 | +class DefaultMatMulRule : public NpuArchMatMulRuleBase { |
| 347 | public: | 348 | public: |
| 348 | - Ascend310AMatMulRule(op::SocVersion soc_version) | 349 | + DefaultMatMulRule(NpuArch npu_arch) |
| 349 | - : SocMatMulRuleBase(soc_version) {} | 350 | + : NpuArchMatMulRuleBase(npu_arch) {} |
| 350 | 351 | ||
| 351 | - ~Ascend310AMatMulRule() override = default; | 352 | + ~DefaultMatMulRule() override = default; |
| 352 | 353 | ||
| 353 | bool CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) override; | 354 | bool CheckInput(const aclTensor* matA, const aclTensor* matB, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) override; |
| 354 | 355 | ||
| @@ -366,9 +367,9 @@ private: | |||
| 366 | }; | 367 | }; |
| 367 | 368 | ||
| 368 | // 单例 | 369 | // 单例 |
| 369 | -class SocMatMulRule { | 370 | +class NpuArchMatMulRule { |
| 370 | public: | 371 | public: |
| 371 | - static std::shared_ptr<SocMatMulRuleBase> getInstance() { | 372 | + static std::shared_ptr<NpuArchMatMulRuleBase> getInstance() { |
| 372 | if(instance == nullptr) { | 373 | if(instance == nullptr) { |
| 373 | instance = BuildRule(); | 374 | instance = BuildRule(); |
| 374 | } | 375 | } |
| @@ -376,9 +377,9 @@ public: | |||
| 376 | } | 377 | } |
| 377 | 378 | ||
| 378 | private: | 379 | private: |
| 379 | - static std::shared_ptr<SocMatMulRuleBase> instance; | 380 | + static std::shared_ptr<NpuArchMatMulRuleBase> instance; |
| 380 | 381 | ||
| 381 | - static std::shared_ptr<SocMatMulRuleBase> BuildRule() ; | 382 | + static std::shared_ptr<NpuArchMatMulRuleBase> BuildRule() ; |
| 382 | }; | 383 | }; |
| 383 | 384 | ||
| 384 | // ===================================================================================================== | 385 | // ===================================================================================================== |
| @@ -97,8 +97,8 @@ static int32_t PackToINT8(int32_t a, int32_t b, DataType dtype) { | |||
| 97 | 97 | ||
| 98 | static int64_t GetNdToNzC0Size(bool c032Flag) | 98 | static int64_t GetNdToNzC0Size(bool c032Flag) |
| 99 | { | 99 | { |
| 100 | - SocVersion socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 100 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 101 | - if (socVersion == SocVersion::ASCEND950) { | 101 | + if (npuArch == NpuArch::DAV_3510) { |
| 102 | if (c032Flag) { | 102 | if (c032Flag) { |
| 103 | return static_cast<int64_t>(C0_32) / static_cast<int64_t>(INT4_NUM_IN_BYTE); | 103 | return static_cast<int64_t>(C0_32) / static_cast<int64_t>(INT4_NUM_IN_BYTE); |
| 104 | } else { | 104 | } else { |
| @@ -219,9 +219,9 @@ static bool CheckStorageShapeVaild(const aclTensor *weightInt4Pack, int64_t weig | |||
| 219 | int64_t storageDim2 = weightInt4Pack->GetStorageShape().GetDim(weightInt4PackDimNum - INT4_NZ_DIM_ID2); | 219 | int64_t storageDim2 = weightInt4Pack->GetStorageShape().GetDim(weightInt4PackDimNum - INT4_NZ_DIM_ID2); |
| 220 | int64_t storageDim3 = weightInt4Pack->GetStorageShape().GetDim(weightInt4PackDimNum - INT4_NZ_DIM_ID1); | 220 | int64_t storageDim3 = weightInt4Pack->GetStorageShape().GetDim(weightInt4PackDimNum - INT4_NZ_DIM_ID1); |
| 221 | int64_t expDim1 = CeilDiv(weightInt4PackDimFirst, CUBE_BLOCK_SIZE); | 221 | int64_t expDim1 = CeilDiv(weightInt4PackDimFirst, CUBE_BLOCK_SIZE); |
| 222 | - SocVersion socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 222 | + NpuArch npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 223 | if (weightInt4Pack->GetDataType() == DataType::DT_INT4) { | 223 | if (weightInt4Pack->GetDataType() == DataType::DT_INT4) { |
| 224 | - int64_t lastDimSize = socVersion == SocVersion::ASCEND950 ? storageDim3 : INT4_NUM_IN_32B; | 224 | + int64_t lastDimSize = npuArch == NpuArch::DAV_3510 ? storageDim3 : INT4_NUM_IN_32B; |
| 225 | int64_t expDim0 = CeilDiv(weightInt4PackDimLast, lastDimSize); | 225 | int64_t expDim0 = CeilDiv(weightInt4PackDimLast, lastDimSize); |
| 226 | if ((storageDim0 != expDim0) || (storageDim1 != expDim1) || (storageDim2 != CUBE_BLOCK_SIZE) || | 226 | if ((storageDim0 != expDim0) || (storageDim1 != expDim1) || (storageDim2 != CUBE_BLOCK_SIZE) || |
| 227 | (storageDim3 != lastDimSize)) { | 227 | (storageDim3 != lastDimSize)) { |
| @@ -236,7 +236,7 @@ static bool CheckStorageShapeVaild(const aclTensor *weightInt4Pack, int64_t weig | |||
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | if (weightInt4Pack->GetDataType() == DataType::DT_INT32) { | 238 | if (weightInt4Pack->GetDataType() == DataType::DT_INT32) { |
| 239 | - int64_t lastDimSize = socVersion == SocVersion::ASCEND950 ? C0_16 / INT4_NUM_IN_INT32 : INT4_NUM_IN_INT32; | 239 | + int64_t lastDimSize = npuArch == NpuArch::DAV_3510 ? C0_16 / INT4_NUM_IN_INT32 : INT4_NUM_IN_INT32; |
| 240 | int64_t expDim0 = CeilDiv(weightInt4PackDimLast, lastDimSize); | 240 | int64_t expDim0 = CeilDiv(weightInt4PackDimLast, lastDimSize); |
| 241 | if ((storageDim0 != expDim0) || (storageDim1 != expDim1) || (storageDim2 != CUBE_BLOCK_SIZE) || | 241 | if ((storageDim0 != expDim0) || (storageDim1 != expDim1) || (storageDim2 != CUBE_BLOCK_SIZE) || |
| 242 | (storageDim3 != lastDimSize)) { | 242 | (storageDim3 != lastDimSize)) { |
| @@ -375,9 +375,9 @@ aclnnStatus aclnnConvertWeightToINT4PackGetWorkspaceSize(const aclTensor *weight | |||
| 375 | CHECK_RET(checkRet == ACLNN_SUCCESS, checkRet); | 375 | CHECK_RET(checkRet == ACLNN_SUCCESS, checkRet); |
| 376 | int64_t weightInt4PackDimNum = weightInt4Pack->GetStorageShape().GetDimNum(); | 376 | int64_t weightInt4PackDimNum = weightInt4Pack->GetStorageShape().GetDimNum(); |
| 377 | int64_t weightInt4PackDimLast = weightInt4Pack->GetStorageShape().GetDim(weightInt4PackDimNum - 1); | 377 | int64_t weightInt4PackDimLast = weightInt4Pack->GetStorageShape().GetDim(weightInt4PackDimNum - 1); |
| 378 | - // 若传入的weightInt4Pack的storageShape的最后一维为32,且为950,则为s8s4分支 | 378 | + // 若传入的weightInt4Pack的storageShape的最后一维为32,且为3510,则为s8s4分支 |
| 379 | bool c032Flag = | 379 | bool c032Flag = |
| 380 | - weightInt4PackDimLast == C0_32 && GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND950; | 380 | + weightInt4PackDimLast == C0_32 && GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510; |
| 381 | auto shapeSize = weight->GetViewShape().GetShapeSize(); | 381 | auto shapeSize = weight->GetViewShape().GetShapeSize(); |
| 382 | 382 | ||
| 383 | // 从device拷贝数据到host | 383 | // 从device拷贝数据到host |
| @@ -106,8 +106,9 @@ static bool IsDimSupport(const aclTensor* input, const std::vector<uint64_t>& di | |||
| 106 | static aclnnStatus CheckSocValid() | 106 | static aclnnStatus CheckSocValid() |
| 107 | { | 107 | { |
| 108 | SocVersion socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 108 | SocVersion socVersion = GetCurrentPlatformInfo().GetSocVersion(); |
| 109 | - switch (socVersion) { | 109 | + NpuArch npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 110 | - case SocVersion::ASCEND950: | 110 | + switch (npuArch) { |
| 111 | + case NpuArch::DAV_3510: | ||
| 111 | break; | 112 | break; |
| 112 | default: { | 113 | default: { |
| 113 | OP_LOGE(ACLNN_ERR_RUNTIME_ERROR, "support for %s is not implemented", op::ToString(socVersion).GetString()); | 114 | OP_LOGE(ACLNN_ERR_RUNTIME_ERROR, "support for %s is not implemented", op::ToString(socVersion).GetString()); |
| @@ -20,7 +20,7 @@ | |||
| 20 | namespace optiling { | 20 | namespace optiling { |
| 21 | namespace fused_matmul { | 21 | namespace fused_matmul { |
| 22 | using matmul_v3_advanced::strategy::BASIC_ASWT; | 22 | using matmul_v3_advanced::strategy::BASIC_ASWT; |
| 23 | -MM_REGISTER_TILING_TEMPLATE(FusedMatMul, FusedMatMulAswBasicApiTiling, ASCEND950, BASIC_ASWT); | 23 | +MM_REGISTER_TILING_TEMPLATE(FusedMatMul, FusedMatMulAswBasicApiTiling, DAV_3510, BASIC_ASWT); |
| 24 | 24 | ||
| 25 | bool FusedMatMulAswBasicApiTiling::IsCapable() | 25 | bool FusedMatMulAswBasicApiTiling::IsCapable() |
| 26 | { | 26 | { |
| @@ -21,7 +21,7 @@ | |||
| 21 | namespace optiling { | 21 | namespace optiling { |
| 22 | namespace fused_matmul { | 22 | namespace fused_matmul { |
| 23 | using matmul_v3_advanced::strategy::BASIC_STREAM_K; | 23 | using matmul_v3_advanced::strategy::BASIC_STREAM_K; |
| 24 | -MM_REGISTER_TILING_TEMPLATE(FusedMatMul, FusedMatMulStreamKTiling, ASCEND950, BASIC_STREAM_K); | 24 | +MM_REGISTER_TILING_TEMPLATE(FusedMatMul, FusedMatMulStreamKTiling, DAV_3510, BASIC_STREAM_K); |
| 25 | 25 | ||
| 26 | bool FusedMatMulStreamKTiling::IsCapable() | 26 | bool FusedMatMulStreamKTiling::IsCapable() |
| 27 | { | 27 | { |
| @@ -36,7 +36,7 @@ static const std::vector<std::vector<ge::DataType>> DTYPE_SUPPORT_LIST_RESERVED | |||
| 36 | {ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16}, | 36 | {ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16}, |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | -static const std::vector<std::vector<ge::DataType>> DTYPE_SUPPORT_LIST_91095 = { | 39 | +static const std::vector<std::vector<ge::DataType>> DTYPE_SUPPORT_LIST_DAV_3510 = { |
| 40 | // x1, x2, y, bias x3 | 40 | // x1, x2, y, bias x3 |
| 41 | {ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16}, | 41 | {ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16}, |
| 42 | {ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT16}, | 42 | {ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT, ge::DT_FLOAT16}, |
| @@ -44,7 +44,7 @@ static const std::vector<std::vector<ge::DataType>> DTYPE_SUPPORT_LIST_91095 = { | |||
| 44 | {ge::DT_BF16, ge::DT_BF16, ge::DT_BF16, ge::DT_FLOAT, ge::DT_BF16}, | 44 | {ge::DT_BF16, ge::DT_BF16, ge::DT_BF16, ge::DT_FLOAT, ge::DT_BF16}, |
| 45 | {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT}}; | 45 | {ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT}}; |
| 46 | 46 | ||
| 47 | -inline void GetDtype(const gert::TilingContext& context, MatMulV3Args& args, platform_ascendc::SocVersion socVersion) | 47 | +inline void GetDtype(const gert::TilingContext& context, MatMulV3Args& args, NpuArch npuArch) |
| 48 | { | 48 | { |
| 49 | args.aType = context.GetInputDesc(0)->GetDataType(); | 49 | args.aType = context.GetInputDesc(0)->GetDataType(); |
| 50 | args.bType = context.GetInputDesc(1)->GetDataType(); | 50 | args.bType = context.GetInputDesc(1)->GetDataType(); |
| @@ -60,12 +60,12 @@ inline void GetDtype(const gert::TilingContext& context, MatMulV3Args& args, pla | |||
| 60 | args.isHf32 = *((context.GetAttrs())->GetAttrPointer<bool>(ATTR_ENABLE_HF32_IDX)); | 60 | args.isHf32 = *((context.GetAttrs())->GetAttrPointer<bool>(ATTR_ENABLE_HF32_IDX)); |
| 61 | args.aDtypeSize = ge::GetSizeByDataType(args.aType); | 61 | args.aDtypeSize = ge::GetSizeByDataType(args.aType); |
| 62 | args.bDtypeSize = ge::GetSizeByDataType(args.bType); | 62 | args.bDtypeSize = ge::GetSizeByDataType(args.bType); |
| 63 | - if (args.isHf32 && socVersion != platform_ascendc::SocVersion::ASCEND950) { | 63 | + if (args.isHf32 && npuArch != NpuArch::DAV_3510) { |
| 64 | OP_LOGW(args.opName, "Hf32 flag is: %d, which is not support yet", args.isHf32); | 64 | OP_LOGW(args.opName, "Hf32 flag is: %d, which is not support yet", args.isHf32); |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | -ge::graphStatus IsValidDtype(const MatMulV3Args& args, platform_ascendc::SocVersion socVersion) | 68 | +ge::graphStatus IsValidDtype(const MatMulV3Args& args, NpuArch npuArch) |
| 69 | { | 69 | { |
| 70 | std::vector<ge::DataType> dtype = {args.aType, args.bType, args.cType}; | 70 | std::vector<ge::DataType> dtype = {args.aType, args.bType, args.cType}; |
| 71 | if (args.hasBias) { | 71 | if (args.hasBias) { |
| @@ -77,8 +77,7 @@ ge::graphStatus IsValidDtype(const MatMulV3Args& args, platform_ascendc::SocVers | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | // check dtype | 79 | // check dtype |
| 80 | - auto supportList = socVersion == platform_ascendc::SocVersion::ASCEND950 ? DTYPE_SUPPORT_LIST_91095 : | 80 | + auto supportList = (npuArch == NpuArch::DAV_3510) ? DTYPE_SUPPORT_LIST_DAV_3510 : DTYPE_SUPPORT_LIST_RESERVED; |
| 81 | - DTYPE_SUPPORT_LIST_RESERVED; | ||
| 82 | for (auto& supported : supportList) { | 81 | for (auto& supported : supportList) { |
| 83 | if (std::equal(dtype.begin(), dtype.end(), supported.begin())) { | 82 | if (std::equal(dtype.begin(), dtype.end(), supported.begin())) { |
| 84 | return ge::GRAPH_SUCCESS; | 83 | return ge::GRAPH_SUCCESS; |
| @@ -106,7 +105,7 @@ ge::graphStatus IsValidDtype(const MatMulV3Args& args, platform_ascendc::SocVers | |||
| 106 | } | 105 | } |
| 107 | 106 | ||
| 108 | ge::graphStatus OpSpecificCheck( | 107 | ge::graphStatus OpSpecificCheck( |
| 109 | - const gert::TilingContext& context, MatMulV3Args& args, platform_ascendc::SocVersion socVersion) | 108 | + const gert::TilingContext& context, MatMulV3Args& args, NpuArch npuArch) |
| 110 | { | 109 | { |
| 111 | // check x3 shape | 110 | // check x3 shape |
| 112 | if (args.hasX3Input) { | 111 | if (args.hasX3Input) { |
| @@ -148,7 +147,7 @@ ge::graphStatus OpSpecificCheck( | |||
| 148 | } | 147 | } |
| 149 | 148 | ||
| 150 | // dtype check | 149 | // dtype check |
| 151 | - return IsValidDtype(args, socVersion); | 150 | + return IsValidDtype(args, npuArch); |
| 152 | } | 151 | } |
| 153 | } // namespace | 152 | } // namespace |
| 154 | 153 | ||
| @@ -265,18 +264,18 @@ ge::graphStatus FusedMatMulBuiltInTiling::DoTiling() | |||
| 265 | MatMulTilingCfg tilingCfg( | 264 | MatMulTilingCfg tilingCfg( |
| 266 | false, context_->GetCompileInfo(), reinterpret_cast<void*>(&args_), &fusedMatmulTilingKey); | 265 | false, context_->GetCompileInfo(), reinterpret_cast<void*>(&args_), &fusedMatmulTilingKey); |
| 267 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); | 266 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); |
| 268 | - MMRegisterCfg registerCfg{"FusedMatMul", socVersion_, strategy::GetFusedMatMulPriorities(socVersion_)}; | 267 | + MMRegisterCfg registerCfg{"FusedMatMul", npuArch_, strategy::GetFusedMatMulPriorities(npuArch_)}; |
| 269 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); | 268 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); |
| 270 | } | 269 | } |
| 271 | 270 | ||
| 272 | ge::graphStatus FusedMatMulBuiltInTiling::GetArgs() | 271 | ge::graphStatus FusedMatMulBuiltInTiling::GetArgs() |
| 273 | { | 272 | { |
| 274 | GetFormat(); | 273 | GetFormat(); |
| 275 | - GetDtype(*context_, args_, socVersion_); | 274 | + GetDtype(*context_, args_, npuArch_); |
| 276 | if (GetShape() != ge::GRAPH_SUCCESS) { | 275 | if (GetShape() != ge::GRAPH_SUCCESS) { |
| 277 | return ge::GRAPH_FAILED; | 276 | return ge::GRAPH_FAILED; |
| 278 | } | 277 | } |
| 279 | - return OpSpecificCheck(*context_, args_, socVersion_); | 278 | + return OpSpecificCheck(*context_, args_, npuArch_); |
| 280 | } | 279 | } |
| 281 | 280 | ||
| 282 | ge::graphStatus FusedMatMulBuiltInTiling::CheckArgs() | 281 | ge::graphStatus FusedMatMulBuiltInTiling::CheckArgs() |
| @@ -312,9 +311,9 @@ ge::graphStatus FusedMatMulBuiltInTiling::CheckArgs() | |||
| 312 | ge::graphStatus FusedMatMulBuiltInTiling::GetShapeAttrsInfo() | 311 | ge::graphStatus FusedMatMulBuiltInTiling::GetShapeAttrsInfo() |
| 313 | { | 312 | { |
| 314 | OP_TILING_CHECK( | 313 | OP_TILING_CHECK( |
| 315 | - GetSocVersion(context_, socVersion_) == ge::GRAPH_FAILED, | 314 | + GetSocVersion(context_, npuArch_) == ge::GRAPH_FAILED, |
| 316 | - CUBE_INNER_ERR_REPORT("FusedMatMul", "fail to get soc version"), return ge::GRAPH_FAILED); | 315 | + CUBE_INNER_ERR_REPORT("FusedMatMul", "fail to get npu arch"), return ge::GRAPH_FAILED); |
| 317 | - return BatchMatMulV3Tiling::GetShapeAttrsInfo(); | 316 | + return MatMulV3Tiling::GetShapeAttrsInfo(); |
| 318 | } | 317 | } |
| 319 | } // namespace fused_matmul | 318 | } // namespace fused_matmul |
| 320 | } // namespace optiling | 319 | } // namespace optiling |
| @@ -40,7 +40,7 @@ protected: | |||
| 40 | const gert::TilingContext& context, MatMulV3Args& args, MatMulV3BatchInfo& batchInfo) override; | 40 | const gert::TilingContext& context, MatMulV3Args& args, MatMulV3BatchInfo& batchInfo) override; |
| 41 | 41 | ||
| 42 | private: | 42 | private: |
| 43 | - platform_ascendc::SocVersion socVersion_; | 43 | + NpuArch npuArch_; |
| 44 | }; | 44 | }; |
| 45 | } // namespace fused_matmul | 45 | } // namespace fused_matmul |
| 46 | } // namespace optiling | 46 | } // namespace optiling |
| @@ -28,18 +28,18 @@ namespace strategy { | |||
| 28 | constexpr int32_t ITER_BATCH_BASICAPI = 0; | 28 | constexpr int32_t ITER_BATCH_BASICAPI = 0; |
| 29 | constexpr int32_t BASE = 999; | 29 | constexpr int32_t BASE = 999; |
| 30 | 30 | ||
| 31 | -const static std::map<platform_ascendc::SocVersion, std::vector<int32_t>> FusedMatMulPrioritiesMap = { | 31 | +const static std::map<NpuArch, std::vector<int32_t>> FusedMatMulPrioritiesMap = { |
| 32 | - {platform_ascendc::SocVersion::ASCEND950, | 32 | + {NpuArch::DAV_3510, |
| 33 | {strategy::ITER_BATCH_BASICAPI, matmul_v3_advanced::strategy::BASIC_STREAM_K, | 33 | {strategy::ITER_BATCH_BASICAPI, matmul_v3_advanced::strategy::BASIC_STREAM_K, |
| 34 | matmul_v3_advanced::strategy::BASIC_ASWT}}, | 34 | matmul_v3_advanced::strategy::BASIC_ASWT}}, |
| 35 | - {platform_ascendc::SocVersion::RESERVED_VERSION, {strategy::BASE}}, // supportMmadS8S4平台 | 35 | + {NpuArch::DAV_RESV, {strategy::BASE}}, // supportMmadS8S4平台 |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | -inline std::vector<int32_t> GetFusedMatMulPriorities(platform_ascendc::SocVersion socVersion) | 38 | +inline std::vector<int32_t> GetFusedMatMulPriorities(NpuArch npuArch) |
| 39 | { | 39 | { |
| 40 | std::vector<int32_t> priorities = {}; | 40 | std::vector<int32_t> priorities = {}; |
| 41 | - if (FusedMatMulPrioritiesMap.find(socVersion) != FusedMatMulPrioritiesMap.end()) { | 41 | + if (FusedMatMulPrioritiesMap.find(npuArch) != FusedMatMulPrioritiesMap.end()) { |
| 42 | - priorities = FusedMatMulPrioritiesMap.at(socVersion); | 42 | + priorities = FusedMatMulPrioritiesMap.at(npuArch); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | return priorities; | 45 | return priorities; |
| @@ -20,7 +20,7 @@ | |||
| 20 | namespace optiling { | 20 | namespace optiling { |
| 21 | namespace fused_matmul { | 21 | namespace fused_matmul { |
| 22 | using strategy::ITER_BATCH_BASICAPI; | 22 | using strategy::ITER_BATCH_BASICAPI; |
| 23 | -MM_REGISTER_TILING_TEMPLATE(FusedMatMul, FusedMatMulIterBatchApiTiling, ASCEND950, ITER_BATCH_BASICAPI); | 23 | +MM_REGISTER_TILING_TEMPLATE(FusedMatMul, FusedMatMulIterBatchApiTiling, DAV_3510, ITER_BATCH_BASICAPI); |
| 24 | 24 | ||
| 25 | bool FusedMatMulIterBatchApiTiling::IsCapable() | 25 | bool FusedMatMulIterBatchApiTiling::IsCapable() |
| 26 | { | 26 | { |
| @@ -35,12 +35,12 @@ constexpr uint64_t FOUR_BATCH_DIM = 4; | |||
| 35 | constexpr uint64_t ALIGN_NUM = 16; | 35 | constexpr uint64_t ALIGN_NUM = 16; |
| 36 | constexpr uint64_t WORKSPACE_SIZE = 1024; | 36 | constexpr uint64_t WORKSPACE_SIZE = 1024; |
| 37 | 37 | ||
| 38 | -// soc_version, built-in, others | 38 | +// NpuArch, built-in, others |
| 39 | -const std::unordered_map<platform_ascendc::SocVersion, std::array<std::vector<std::string>, 2>> SocFusedOpSupport = { | 39 | +const std::unordered_map<NpuArch, std::array<std::vector<std::string>, 2>> NpuArchFusedOpSupport = { |
| 40 | - {platform_ascendc::SocVersion::ASCEND950, | 40 | + {NpuArch::DAV_3510, |
| 41 | std::array<std::vector<std::string>, 2>{ | 41 | std::array<std::vector<std::string>, 2>{ |
| 42 | std::vector<std::string>{"", "relu", "add", "mul",}, std::vector<std::string>{"gelu_erf", "gelu_tanh"}}}, | 42 | std::vector<std::string>{"", "relu", "add", "mul",}, std::vector<std::string>{"gelu_erf", "gelu_tanh"}}}, |
| 43 | - {platform_ascendc::SocVersion::RESERVED_VERSION, | 43 | + {NpuArch::DAV_RESV, |
| 44 | std::array<std::vector<std::string>, 2>{std::vector<std::string>{"relu"}, std::vector<std::string>{}}}}; | 44 | std::array<std::vector<std::string>, 2>{std::vector<std::string>{"relu"}, std::vector<std::string>{}}}}; |
| 45 | 45 | ||
| 46 | const std::initializer_list<std::string> FusedOpTypeSupportF32 = {"", "relu", "add", "mul"}; | 46 | const std::initializer_list<std::string> FusedOpTypeSupportF32 = {"", "relu", "add", "mul"}; |
| @@ -241,13 +241,13 @@ bool CheckFusedOpType(const gert::TilingContext& context) | |||
| 241 | std::string fusedOpType = attrs->GetAttrPointer<char>(ATTR_OP_TYPE_IDX); | 241 | std::string fusedOpType = attrs->GetAttrPointer<char>(ATTR_OP_TYPE_IDX); |
| 242 | 242 | ||
| 243 | // get available fused op type | 243 | // get available fused op type |
| 244 | - platform_ascendc::SocVersion socVersion; | 244 | + NpuArch npuArch; |
| 245 | OP_TILING_CHECK( | 245 | OP_TILING_CHECK( |
| 246 | - GetSocVersion(&context, socVersion) == ge::GRAPH_FAILED, | 246 | + GetSocVersion(&context, npuArch) == ge::GRAPH_FAILED, |
| 247 | - CUBE_INNER_ERR_REPORT(context.GetNodeName(), "fail to get soc version"), return false); | 247 | + CUBE_INNER_ERR_REPORT(context.GetNodeName(), "fail to get npu arch"), return false); |
| 248 | - auto it = SocFusedOpSupport.find(socVersion); | 248 | + auto it = NpuArchFusedOpSupport.find(npuArch); |
| 249 | OP_TILING_CHECK( | 249 | OP_TILING_CHECK( |
| 250 | - it == SocFusedOpSupport.end(), | 250 | + it == NpuArchFusedOpSupport.end(), |
| 251 | CUBE_INNER_ERR_REPORT(context.GetNodeName(), "unsupported platform(impossible situation)"), return false); | 251 | CUBE_INNER_ERR_REPORT(context.GetNodeName(), "unsupported platform(impossible situation)"), return false); |
| 252 | 252 | ||
| 253 | // check op type support | 253 | // check op type support |
| @@ -266,13 +266,13 @@ ge::graphStatus BuiltInTilingCheck(gert::TilingContext* context, bool& useBuiltI | |||
| 266 | std::string fusedOpType = attrs->GetAttrPointer<char>(ATTR_OP_TYPE_IDX); | 266 | std::string fusedOpType = attrs->GetAttrPointer<char>(ATTR_OP_TYPE_IDX); |
| 267 | 267 | ||
| 268 | // get available fused op type | 268 | // get available fused op type |
| 269 | - platform_ascendc::SocVersion socVersion; | 269 | + NpuArch npuArch; |
| 270 | OP_TILING_CHECK( | 270 | OP_TILING_CHECK( |
| 271 | - GetSocVersion(context, socVersion) == ge::GRAPH_FAILED, | 271 | + GetSocVersion(context, npuArch) == ge::GRAPH_FAILED, |
| 272 | - CUBE_INNER_ERR_REPORT(context->GetNodeName(), "fail to get soc version"), return ge::GRAPH_FAILED); | 272 | + CUBE_INNER_ERR_REPORT(context->GetNodeName(), "fail to get npu arch"), return ge::GRAPH_FAILED); |
| 273 | - auto it = SocFusedOpSupport.find(socVersion); | 273 | + auto it = NpuArchFusedOpSupport.find(npuArch); |
| 274 | OP_TILING_CHECK( | 274 | OP_TILING_CHECK( |
| 275 | - it == SocFusedOpSupport.end(), | 275 | + it == NpuArchFusedOpSupport.end(), |
| 276 | CUBE_INNER_ERR_REPORT(context->GetNodeName(), "unsupported platform(impossible situation)"), | 276 | CUBE_INNER_ERR_REPORT(context->GetNodeName(), "unsupported platform(impossible situation)"), |
| 277 | return ge::GRAPH_FAILED); | 277 | return ge::GRAPH_FAILED); |
| 278 | 278 | ||
| @@ -288,7 +288,7 @@ ge::graphStatus FusedMatMulTilingFunc(gert::TilingContext* context) | |||
| 288 | OP_TILING_CHECK( | 288 | OP_TILING_CHECK( |
| 289 | context == nullptr, CUBE_INNER_ERR_REPORT("FusedMatMul", "context is null"), return ge::GRAPH_FAILED); | 289 | context == nullptr, CUBE_INNER_ERR_REPORT("FusedMatMul", "context is null"), return ge::GRAPH_FAILED); |
| 290 | if (!IsAdvancedSocVersion(context)) { | 290 | if (!IsAdvancedSocVersion(context)) { |
| 291 | - OP_LOGE("FusedMatMul", "not support soc version"); | 291 | + OP_LOGE("FusedMatMul", "not support npu arch"); |
| 292 | return ge::GRAPH_FAILED; | 292 | return ge::GRAPH_FAILED; |
| 293 | } | 293 | } |
| 294 | bool useBuiltInTiling = false; | 294 | bool useBuiltInTiling = false; |
| @@ -50,8 +50,8 @@ static inline bool CheckNotNull(const aclTensor* A, const aclTensor* B, const ac | |||
| 50 | 50 | ||
| 51 | static inline bool CheckSocVersionIsSupportBf16(void) | 51 | static inline bool CheckSocVersionIsSupportBf16(void) |
| 52 | { | 52 | { |
| 53 | - return GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 53 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 54 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E; | 54 | + return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | static inline bool CheckFormat(const aclTensor* A, const aclTensor* B, const aclTensor* C, const aclTensor* out) | 57 | static inline bool CheckFormat(const aclTensor* A, const aclTensor* B, const aclTensor* C, const aclTensor* out) |
| @@ -96,8 +96,8 @@ static inline bool CheckMatmul(const aclTensor* A, const aclTensor* B, int64_t t | |||
| 96 | OP_CHECK_WRONG_DIMENSION(B, 2, return false); | 96 | OP_CHECK_WRONG_DIMENSION(B, 2, return false); |
| 97 | 97 | ||
| 98 | // check whether matrices can be multiplied | 98 | // check whether matrices can be multiplied |
| 99 | - auto kDimA = transA ? (A->GetViewShape())[0] : (A->GetViewShape())[1]; | 99 | + auto kDimA = static_cast<bool>(transA) ? (A->GetViewShape())[0] : (A->GetViewShape())[1]; |
| 100 | - auto kDimB = transB ? (B->GetViewShape())[1] : (B->GetViewShape())[0]; | 100 | + auto kDimB = static_cast<bool>(transB) ? (B->GetViewShape())[1] : (B->GetViewShape())[0]; |
| 101 | if (kDimA != kDimB) { | 101 | if (kDimA != kDimB) { |
| 102 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The k-axis of the two inputs are different."); | 102 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The k-axis of the two inputs are different."); |
| 103 | return false; | 103 | return false; |
| @@ -109,8 +109,8 @@ static inline bool CheckMatmul(const aclTensor* A, const aclTensor* B, int64_t t | |||
| 109 | static inline bool CheckBroadcast( | 109 | static inline bool CheckBroadcast( |
| 110 | const aclTensor* A, const aclTensor* B, const aclTensor* C, int64_t transA, int64_t transB) | 110 | const aclTensor* A, const aclTensor* B, const aclTensor* C, int64_t transA, int64_t transB) |
| 111 | { | 111 | { |
| 112 | - auto mDim = transA ? (A->GetViewShape())[1] : (A->GetViewShape())[0]; | 112 | + auto mDim = static_cast<bool>(transA) ? (A->GetViewShape())[1] : (A->GetViewShape())[0]; |
| 113 | - auto nDim = transB ? (B->GetViewShape())[0] : (B->GetViewShape())[1]; | 113 | + auto nDim = static_cast<bool>(transB) ? (B->GetViewShape())[0] : (B->GetViewShape())[1]; |
| 114 | op::Shape matmulShape = {mDim, nDim}; | 114 | op::Shape matmulShape = {mDim, nDim}; |
| 115 | OP_CHECK_BROADCAST_WITH_SHAPE(C, matmulShape, return false); | 115 | OP_CHECK_BROADCAST_WITH_SHAPE(C, matmulShape, return false); |
| 116 | 116 | ||
| @@ -121,8 +121,8 @@ static inline bool CheckBroadcast( | |||
| 121 | static inline bool CheckOutShape( | 121 | static inline bool CheckOutShape( |
| 122 | const aclTensor* A, const aclTensor* B, int64_t transA, int64_t transB, const aclTensor* out) | 122 | const aclTensor* A, const aclTensor* B, int64_t transA, int64_t transB, const aclTensor* out) |
| 123 | { | 123 | { |
| 124 | - auto mDim = transA ? A->GetViewShape().GetDim(1) : A->GetViewShape().GetDim(0); | 124 | + auto mDim = static_cast<bool>(transA) ? A->GetViewShape().GetDim(1) : A->GetViewShape().GetDim(0); |
| 125 | - auto nDim = transB ? B->GetViewShape().GetDim(0) : B->GetViewShape().GetDim(1); | 125 | + auto nDim = static_cast<bool>(transB) ? B->GetViewShape().GetDim(0) : B->GetViewShape().GetDim(1); |
| 126 | 126 | ||
| 127 | int64_t out_m = out->GetViewShape().GetDim(0); | 127 | int64_t out_m = out->GetViewShape().GetDim(0); |
| 128 | int64_t out_n = out->GetViewShape().GetDim(1); | 128 | int64_t out_n = out->GetViewShape().GetDim(1); |
| @@ -172,8 +172,8 @@ static aclnnStatus CheckParams( | |||
| 172 | // A: m x k, B: k x n -> m x n 是否为空tensor,为空tensor返回true | 172 | // A: m x k, B: k x n -> m x n 是否为空tensor,为空tensor返回true |
| 173 | static inline bool CheckMulResIsEmpty(const aclTensor* A, const aclTensor* B, int64_t transA, int64_t transB) | 173 | static inline bool CheckMulResIsEmpty(const aclTensor* A, const aclTensor* B, int64_t transA, int64_t transB) |
| 174 | { | 174 | { |
| 175 | - auto mDim = transA ? A->GetViewShape().GetDim(1) : A->GetViewShape().GetDim(0); | 175 | + auto mDim = static_cast<bool>(transA) ? A->GetViewShape().GetDim(1) : A->GetViewShape().GetDim(0); |
| 176 | - auto nDim = transB ? B->GetViewShape().GetDim(0) : B->GetViewShape().GetDim(1); | 176 | + auto nDim = static_cast<bool>(transB) ? B->GetViewShape().GetDim(0) : B->GetViewShape().GetDim(1); |
| 177 | return mDim == 0 || nDim == 0; | 177 | return mDim == 0 || nDim == 0; |
| 178 | } | 178 | } |
| 179 | 179 | ||
| @@ -187,7 +187,7 @@ static aclnnStatus GemmMulEmptyProcess(const aclTensor* C, float beta, aclTensor | |||
| 187 | 187 | ||
| 188 | // broadcast成和out一个shape | 188 | // broadcast成和out一个shape |
| 189 | if (mulOut->GetViewShape() != out->GetViewShape()) { | 189 | if (mulOut->GetViewShape() != out->GetViewShape()) { |
| 190 | - int64_t tensorSize = (int64_t)(out->GetViewShape().GetDimNum()); | 190 | + int64_t tensorSize = static_cast<int64_t>(out->GetViewShape().GetDimNum()); |
| 191 | std::vector<int64_t> tensorShape(tensorSize); | 191 | std::vector<int64_t> tensorShape(tensorSize); |
| 192 | for (int64_t i = 0; i < tensorSize; i++) { | 192 | for (int64_t i = 0; i < tensorSize; i++) { |
| 193 | tensorShape[i] = (out->GetViewShape())[i]; | 193 | tensorShape[i] = (out->GetViewShape())[i]; |
| @@ -57,6 +57,7 @@ static ge::graphStatus TilingPrepareForGemmV2(gert::TilingParseContext *context) | |||
| 57 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != string::npos); | 57 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != string::npos); |
| 58 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); | 58 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); |
| 59 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); | 59 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); |
| 60 | + compileInfoPtr->npuArch = ascendcPlatform.GetCurNpuArch(); | ||
| 60 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024 : 0; // 1024 is btSize | 61 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024 : 0; // 1024 is btSize |
| 61 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096 : compileInfoPtr->btSize; // 4096 is btSize | 62 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096 : compileInfoPtr->btSize; // 4096 is btSize |
| 62 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 63 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -66,9 +67,10 @@ static ge::graphStatus TilingPrepareForGemmV2(gert::TilingParseContext *context) | |||
| 66 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L0_C, compileInfoPtr->l0CSize); | 67 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L0_C, compileInfoPtr->l0CSize); |
| 67 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L2, compileInfoPtr->l2Size); | 68 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L2, compileInfoPtr->l2Size); |
| 68 | OP_LOGI(context->GetNodeName(), | 69 | OP_LOGI(context->GetNodeName(), |
| 69 | - "parse compile info success soc:%d, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d,\ | 70 | + "parse compile info success soc:%d, npu arch: %u, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d,\ |
| 70 | supportL12BtBf16:%d", | 71 | supportL12BtBf16:%d", |
| 71 | static_cast<int>(compileInfoPtr->socVersion), | 72 | static_cast<int>(compileInfoPtr->socVersion), |
| 73 | + compileInfoPtr->npuArch, | ||
| 72 | compileInfoPtr->l1Size, | 74 | compileInfoPtr->l1Size, |
| 73 | compileInfoPtr->l2Size, | 75 | compileInfoPtr->l2Size, |
| 74 | compileInfoPtr->aicNum, | 76 | compileInfoPtr->aicNum, |
| @@ -242,9 +242,9 @@ ge::graphStatus GemmV3Tiling::DoTiling() | |||
| 242 | GemmV3TilingKey GemmV3TilingKey_; | 242 | GemmV3TilingKey GemmV3TilingKey_; |
| 243 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void*>(&args_), &GemmV3TilingKey_); | 243 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void*>(&args_), &GemmV3TilingKey_); |
| 244 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); | 244 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); |
| 245 | - platform_ascendc::SocVersion socVersion = | 245 | + NpuArch npuArch = |
| 246 | - static_cast<const MatmulV3CompileInfo*>(tilingCfg.compileInfo)->socVersion; | 246 | + static_cast<const MatmulV3CompileInfo*>(tilingCfg.compileInfo)->npuArch; |
| 247 | - MMRegisterCfg registerCfg{"MatMulV3", socVersion, strategy::GetGemmV3Priorities(socVersion)}; | 247 | + MMRegisterCfg registerCfg{"MatMulV3", npuArch, strategy::GetGemmV3Priorities(npuArch)}; |
| 248 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); | 248 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); |
| 249 | } | 249 | } |
| 250 | } // namespace gemmv3 | 250 | } // namespace gemmv3 |
| @@ -26,15 +26,15 @@ namespace gemmv3 { | |||
| 26 | namespace strategy { | 26 | namespace strategy { |
| 27 | constexpr int32_t BASE = 999; | 27 | constexpr int32_t BASE = 999; |
| 28 | 28 | ||
| 29 | -const static std::map<platform_ascendc::SocVersion, std::vector<int32_t>> Gemmv3PrioritiesMap = { | 29 | +const static std::map<NpuArch, std::vector<int32_t>> Gemmv3PrioritiesMap = { |
| 30 | - {platform_ascendc::SocVersion::ASCEND950, {strategy::BASE}}, | 30 | + {NpuArch::DAV_3510, {strategy::BASE}}, |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | -inline std::vector<int32_t> GetGemmV3Priorities(platform_ascendc::SocVersion socVersion) | 33 | +inline std::vector<int32_t> GetGemmV3Priorities(NpuArch npuArch) |
| 34 | { | 34 | { |
| 35 | std::vector<int32_t> priorities = {}; | 35 | std::vector<int32_t> priorities = {}; |
| 36 | - if (Gemmv3PrioritiesMap.find(socVersion) != Gemmv3PrioritiesMap.end()) { | 36 | + if (Gemmv3PrioritiesMap.find(npuArch) != Gemmv3PrioritiesMap.end()) { |
| 37 | - priorities = Gemmv3PrioritiesMap.at(socVersion); | 37 | + priorities = Gemmv3PrioritiesMap.at(npuArch); |
| 38 | } | 38 | } |
| 39 | return priorities; | 39 | return priorities; |
| 40 | }; | 40 | }; |
| @@ -73,6 +73,7 @@ static ge::graphStatus TilingPrepareForGemmV3(gert::TilingParseContext *context) | |||
| 73 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); | 73 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); |
| 74 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); | 74 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); |
| 75 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); | 75 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); |
| 76 | + compileInfoPtr->npuArch = ascendcPlatform.GetCurNpuArch(); | ||
| 76 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize | 77 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize |
| 77 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize | 78 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize |
| 78 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 79 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -86,8 +87,8 @@ static ge::graphStatus TilingPrepareForGemmV3(gert::TilingParseContext *context) | |||
| 86 | } | 87 | } |
| 87 | OP_LOGI( | 88 | OP_LOGI( |
| 88 | context->GetNodeName(), | 89 | context->GetNodeName(), |
| 89 | - "parse compile info success soc:%d, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", | 90 | + "parse compile info success soc:%d, npu arch: %u, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", |
| 90 | - static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->l1Size, compileInfoPtr->l2Size, | 91 | + static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->npuArch, compileInfoPtr->l1Size, compileInfoPtr->l2Size, |
| 91 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); | 92 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); |
| 92 | return ge::GRAPH_SUCCESS; | 93 | return ge::GRAPH_SUCCESS; |
| 93 | } | 94 | } |
| @@ -68,16 +68,16 @@ static const std::initializer_list<op::DataType> dtypeSupportListWithoutBf16 = { | |||
| 68 | op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16}; | 68 | op::DataType::DT_FLOAT, op::DataType::DT_FLOAT16}; |
| 69 | static const std::initializer_list<op::DataType> dtypeSupportListMat1AndMat2 = { | 69 | static const std::initializer_list<op::DataType> dtypeSupportListMat1AndMat2 = { |
| 70 | op::DataType::DT_FLOAT16, op::DataType::DT_BF16}; | 70 | op::DataType::DT_FLOAT16, op::DataType::DT_BF16}; |
| 71 | -static inline bool CheckSocVersionIsSupportBf16(void) | 71 | +static inline bool CheckNpuArchIsSupportBf16(void) |
| 72 | { | 72 | { |
| 73 | - return GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 73 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 74 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E; | 74 | + return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | static inline bool CheckWeightNzDtypeValid( | 77 | static inline bool CheckWeightNzDtypeValid( |
| 78 | const aclTensor* self, const aclTensor* mat1, const aclTensor* mat2, const aclTensor* out) | 78 | const aclTensor* self, const aclTensor* mat1, const aclTensor* mat2, const aclTensor* out) |
| 79 | { | 79 | { |
| 80 | - bool bf16flag = CheckSocVersionIsSupportBf16(); | 80 | + bool bf16flag = CheckNpuArchIsSupportBf16(); |
| 81 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 81 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); |
| 82 | auto dtypeList = bf16flag ? dtypeSupportList : dtypeSupportListWithoutBf16; | 82 | auto dtypeList = bf16flag ? dtypeSupportList : dtypeSupportListWithoutBf16; |
| 83 | auto dtypeListMat1AndMat2 = bf16flag ? dtypeSupportListMat1AndMat2 : dtypeSupportListWithoutBf16; | 83 | auto dtypeListMat1AndMat2 = bf16flag ? dtypeSupportListMat1AndMat2 : dtypeSupportListWithoutBf16; |
| @@ -160,10 +160,10 @@ static aclnnStatus CheckInputParams(AclnnAddmmTensor& addmmTensor, int8_t cubeMa | |||
| 160 | CHECK_RET(CheckNotNull(addmmTensor), ACLNN_ERR_PARAM_NULLPTR); | 160 | CHECK_RET(CheckNotNull(addmmTensor), ACLNN_ERR_PARAM_NULLPTR); |
| 161 | 161 | ||
| 162 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 | 162 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 |
| 163 | - auto socRule = SocMatMulRule::getInstance(); | 163 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 164 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 164 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 165 | CHECK_RET( | 165 | CHECK_RET( |
| 166 | - socRule -> CheckInput(addmmTensor.mat1, addmmTensor.mat2, addmmTensor.self, addmmTensor.out, cubeMathType), | 166 | + archRule -> CheckInput(addmmTensor.mat1, addmmTensor.mat2, addmmTensor.self, addmmTensor.out, cubeMathType), |
| 167 | ACLNN_ERR_PARAM_INVALID); | 167 | ACLNN_ERR_PARAM_INVALID); |
| 168 | 168 | ||
| 169 | // 3. 检查mat1和mat2是否满足matmul条件 | 169 | // 3. 检查mat1和mat2是否满足matmul条件 |
| @@ -412,11 +412,9 @@ static inline bool CheckMatmulWeightNz(const aclTensor* mat1, const aclTensor* m | |||
| 412 | static aclnnStatus AddmmCheckWeightNzParam(AclnnAddmmTensor& addmmTensor, int8_t cubeMathType) | 412 | static aclnnStatus AddmmCheckWeightNzParam(AclnnAddmmTensor& addmmTensor, int8_t cubeMathType) |
| 413 | { | 413 | { |
| 414 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 414 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); |
| 415 | - bool isSupportSocVersion = | 415 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 416 | - (socVersion == SocVersion::ASCEND910B || socVersion == SocVersion::ASCEND910_93 || | 416 | + bool isSupportNpuArch = ((npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510)); |
| 417 | - socVersion == SocVersion::ASCEND950); | 417 | + if (!isSupportNpuArch) { |
| 418 | - | ||
| 419 | - if (!isSupportSocVersion) { | ||
| 420 | OP_LOGE( | 418 | OP_LOGE( |
| 421 | ACLNN_ERR_PARAM_INVALID, "Weight NZ is unsupported by the current SOC version [%s].", | 419 | ACLNN_ERR_PARAM_INVALID, "Weight NZ is unsupported by the current SOC version [%s].", |
| 422 | op::ToString(socVersion).GetString()); | 420 | op::ToString(socVersion).GetString()); |
| @@ -441,10 +439,10 @@ static aclnnStatus AddmmCheckWeightNzParam(AclnnAddmmTensor& addmmTensor, int8_t | |||
| 441 | CHECK_RET(CheckWeightNzDtypeValid(addmmTensor.self, addmmTensor.mat1, addmmTensor.mat2, | 439 | CHECK_RET(CheckWeightNzDtypeValid(addmmTensor.self, addmmTensor.mat1, addmmTensor.mat2, |
| 442 | addmmTensor.out), ACLNN_ERR_PARAM_INVALID); | 440 | addmmTensor.out), ACLNN_ERR_PARAM_INVALID); |
| 443 | 441 | ||
| 444 | - auto socRule = SocMatMulRule::getInstance(); | 442 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 445 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 443 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 446 | CHECK_RET( | 444 | CHECK_RET( |
| 447 | - socRule->CheckInput(addmmTensor.mat1, addmmTensor.mat2, addmmTensor.self, addmmTensor.out, cubeMathType), | 445 | + archRule->CheckInput(addmmTensor.mat1, addmmTensor.mat2, addmmTensor.self, addmmTensor.out, cubeMathType), |
| 448 | ACLNN_ERR_PARAM_INVALID); | 446 | ACLNN_ERR_PARAM_INVALID); |
| 449 | 447 | ||
| 450 | // 3. 检查mat1和mat2是否满足matmulweightNz条件 | 448 | // 3. 检查mat1和mat2是否满足matmulweightNz条件 |
| @@ -494,11 +492,11 @@ public: | |||
| 494 | CHECK_RET(out1 != nullptr, ACLNN_ERR_INNER_NULLPTR); | 492 | CHECK_RET(out1 != nullptr, ACLNN_ERR_INNER_NULLPTR); |
| 495 | // 执行 Matmul: out2 = mat1 @ mat2 | 493 | // 执行 Matmul: out2 = mat1 @ mat2 |
| 496 | // 为了提升addmm的精度,如果输入是fp16或者bf16时,输出需要是fp32类型 | 494 | // 为了提升addmm的精度,如果输入是fp16或者bf16时,输出需要是fp32类型 |
| 497 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 495 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 498 | - bool isSupportSocVersion = (socVersion == SocVersion::ASCEND910B || socVersion == SocVersion::ASCEND910_93); | 496 | + bool isSupportNpuArch = (npuArch == NpuArch::DAV_2201); |
| 499 | - if (((matA->GetDataType() == DataType::DT_FLOAT16 && matB->GetDataType() == DataType::DT_FLOAT16) || | 497 | + if (((matA->GetDataType() == DataType::DT_FLOAT16 && matB->GetDataType() == DataType::DT_FLOAT16) || |
| 500 | (matA->GetDataType() == DataType::DT_BF16 && matB->GetDataType() == DataType::DT_BF16)) && | 498 | (matA->GetDataType() == DataType::DT_BF16 && matB->GetDataType() == DataType::DT_BF16)) && |
| 501 | - (cubeMathType == KEEP_DTYPE || cubeMathType == USE_HF32) && isSupportSocVersion) { | 499 | + (cubeMathType == KEEP_DTYPE || cubeMathType == USE_HF32) && isSupportNpuArch) { |
| 502 | cubeMathType = USE_HIGH_PREC_MODE; | 500 | cubeMathType = USE_HIGH_PREC_MODE; |
| 503 | } | 501 | } |
| 504 | const aclTensor* out2 = MatmulProcess(matA, matB, output, cubeMathType, opInfo, executor); | 502 | const aclTensor* out2 = MatmulProcess(matA, matB, output, cubeMathType, opInfo, executor); |
| @@ -62,10 +62,10 @@ inline static bool CheckNotNull(const aclTensor* self, const aclTensor* mat2, co | |||
| 62 | return true; | 62 | return true; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | -static inline bool CheckSocVersionIsSupportBf16(void) | 65 | +static inline bool CheckNpuArchIsSupportBf16(void) |
| 66 | { | 66 | { |
| 67 | - return GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 67 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 68 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E; | 68 | + return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | static inline bool CheckMathType(const aclTensor* self, const aclTensor* mat2, int8_t cubeMathType) | 71 | static inline bool CheckMathType(const aclTensor* self, const aclTensor* mat2, int8_t cubeMathType) |
| @@ -105,7 +105,7 @@ static bool CheckWeightNzDtype(const aclTensor* self, const aclTensor* mat2) | |||
| 105 | inline static bool CheckWeightNzDtypeValid( | 105 | inline static bool CheckWeightNzDtypeValid( |
| 106 | const aclTensor* self, const aclTensor* mat2, const aclTensor* out, int8_t cubeMathType) | 106 | const aclTensor* self, const aclTensor* mat2, const aclTensor* out, int8_t cubeMathType) |
| 107 | { | 107 | { |
| 108 | - bool bf16flag = CheckSocVersionIsSupportBf16(); | 108 | + bool bf16flag = CheckNpuArchIsSupportBf16(); |
| 109 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 109 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); |
| 110 | auto dtypeList = bf16flag ? DTYPE_SUPPORT_LIST : DTYPE_SUPPORT_LIST_WITHOUT_BF16; | 110 | auto dtypeList = bf16flag ? DTYPE_SUPPORT_LIST : DTYPE_SUPPORT_LIST_WITHOUT_BF16; |
| 111 | OP_CHECK_DTYPE_NOT_SUPPORT(self, dtypeList, return false); | 111 | OP_CHECK_DTYPE_NOT_SUPPORT(self, dtypeList, return false); |
| @@ -246,10 +246,10 @@ inline static aclnnStatus CheckInputParams( | |||
| 246 | CHECK_RET(CheckNotNull(self, mat2, out), ACLNN_ERR_PARAM_NULLPTR); | 246 | CHECK_RET(CheckNotNull(self, mat2, out), ACLNN_ERR_PARAM_NULLPTR); |
| 247 | 247 | ||
| 248 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 | 248 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 |
| 249 | - auto socRule = SocMatMulRule::getInstance(); | 249 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 250 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 250 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 251 | CHECK_RET( | 251 | CHECK_RET( |
| 252 | - socRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), | 252 | + archRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), |
| 253 | ACLNN_ERR_PARAM_INVALID); | 253 | ACLNN_ERR_PARAM_INVALID); |
| 254 | 254 | ||
| 255 | CHECK_RET(CheckWeightNzDtype(self, mat2), ACLNN_ERR_PARAM_INVALID); | 255 | CHECK_RET(CheckWeightNzDtype(self, mat2), ACLNN_ERR_PARAM_INVALID); |
| @@ -308,10 +308,9 @@ const aclTensor* SetTensorToNZFormat(const aclTensor* input, op::Shape& shape, a | |||
| 308 | bool CheckWeightNzShapeValid(const aclTensor* self, const aclTensor* mat2) | 308 | bool CheckWeightNzShapeValid(const aclTensor* self, const aclTensor* mat2) |
| 309 | { | 309 | { |
| 310 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 310 | auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); |
| 311 | - bool isSupportSocVersion = | 311 | + auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); |
| 312 | - (socVersion == SocVersion::ASCEND910B || socVersion == SocVersion::ASCEND910_93 || | 312 | + bool isSupportNpuArch = ((npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510)); |
| 313 | - socVersion == SocVersion::ASCEND950); | 313 | + if (!isSupportNpuArch) { |
| 314 | - if (!isSupportSocVersion) { | ||
| 315 | OP_LOGE( | 314 | OP_LOGE( |
| 316 | ACLNN_ERR_PARAM_INVALID, "Weight NZ is unsupported by the current SOC version [%s].", | 315 | ACLNN_ERR_PARAM_INVALID, "Weight NZ is unsupported by the current SOC version [%s].", |
| 317 | op::ToString(socVersion).GetString()); | 316 | op::ToString(socVersion).GetString()); |
| @@ -368,10 +367,10 @@ aclnnStatus CheckWeightNzParam(const aclTensor* self, const aclTensor* mat2, con | |||
| 368 | CHECK_RET(CheckWeightNzShapeValid(self, mat2), ACLNN_ERR_PARAM_INVALID); | 367 | CHECK_RET(CheckWeightNzShapeValid(self, mat2), ACLNN_ERR_PARAM_INVALID); |
| 369 | // 4. 检查cubeMathType | 368 | // 4. 检查cubeMathType |
| 370 | CHECK_RET(CheckMathType(self, mat2, cubeMathType), ACLNN_ERR_PARAM_INVALID); | 369 | CHECK_RET(CheckMathType(self, mat2, cubeMathType), ACLNN_ERR_PARAM_INVALID); |
| 371 | - auto socRule = SocMatMulRule::getInstance(); | 370 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 372 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 371 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 373 | CHECK_RET( | 372 | CHECK_RET( |
| 374 | - socRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), | 373 | + archRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), |
| 375 | ACLNN_ERR_PARAM_INVALID); | 374 | ACLNN_ERR_PARAM_INVALID); |
| 376 | OP_LOGD("MatmulWeightNz check params success."); | 375 | OP_LOGD("MatmulWeightNz check params success."); |
| 377 | return ACLNN_SUCCESS; | 376 | return ACLNN_SUCCESS; |
| @@ -383,10 +382,10 @@ aclnnStatus CheckWeightNzInputParams(const aclTensor* self, const aclTensor* mat | |||
| 383 | CHECK_RET(CheckNotNull(self, mat2, out), ACLNN_ERR_PARAM_NULLPTR); | 382 | CHECK_RET(CheckNotNull(self, mat2, out), ACLNN_ERR_PARAM_NULLPTR); |
| 384 | 383 | ||
| 385 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 | 384 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 |
| 386 | - auto socRule = SocMatMulRule::getInstance(); | 385 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 387 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 386 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 388 | CHECK_RET( | 387 | CHECK_RET( |
| 389 | - socRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), | 388 | + archRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), |
| 390 | ACLNN_ERR_PARAM_INVALID); | 389 | ACLNN_ERR_PARAM_INVALID); |
| 391 | 390 | ||
| 392 | CHECK_RET(CheckWeightNzDtype(self, mat2), ACLNN_ERR_PARAM_INVALID); | 391 | CHECK_RET(CheckWeightNzDtype(self, mat2), ACLNN_ERR_PARAM_INVALID); |
| @@ -51,20 +51,20 @@ static inline bool CheckNotNull(const aclTensor* self, const aclTensor* mat2, co | |||
| 51 | 51 | ||
| 52 | static inline bool CheckKEqual1Support(void) | 52 | static inline bool CheckKEqual1Support(void) |
| 53 | { | 53 | { |
| 54 | - return GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 54 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 55 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93; | 55 | + return (npuArch == NpuArch::DAV_2201); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | -static inline bool CheckSocVersionIsSupportBf16(void) | 58 | +static inline bool CheckNpuArchIsSupportBf16(void) |
| 59 | { | 59 | { |
| 60 | - return GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E && | 60 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 61 | - GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B; | 61 | + return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static bool CheckDtypeValid( | 64 | static bool CheckDtypeValid( |
| 65 | const aclTensor* self, const aclTensor* mat2, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) | 65 | const aclTensor* self, const aclTensor* mat2, const aclTensor* bias, const aclTensor* out, int8_t cubeMathType) |
| 66 | { | 66 | { |
| 67 | - bool bf16flag = CheckSocVersionIsSupportBf16(); | 67 | + bool bf16flag = CheckNpuArchIsSupportBf16(); |
| 68 | if (bf16flag) { | 68 | if (bf16flag) { |
| 69 | OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); | 69 | OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); |
| 70 | OP_CHECK_DTYPE_NOT_SUPPORT(mat2, DTYPE_SUPPORT_LIST, return false); | 70 | OP_CHECK_DTYPE_NOT_SUPPORT(mat2, DTYPE_SUPPORT_LIST, return false); |
| @@ -166,9 +166,9 @@ inline static aclnnStatus CheckMmInputParams( | |||
| 166 | CHECK_RET(CheckNotNull(self, mat2, out), ACLNN_ERR_PARAM_NULLPTR); | 166 | CHECK_RET(CheckNotNull(self, mat2, out), ACLNN_ERR_PARAM_NULLPTR); |
| 167 | 167 | ||
| 168 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验。 | 168 | // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验。 |
| 169 | - auto socRule = SocMatMulRule::getInstance(); | 169 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 170 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 170 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 171 | - CHECK_RET( socRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), ACLNN_ERR_PARAM_INVALID); | 171 | + CHECK_RET(archRule -> CheckInput(self, mat2, nullptr, out, cubeMathType), ACLNN_ERR_PARAM_INVALID); |
| 172 | 172 | ||
| 173 | // 3. 检查Shape是否支持 | 173 | // 3. 检查Shape是否支持 |
| 174 | CHECK_RET(CheckShapeValid(self, mat2), ACLNN_ERR_PARAM_INVALID); | 174 | CHECK_RET(CheckShapeValid(self, mat2), ACLNN_ERR_PARAM_INVALID); |
| @@ -32,7 +32,7 @@ | |||
| 32 | namespace optiling { | 32 | namespace optiling { |
| 33 | struct MMRegisterCfg { | 33 | struct MMRegisterCfg { |
| 34 | const char *opType{ nullptr }; | 34 | const char *opType{ nullptr }; |
| 35 | - platform_ascendc::SocVersion socVersion{ platform_ascendc::SocVersion::RESERVED_VERSION }; | 35 | + NpuArch npuArch{ NpuArch::DAV_RESV }; |
| 36 | std::vector<int32_t> priorities{ }; // 0 base | 36 | std::vector<int32_t> priorities{ }; // 0 base |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| @@ -83,23 +83,23 @@ public: | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | - std::shared_ptr<MMTilingCases> RegisterOp(const std::string &opType, platform_ascendc::SocVersion socVersion) | 86 | + std::shared_ptr<MMTilingCases> RegisterOp(const std::string &opType, NpuArch npuArch) |
| 87 | { | 87 | { |
| 88 | - auto socIter = registryMap_.find(socVersion); | 88 | + auto socIter = registryMap_.find(npuArch); |
| 89 | if (socIter == registryMap_.end()) { | 89 | if (socIter == registryMap_.end()) { |
| 90 | std::map<std::string, std::shared_ptr<MMTilingCases>> opTypeMap; | 90 | std::map<std::string, std::shared_ptr<MMTilingCases>> opTypeMap; |
| 91 | opTypeMap[opType] = std::shared_ptr<MMTilingCases>(new (std::nothrow) MMTilingCases(opType)); | 91 | opTypeMap[opType] = std::shared_ptr<MMTilingCases>(new (std::nothrow) MMTilingCases(opType)); |
| 92 | - registryMap_[socVersion] = opTypeMap; | 92 | + registryMap_[npuArch] = opTypeMap; |
| 93 | } else { | 93 | } else { |
| 94 | if (socIter->second.find(opType) == socIter->second.end()) { | 94 | if (socIter->second.find(opType) == socIter->second.end()) { |
| 95 | socIter->second[opType] = std::shared_ptr<MMTilingCases>(new (std::nothrow) MMTilingCases(opType)); | 95 | socIter->second[opType] = std::shared_ptr<MMTilingCases>(new (std::nothrow) MMTilingCases(opType)); |
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | - OPS_ERR_IF(registryMap_[socVersion][opType] == nullptr, | 99 | + OPS_ERR_IF(registryMap_[npuArch][opType] == nullptr, |
| 100 | OPS_REPORT_VECTOR_INNER_ERR(opType, "Register tiling func failed, please check the class name."), | 100 | OPS_REPORT_VECTOR_INNER_ERR(opType, "Register tiling func failed, please check the class name."), |
| 101 | return nullptr); | 101 | return nullptr); |
| 102 | - return registryMap_[socVersion][opType]; | 102 | + return registryMap_[npuArch][opType]; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | ge::graphStatus DoTilingImpl(gert::TilingContext *context, MatMulTilingCfg &tilingCfg, | 105 | ge::graphStatus DoTilingImpl(gert::TilingContext *context, MatMulTilingCfg &tilingCfg, |
| @@ -110,10 +110,10 @@ public: | |||
| 110 | return ge::GRAPH_FAILED; | 110 | return ge::GRAPH_FAILED; |
| 111 | } | 111 | } |
| 112 | const char *opType = registerCfg.opType == nullptr ? context->GetNodeType() : registerCfg.opType; | 112 | const char *opType = registerCfg.opType == nullptr ? context->GetNodeType() : registerCfg.opType; |
| 113 | - auto tilingTemplateRegistryMap = GetTilingTemplates(opType, registerCfg.socVersion); | 113 | + auto tilingTemplateRegistryMap = GetTilingTemplates(opType, registerCfg.npuArch); |
| 114 | - OPS_LOG_D(context, "registry map find by opType %s, soc version %d", opType, static_cast<int32_t>(registerCfg.socVersion)); | 114 | + OPS_LOG_D(context, "registry map find by opType %s, npu arch %d", opType, static_cast<int32_t>(registerCfg.npuArch)); |
| 115 | if (tilingTemplateRegistryMap.empty()) { | 115 | if (tilingTemplateRegistryMap.empty()) { |
| 116 | - OPS_LOG_E(context, "no registry map find by opType %s, soc version %d", opType, static_cast<int32_t>(registerCfg.socVersion)); | 116 | + OPS_LOG_E(context, "no registry map find by opType %s, npu arch %d", opType, static_cast<int32_t>(registerCfg.npuArch)); |
| 117 | return ge::GRAPH_FAILED; | 117 | return ge::GRAPH_FAILED; |
| 118 | } | 118 | } |
| 119 | std::vector<int32_t> priorities{ registerCfg.priorities }; | 119 | std::vector<int32_t> priorities{ registerCfg.priorities }; |
| @@ -141,12 +141,12 @@ public: | |||
| 141 | return ge::GRAPH_FAILED; | 141 | return ge::GRAPH_FAILED; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | - const std::map<int32_t, MMTilingClassCase> &GetTilingTemplates(const std::string &opType, platform_ascendc::SocVersion socVersion) | 144 | + const std::map<int32_t, MMTilingClassCase> &GetTilingTemplates(const std::string &opType, NpuArch npuArch) |
| 145 | { | 145 | { |
| 146 | - auto socIter = registryMap_.find(socVersion); | 146 | + auto socIter = registryMap_.find(npuArch); |
| 147 | OPS_ERR_IF(socIter == registryMap_.end(), | 147 | OPS_ERR_IF(socIter == registryMap_.end(), |
| 148 | - OPS_REPORT_VECTOR_INNER_ERR(opType, "Get op tiling func failed, please check the soc version %d", | 148 | + OPS_REPORT_VECTOR_INNER_ERR(opType, "Get op tiling func failed, please check the npu arch %d", |
| 149 | - static_cast<int32_t>(socVersion)), | 149 | + static_cast<int32_t>(npuArch)), |
| 150 | return emptyTilingCase_); | 150 | return emptyTilingCase_); |
| 151 | auto opIter = socIter->second.find(opType); | 151 | auto opIter = socIter->second.find(opType); |
| 152 | OPS_ERR_IF(opIter == socIter->second.end(), | 152 | OPS_ERR_IF(opIter == socIter->second.end(), |
| @@ -156,7 +156,7 @@ public: | |||
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | private: | 158 | private: |
| 159 | - std::map<platform_ascendc::SocVersion, std::map<std::string, std::shared_ptr<MMTilingCases>>> registryMap_; // key is socversion | 159 | + std::map<NpuArch, std::map<std::string, std::shared_ptr<MMTilingCases>>> registryMap_; // key is socversion |
| 160 | const std::map<int32_t, MMTilingClassCase> emptyTilingCase_{}; | 160 | const std::map<int32_t, MMTilingClassCase> emptyTilingCase_{}; |
| 161 | }; | 161 | }; |
| 162 | 162 | ||
| @@ -165,9 +165,9 @@ public: | |||
| 165 | explicit MMRegister(std::string opType) : opType_(std::move(opType)) {} | 165 | explicit MMRegister(std::string opType) : opType_(std::move(opType)) {} |
| 166 | 166 | ||
| 167 | template <typename T> | 167 | template <typename T> |
| 168 | - MMRegister &tiling(int32_t priority, platform_ascendc::SocVersion socVersion) | 168 | + MMRegister &tiling(int32_t priority, NpuArch npuArch) |
| 169 | { | 169 | { |
| 170 | - auto tilingCases = MMTilingRegistry::GetInstance().RegisterOp(opType_, socVersion); | 170 | + auto tilingCases = MMTilingRegistry::GetInstance().RegisterOp(opType_, npuArch); |
| 171 | OPS_ERR_IF(tilingCases == nullptr, | 171 | OPS_ERR_IF(tilingCases == nullptr, |
| 172 | OPS_REPORT_VECTOR_INNER_ERR(opType_, "Register op tiling failed, please the op name."), return *this); | 172 | OPS_REPORT_VECTOR_INNER_ERR(opType_, "Register op tiling failed, please the op name."), return *this); |
| 173 | tilingCases->AddTiling<T>(priority); | 173 | tilingCases->AddTiling<T>(priority); |
| @@ -181,10 +181,10 @@ private: | |||
| 181 | // opType: 算子名称, className: 注册的 tiling 类, | 181 | // opType: 算子名称, className: 注册的 tiling 类, |
| 182 | // priority: tiling 类的优先级, 越小表示优先级越高, 即被选中的概率越大 | 182 | // priority: tiling 类的优先级, 越小表示优先级越高, 即被选中的概率越大 |
| 183 | // 取代 MM_REGISTER_TILING_TEMPLATE , 传入的op_type如果是字符串常量,需要去掉引号 | 183 | // 取代 MM_REGISTER_TILING_TEMPLATE , 传入的op_type如果是字符串常量,需要去掉引号 |
| 184 | -#define MM_REGISTER_TILING_TEMPLATE(opType, className, socVersion, priority) \ | 184 | +#define MM_REGISTER_TILING_TEMPLATE(opType, className, npuArch, priority) \ |
| 185 | GLOBAL_REGISTER_SYMBOL(opType, className, priority, __COUNTER__, __LINE__); \ | 185 | GLOBAL_REGISTER_SYMBOL(opType, className, priority, __COUNTER__, __LINE__); \ |
| 186 | - static MMRegister __attribute__((unused)) mm_register_##opType##_##className##_##socVersion##_##priority##_ = \ | 186 | + static MMRegister __attribute__((unused)) mm_register_##opType##_##className##_##npuArch##_##priority##_ = \ |
| 187 | - MMRegister(#opType).tiling<className>(static_cast<int32_t>(priority), platform_ascendc::SocVersion::socVersion) | 187 | + MMRegister(#opType).tiling<className>(static_cast<int32_t>(priority), NpuArch::npuArch) |
| 188 | } // namespace optiling | 188 | } // namespace optiling |
| 189 | 189 | ||
| 190 | 190 | ||
| @@ -28,7 +28,7 @@ bool ABL1FullLoadExtraCondDefault(uint64_t /* al1SingleCoreSize */, uint64_t /* | |||
| 28 | return true; | 28 | return true; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | -bool ABL1FullLoadExtraCond91095(uint64_t al1SingleCoreSize, uint64_t bl1SingleCoreSize) | 31 | +bool ABL1FullLoadExtraCondDav3510(uint64_t al1SingleCoreSize, uint64_t bl1SingleCoreSize) |
| 32 | { | 32 | { |
| 33 | // 单边矩阵小于64K,MMAD启动较快,AB全载更有优势 | 33 | // 单边矩阵小于64K,MMAD启动较快,AB全载更有优势 |
| 34 | constexpr uint64_t AB_L1_SINGLE_LOAD_THRE = 64 * 1024UL; | 34 | constexpr uint64_t AB_L1_SINGLE_LOAD_THRE = 64 * 1024UL; |
| @@ -39,8 +39,8 @@ bool ABL1FullLoadExtraCond91095(uint64_t al1SingleCoreSize, uint64_t bl1SingleCo | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | using ABL1FullLoadExtraCondFunc = bool (*)(uint64_t, uint64_t); | 41 | using ABL1FullLoadExtraCondFunc = bool (*)(uint64_t, uint64_t); |
| 42 | -const static std::map<platform_ascendc::SocVersion, ABL1FullLoadExtraCondFunc> ABL1FullLoadExtraCondFuncMap = { | 42 | +const static std::map<NpuArch, ABL1FullLoadExtraCondFunc> ABL1FullLoadExtraCondFuncMap = { |
| 43 | - {platform_ascendc::SocVersion::ASCEND950, ABL1FullLoadExtraCond91095}, | 43 | + {NpuArch::DAV_3510, ABL1FullLoadExtraCondDav3510}, |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | } // namespace | 46 | } // namespace |
| @@ -50,7 +50,7 @@ namespace matmul_v3_advanced { | |||
| 50 | using namespace strategy; | 50 | using namespace strategy; |
| 51 | 51 | ||
| 52 | // 注册FULL_LOAD_BASE作为高阶API实现的全载模板策略 | 52 | // 注册FULL_LOAD_BASE作为高阶API实现的全载模板策略 |
| 53 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3AswFullLoadTiling, ASCEND950, FULL_LOAD_BASE); | 53 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3AswFullLoadTiling, DAV_3510, FULL_LOAD_BASE); |
| 54 | 54 | ||
| 55 | void MatMulV3AswFullLoadTiling::FullLoadPre() | 55 | void MatMulV3AswFullLoadTiling::FullLoadPre() |
| 56 | { | 56 | { |
| @@ -63,9 +63,9 @@ void MatMulV3AswFullLoadTiling::FullLoadPre() | |||
| 63 | 63 | ||
| 64 | bool MatMulV3AswFullLoadTiling::ABL1FullLoadExtraCond(uint64_t al1SingleCoreSize, uint64_t bl1SingleCoreSize) const | 64 | bool MatMulV3AswFullLoadTiling::ABL1FullLoadExtraCond(uint64_t al1SingleCoreSize, uint64_t bl1SingleCoreSize) const |
| 65 | { | 65 | { |
| 66 | - auto iter = (ABL1FullLoadExtraCondFuncMap.find(compileInfo_.socVersion) == ABL1FullLoadExtraCondFuncMap.end()) ? | 66 | + auto iter = (ABL1FullLoadExtraCondFuncMap.find(compileInfo_.npuArch) == ABL1FullLoadExtraCondFuncMap.end()) ? |
| 67 | ABL1FullLoadExtraCondDefault : | 67 | ABL1FullLoadExtraCondDefault : |
| 68 | - ABL1FullLoadExtraCondFuncMap.at(compileInfo_.socVersion); | 68 | + ABL1FullLoadExtraCondFuncMap.at(compileInfo_.npuArch); |
| 69 | return iter(al1SingleCoreSize, bl1SingleCoreSize); | 69 | return iter(al1SingleCoreSize, bl1SingleCoreSize); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| @@ -115,8 +115,8 @@ namespace optiling { | |||
| 115 | namespace matmul_v3_advanced { | 115 | namespace matmul_v3_advanced { |
| 116 | using namespace strategy; | 116 | using namespace strategy; |
| 117 | 117 | ||
| 118 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3AswTiling, ASCEND950, BASE); | 118 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3AswTiling, DAV_3510, BASE); |
| 119 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3AswTiling, RESERVED_VERSION, BASE); // supportMmadS8S4平台 | 119 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3AswTiling, DAV_RESV, BASE); // supportMmadS8S4平台 |
| 120 | 120 | ||
| 121 | void MatMulV3AswTiling::CalcTailBasicBlock() | 121 | void MatMulV3AswTiling::CalcTailBasicBlock() |
| 122 | { | 122 | { |
| @@ -25,7 +25,7 @@ constexpr uint64_t FP32_SPLIT_K_THRESHOLD = 8192UL; | |||
| 25 | using namespace strategy; | 25 | using namespace strategy; |
| 26 | 26 | ||
| 27 | // 注册BASIC_FULL_LOAD作为基础API实现的全载模板策略 | 27 | // 注册BASIC_FULL_LOAD作为基础API实现的全载模板策略 |
| 28 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3BasicAswtTiling, ASCEND950, BASIC_ASWT); | 28 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3BasicAswtTiling, DAV_3510, BASIC_ASWT); |
| 29 | 29 | ||
| 30 | bool MatMulV3BasicAswtTiling::IsCapable() | 30 | bool MatMulV3BasicAswtTiling::IsCapable() |
| 31 | { | 31 | { |
| @@ -53,7 +53,7 @@ uint64_t MatMulV3BasicAswtTiling::GetAFullLoadBasicNL1() const { | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | // A全载切换基础API的条件 | 55 | // A全载切换基础API的条件 |
| 56 | -bool MatMulV3BasicAswtTiling::CheckAL1FullLoad91095(uint64_t kAlignedValue, uint64_t mAlignedValue) | 56 | +bool MatMulV3BasicAswtTiling::CheckAL1FullLoadDav3510(uint64_t kAlignedValue, uint64_t mAlignedValue) |
| 57 | { | 57 | { |
| 58 | uint64_t al1Size = kAlignedValue * mAlignedValue * args_.aDtypeSize; | 58 | uint64_t al1Size = kAlignedValue * mAlignedValue * args_.aDtypeSize; |
| 59 | // 单核上只有一轮,走basic api模板, 头开销较小,无需走全载模板 | 59 | // 单核上只有一轮,走basic api模板, 头开销较小,无需走全载模板 |
| @@ -97,7 +97,7 @@ bool MatMulV3BasicAswtTiling::CheckAL1FullLoad() | |||
| 97 | kAlignedValue = ops::CeilAlign(args_.kValue, BASIC_BLOCK_SIZE_16); | 97 | kAlignedValue = ops::CeilAlign(args_.kValue, BASIC_BLOCK_SIZE_16); |
| 98 | } | 98 | } |
| 99 | // check AL1FullLoad | 99 | // check AL1FullLoad |
| 100 | - return CheckAL1FullLoad91095(kAlignedValue, mAlignedValue); | 100 | + return CheckAL1FullLoadDav3510(kAlignedValue, mAlignedValue); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | void MatMulV3BasicAswtTiling::CalcTailBasicBlockBL1Full() | 103 | void MatMulV3BasicAswtTiling::CalcTailBasicBlockBL1Full() |
| @@ -130,8 +130,8 @@ void MatMulV3BasicAswtTiling::CalcTailBasicBlockAL1Full() | |||
| 130 | } | 130 | } |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | -void MatMulV3BasicAswtTiling::AdjustAL1Tiling91095Basic([[maybe_unused]] uint64_t biasBatchDimAll /* args */) { | 133 | +void MatMulV3BasicAswtTiling::AdjustAL1Tiling3510Basic([[maybe_unused]] uint64_t biasBatchDimAll /* args */) { |
| 134 | - //biasBatchDimAll 没有被使用,但是编译器不发出警告 | 134 | + // biasBatchDimAll没有被使用,但编译器不会发出警告 |
| 135 | uint64_t kAlignedValue = ops::CeilAlign(args_.kValue, BASIC_BLOCK_SIZE_16); | 135 | uint64_t kAlignedValue = ops::CeilAlign(args_.kValue, BASIC_BLOCK_SIZE_16); |
| 136 | uint64_t mAlignedValue = ops::CeilAlign(args_.mValue, BASIC_BLOCK_SIZE_16); | 136 | uint64_t mAlignedValue = ops::CeilAlign(args_.mValue, BASIC_BLOCK_SIZE_16); |
| 137 | // aL1 LoadSize | 137 | // aL1 LoadSize |
| @@ -179,13 +179,13 @@ void MatMulV3BasicAswtTiling::DoAL1FullLoad(uint64_t bBatchDimAll, uint64_t bias | |||
| 179 | // adjust tiling common | 179 | // adjust tiling common |
| 180 | MatMulV3TilingHelper::AdjustAL1TilingCommon(bBatchDimAll, compileInfo_, args_, runInfo_); | 180 | MatMulV3TilingHelper::AdjustAL1TilingCommon(bBatchDimAll, compileInfo_, args_, runInfo_); |
| 181 | // 复用A全载的标记位, 无需再使用函数指针隔离, 不支持的平台无需设置走基础API的标记 | 181 | // 复用A全载的标记位, 无需再使用函数指针隔离, 不支持的平台无需设置走基础API的标记 |
| 182 | - AdjustAL1Tiling91095Basic(biasBatchDimAll); | 182 | + AdjustAL1Tiling3510Basic(biasBatchDimAll); |
| 183 | CalcTailBasicBlockAL1Full(); | 183 | CalcTailBasicBlockAL1Full(); |
| 184 | fullLoad_ = MatMulV3FullLoad::A_FULL_LOAD; | 184 | fullLoad_ = MatMulV3FullLoad::A_FULL_LOAD; |
| 185 | return; | 185 | return; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | -bool MatMulV3BasicAswtTiling::CheckBL1FullLoad91095(uint64_t kAlignedValue, uint64_t nAlignedValue) | 188 | +bool MatMulV3BasicAswtTiling::CheckBL1FullLoadDav3510(uint64_t kAlignedValue, uint64_t nAlignedValue) |
| 189 | { | 189 | { |
| 190 | uint64_t bl1Size = kAlignedValue * nAlignedValue * args_.bDtypeSize; | 190 | uint64_t bl1Size = kAlignedValue * nAlignedValue * args_.bDtypeSize; |
| 191 | // 单核上只有一轮,走basic api模板, 头开销较小,无需走全载模板 | 191 | // 单核上只有一轮,走basic api模板, 头开销较小,无需走全载模板 |
| @@ -224,10 +224,10 @@ bool MatMulV3BasicAswtTiling::CheckBL1FullLoad() | |||
| 224 | kAlignedValue = ops::CeilAlign(args_.kValue, BLOCK_BYTE_SIZE / args_.bDtypeSize); | 224 | kAlignedValue = ops::CeilAlign(args_.kValue, BLOCK_BYTE_SIZE / args_.bDtypeSize); |
| 225 | nAlignedValue = ops::CeilAlign(args_.nValue, BASIC_BLOCK_SIZE_16); | 225 | nAlignedValue = ops::CeilAlign(args_.nValue, BASIC_BLOCK_SIZE_16); |
| 226 | } | 226 | } |
| 227 | - return CheckBL1FullLoad91095(kAlignedValue, nAlignedValue); | 227 | + return CheckBL1FullLoadDav3510(kAlignedValue, nAlignedValue); |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | -void MatMulV3BasicAswtTiling::AdjustBL1Tiling91095Basic([[maybe_unused]] uint64_t biasBatchDimAll /* args */) | 230 | +void MatMulV3BasicAswtTiling::AdjustBL1Tiling3510Basic([[maybe_unused]] uint64_t biasBatchDimAll /* args */) |
| 231 | { | 231 | { |
| 232 | //biasBatchDimAll 没有被使用,但是编译器不发出警告 | 232 | //biasBatchDimAll 没有被使用,但是编译器不发出警告 |
| 233 | uint64_t kAlignedValue = ops::CeilAlign(args_.kValue, BASIC_BLOCK_SIZE_16); | 233 | uint64_t kAlignedValue = ops::CeilAlign(args_.kValue, BASIC_BLOCK_SIZE_16); |
| @@ -268,7 +268,7 @@ void MatMulV3BasicAswtTiling::DoBL1FullLoad(uint64_t aBatchDimAll, uint64_t bias | |||
| 268 | MatMulV3TilingHelper::ResetFullLoadLoadBalance(runInfo_); | 268 | MatMulV3TilingHelper::ResetFullLoadLoadBalance(runInfo_); |
| 269 | OP_LOGI(args_.opName, "MatMulV3 tiling enable state is DoBL1FullLoad."); | 269 | OP_LOGI(args_.opName, "MatMulV3 tiling enable state is DoBL1FullLoad."); |
| 270 | MatMulV3TilingHelper::AdjustBL1TilingCommon(aBatchDimAll, compileInfo_, args_, runInfo_); | 270 | MatMulV3TilingHelper::AdjustBL1TilingCommon(aBatchDimAll, compileInfo_, args_, runInfo_); |
| 271 | - AdjustBL1Tiling91095Basic(biasBatchDimAll); | 271 | + AdjustBL1Tiling3510Basic(biasBatchDimAll); |
| 272 | CalcTailBasicBlockBL1Full(); | 272 | CalcTailBasicBlockBL1Full(); |
| 273 | fullLoad_ = MatMulV3FullLoad::B_FULL_LOAD; | 273 | fullLoad_ = MatMulV3FullLoad::B_FULL_LOAD; |
| 274 | return; | 274 | return; |
| @@ -26,10 +26,10 @@ public: | |||
| 26 | MatMulV3BasicAswtTiling(gert::TilingContext *context, MatMulTilingCfg &cfg) | 26 | MatMulV3BasicAswtTiling(gert::TilingContext *context, MatMulTilingCfg &cfg) |
| 27 | : MatMulV3AswTiling(context, cfg) {}; | 27 | : MatMulV3AswTiling(context, cfg) {}; |
| 28 | ~MatMulV3BasicAswtTiling() override = default; | 28 | ~MatMulV3BasicAswtTiling() override = default; |
| 29 | - bool CheckBL1FullLoad91095(uint64_t kAlignedValue, uint64_t nAlignedValue); | 29 | + bool CheckBL1FullLoadDav3510(uint64_t kAlignedValue, uint64_t nAlignedValue); |
| 30 | - bool CheckAL1FullLoad91095(uint64_t kAlignedValue, uint64_t mAlignedValue); | 30 | + bool CheckAL1FullLoadDav3510(uint64_t kAlignedValue, uint64_t mAlignedValue); |
| 31 | - void AdjustBL1Tiling91095Basic(uint64_t biasBatchDimAll); | 31 | + void AdjustBL1Tiling3510Basic(uint64_t biasBatchDimAll); |
| 32 | - void AdjustAL1Tiling91095Basic(uint64_t biasBatchDimAll); | 32 | + void AdjustAL1Tiling3510Basic(uint64_t biasBatchDimAll); |
| 33 | 33 | ||
| 34 | protected: | 34 | protected: |
| 35 | bool IsCapable() override; | 35 | bool IsCapable() override; |
| @@ -29,7 +29,7 @@ bool CheckStreamKDPSKTilingDefault(const MatmulV3CompileInfo & /* compileInfo */ | |||
| 29 | return false; | 29 | return false; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | -bool CheckStreamKDPSKTiling91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) | 32 | +bool CheckStreamKDPSKTilingDav3510(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) |
| 33 | { | 33 | { |
| 34 | constexpr uint64_t STREAM_K_MIN_K_THRESHOLD = 8192UL; | 34 | constexpr uint64_t STREAM_K_MIN_K_THRESHOLD = 8192UL; |
| 35 | // 如果k轴小于32*256/DtypeSize_ 或 mn轴不是256对齐 或 输入是fp32类型,不走stream-k-dpsk | 35 | // 如果k轴小于32*256/DtypeSize_ 或 mn轴不是256对齐 或 输入是fp32类型,不走stream-k-dpsk |
| @@ -49,8 +49,8 @@ bool CheckStreamKDPSKTiling91095(const MatmulV3CompileInfo &compileInfo, const M | |||
| 49 | 49 | ||
| 50 | using CheckStreamKDPSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); | 50 | using CheckStreamKDPSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); |
| 51 | 51 | ||
| 52 | -const static std::map<platform_ascendc::SocVersion, CheckStreamKDPSKTilingFunc> CheckStreamKDPSKTilingFuncMap = { | 52 | +const static std::map<NpuArch, CheckStreamKDPSKTilingFunc> CheckStreamKDPSKTilingFuncMap = { |
| 53 | - {platform_ascendc::SocVersion::ASCEND950, CheckStreamKDPSKTiling91095}, | 53 | + {NpuArch::DAV_3510, CheckStreamKDPSKTilingDav3510}, |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | // ------------------------------ CheckStreamKSKTiling -------------------------------------------// | 56 | // ------------------------------ CheckStreamKSKTiling -------------------------------------------// |
| @@ -59,7 +59,7 @@ bool CheckStreamKSKTilingDefault(const MatmulV3CompileInfo & /* compileInfo */, | |||
| 59 | return false; | 59 | return false; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | -bool CheckStreamKSKTiling91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) | 62 | +bool CheckStreamKSKTilingDav3510(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) |
| 63 | { | 63 | { |
| 64 | constexpr uint64_t STREAM_K_MAX_K_THRESHOLD = 2000000UL; | 64 | constexpr uint64_t STREAM_K_MAX_K_THRESHOLD = 2000000UL; |
| 65 | // 如果dtype是fp32且k轴大于200万 则走基础模板来保证fp32的精度 | 65 | // 如果dtype是fp32且k轴大于200万 则走基础模板来保证fp32的精度 |
| @@ -92,8 +92,8 @@ bool CheckStreamKSKTiling91095(const MatmulV3CompileInfo &compileInfo, const Mat | |||
| 92 | 92 | ||
| 93 | using CheckStreamKSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); | 93 | using CheckStreamKSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); |
| 94 | 94 | ||
| 95 | -const static std::map<platform_ascendc::SocVersion, CheckStreamKSKTilingFunc> CheckStreamKSKTilingFuncMap = { | 95 | +const static std::map<NpuArch, CheckStreamKSKTilingFunc> CheckStreamKSKTilingFuncMap = { |
| 96 | - {platform_ascendc::SocVersion::ASCEND950, CheckStreamKSKTiling91095}, | 96 | + {NpuArch::DAV_3510, CheckStreamKSKTilingDav3510}, |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | // ------------------------------ GetL0C2OutFlag -------------------------------------------// | 99 | // ------------------------------ GetL0C2OutFlag -------------------------------------------// |
| @@ -102,7 +102,7 @@ MatMulV3L0C2Out GetL0C2OutFlagDefault(const MatMulV3Args & /* args */) | |||
| 102 | return MatMulV3L0C2Out::ON_THE_FLY; | 102 | return MatMulV3L0C2Out::ON_THE_FLY; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | -MatMulV3L0C2Out GetL0C2OutFlag91095(const MatMulV3Args &args) | 105 | +MatMulV3L0C2Out GetL0C2OutFlagDav3510(const MatMulV3Args &args) |
| 106 | { | 106 | { |
| 107 | if (args.nValue > BASIC_BLOCK_SIZE_64 && args.nValue % BASIC_BLOCK_SIZE_16 != 0 && args.mValue > NUM_TWO && | 107 | if (args.nValue > BASIC_BLOCK_SIZE_64 && args.nValue % BASIC_BLOCK_SIZE_16 != 0 && args.mValue > NUM_TWO && |
| 108 | args.mValue * args.nValue >= BASIC_BLOCK_SIZE_256) { | 108 | args.mValue * args.nValue >= BASIC_BLOCK_SIZE_256) { |
| @@ -113,8 +113,8 @@ MatMulV3L0C2Out GetL0C2OutFlag91095(const MatMulV3Args &args) | |||
| 113 | 113 | ||
| 114 | using GetL0C2OutFlagFunc = MatMulV3L0C2Out (*)(const MatMulV3Args &); | 114 | using GetL0C2OutFlagFunc = MatMulV3L0C2Out (*)(const MatMulV3Args &); |
| 115 | 115 | ||
| 116 | -const static std::map<platform_ascendc::SocVersion, GetL0C2OutFlagFunc> GetL0C2OutFlagFuncMap = { | 116 | +const static std::map<NpuArch, GetL0C2OutFlagFunc> GetL0C2OutFlagFuncMap = { |
| 117 | - {platform_ascendc::SocVersion::ASCEND950, GetL0C2OutFlag91095}, | 117 | + {NpuArch::DAV_3510, GetL0C2OutFlagDav3510}, |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | } // namespace | 120 | } // namespace |
| @@ -122,29 +122,29 @@ const static std::map<platform_ascendc::SocVersion, GetL0C2OutFlagFunc> GetL0C2O | |||
| 122 | namespace optiling { | 122 | namespace optiling { |
| 123 | namespace matmul_v3_advanced { | 123 | namespace matmul_v3_advanced { |
| 124 | using namespace strategy; | 124 | using namespace strategy; |
| 125 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3BasicStreamKTiling, ASCEND950, BASIC_STREAM_K); | 125 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3BasicStreamKTiling, DAV_3510, BASIC_STREAM_K); |
| 126 | 126 | ||
| 127 | bool MatMulV3BasicStreamKTiling::CheckStreamKSKTiling() const | 127 | bool MatMulV3BasicStreamKTiling::CheckStreamKSKTiling() const |
| 128 | { | 128 | { |
| 129 | - auto iter = (CheckStreamKSKTilingFuncMap.find(compileInfo_.socVersion) == CheckStreamKSKTilingFuncMap.end()) | 129 | + auto iter = (CheckStreamKSKTilingFuncMap.find(compileInfo_.npuArch) == CheckStreamKSKTilingFuncMap.end()) |
| 130 | ? CheckStreamKSKTilingDefault | 130 | ? CheckStreamKSKTilingDefault |
| 131 | - : CheckStreamKSKTilingFuncMap.at(compileInfo_.socVersion); | 131 | + : CheckStreamKSKTilingFuncMap.at(compileInfo_.npuArch); |
| 132 | return iter(compileInfo_, args_); | 132 | return iter(compileInfo_, args_); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | bool MatMulV3BasicStreamKTiling::CheckStreamKDPSKTiling() const | 135 | bool MatMulV3BasicStreamKTiling::CheckStreamKDPSKTiling() const |
| 136 | { | 136 | { |
| 137 | - auto iter = (CheckStreamKDPSKTilingFuncMap.find(compileInfo_.socVersion) == CheckStreamKDPSKTilingFuncMap.end()) | 137 | + auto iter = (CheckStreamKDPSKTilingFuncMap.find(compileInfo_.npuArch) == CheckStreamKDPSKTilingFuncMap.end()) |
| 138 | ? CheckStreamKDPSKTilingDefault | 138 | ? CheckStreamKDPSKTilingDefault |
| 139 | - : CheckStreamKDPSKTilingFuncMap.at(compileInfo_.socVersion); | 139 | + : CheckStreamKDPSKTilingFuncMap.at(compileInfo_.npuArch); |
| 140 | return iter(compileInfo_, args_); | 140 | return iter(compileInfo_, args_); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | MatMulV3L0C2Out MatMulV3BasicStreamKTiling::GetL0C2OutFlag() const | 143 | MatMulV3L0C2Out MatMulV3BasicStreamKTiling::GetL0C2OutFlag() const |
| 144 | { | 144 | { |
| 145 | - auto iter = (GetL0C2OutFlagFuncMap.find(compileInfo_.socVersion) == GetL0C2OutFlagFuncMap.end()) | 145 | + auto iter = (GetL0C2OutFlagFuncMap.find(compileInfo_.npuArch) == GetL0C2OutFlagFuncMap.end()) |
| 146 | ? GetL0C2OutFlagDefault | 146 | ? GetL0C2OutFlagDefault |
| 147 | - : GetL0C2OutFlagFuncMap.at(compileInfo_.socVersion); | 147 | + : GetL0C2OutFlagFuncMap.at(compileInfo_.npuArch); |
| 148 | return iter(args_); | 148 | return iter(args_); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| @@ -43,6 +43,7 @@ inline ge::graphStatus InitCompileInfo(fe::PlatFormInfos *platformInfo, MatmulV3 | |||
| 43 | bool supportMmadS8S4 = res && mmad.find("s8s4") != std::string::npos; | 43 | bool supportMmadS8S4 = res && mmad.find("s8s4") != std::string::npos; |
| 44 | compileInfoPtr->socVersion = | 44 | compileInfoPtr->socVersion = |
| 45 | supportMmadS8S4 ? platform_ascendc::SocVersion::RESERVED_VERSION : ascendcPlatform.GetSocVersion(); | 45 | supportMmadS8S4 ? platform_ascendc::SocVersion::RESERVED_VERSION : ascendcPlatform.GetSocVersion(); |
| 46 | + compileInfoPtr->npuArch = supportMmadS8S4 ? NpuArch::DAV_RESV : ascendcPlatform.GetCurNpuArch(); | ||
| 46 | compileInfoPtr->supportL0c2out = false; // Not used | 47 | compileInfoPtr->supportL0c2out = false; // Not used |
| 47 | compileInfoPtr->supportL12BtBf16 = false; // Not used | 48 | compileInfoPtr->supportL12BtBf16 = false; // Not used |
| 48 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 49 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -53,12 +54,14 @@ inline ge::graphStatus InitCompileInfo(fe::PlatFormInfos *platformInfo, MatmulV3 | |||
| 53 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L2, compileInfoPtr->l2Size); | 54 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::L2, compileInfoPtr->l2Size); |
| 54 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::BT, compileInfoPtr->btSize); | 55 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::BT, compileInfoPtr->btSize); |
| 55 | OP_LOGI("MatMul", | 56 | OP_LOGI("MatMul", |
| 56 | - "parse compile info success soc:%d, aicNum:%lu, aivNum:%lu, ubSize:%lu, l1Size:%lu, l2Size:%lu, l0ASize:%lu, " | 57 | + "parse compile info success soc:%d, npuArch:%u, " |
| 58 | + "aicNum:%lu, aivNum:%lu, ubSize:%lu, l1Size:%lu, l2Size:%lu, l0ASize:%lu, " | ||
| 57 | "l0BSize:%lu, " | 59 | "l0BSize:%lu, " |
| 58 | "l0CSize:%lu, btSize:%lu", | 60 | "l0CSize:%lu, btSize:%lu", |
| 59 | - static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->aicNum, compileInfoPtr->aivNum, | 61 | + static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->npuArch, |
| 60 | - compileInfoPtr->ubSize, compileInfoPtr->l1Size, compileInfoPtr->l2Size, compileInfoPtr->l0ASize, | 62 | + compileInfoPtr->aicNum, compileInfoPtr->aivNum, compileInfoPtr->ubSize, compileInfoPtr->l1Size, |
| 61 | - compileInfoPtr->l0BSize, compileInfoPtr->l0CSize, compileInfoPtr->btSize); | 63 | + compileInfoPtr->l2Size, compileInfoPtr->l0ASize, compileInfoPtr->l0BSize, |
| 64 | + compileInfoPtr->l0CSize, compileInfoPtr->btSize); | ||
| 62 | return ge::GRAPH_SUCCESS; | 65 | return ge::GRAPH_SUCCESS; |
| 63 | } | 66 | } |
| 64 | 67 | ||
| @@ -23,7 +23,7 @@ namespace optiling { | |||
| 23 | namespace matmul_v3_advanced { | 23 | namespace matmul_v3_advanced { |
| 24 | using namespace strategy; | 24 | using namespace strategy; |
| 25 | 25 | ||
| 26 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3KEqZeroTiling, ASCEND950, MATMUL_INPUT_K_EQUAL_ZERO); | 26 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3KEqZeroTiling, DAV_3510, MATMUL_INPUT_K_EQUAL_ZERO); |
| 27 | 27 | ||
| 28 | bool MatMulV3KEqZeroTiling::IsCapable() | 28 | bool MatMulV3KEqZeroTiling::IsCapable() |
| 29 | { | 29 | { |
| @@ -30,7 +30,7 @@ bool CheckStreamKSKTilingDefault(const MatmulV3CompileInfo & /* compileInfo */, | |||
| 30 | return false; | 30 | return false; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | -bool CheckStreamKSKTiling91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) | 33 | +bool CheckStreamKSKTilingDav3510(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) |
| 34 | { | 34 | { |
| 35 | constexpr uint64_t STREAM_K_MIN_K_THRESHOLD = 8192UL; | 35 | constexpr uint64_t STREAM_K_MIN_K_THRESHOLD = 8192UL; |
| 36 | // 判断k轴是否大于32*256 / DtypeSize_, 小于就不走stream-k | 36 | // 判断k轴是否大于32*256 / DtypeSize_, 小于就不走stream-k |
| @@ -56,8 +56,8 @@ bool CheckStreamKSKTiling91095(const MatmulV3CompileInfo &compileInfo, const Mat | |||
| 56 | 56 | ||
| 57 | using CheckStreamKSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); | 57 | using CheckStreamKSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); |
| 58 | 58 | ||
| 59 | -const static std::map<platform_ascendc::SocVersion, CheckStreamKSKTilingFunc> CheckStreamKSKTilingFuncMap = { | 59 | +const static std::map<NpuArch, CheckStreamKSKTilingFunc> CheckStreamKSKTilingFuncMap = { |
| 60 | - {platform_ascendc::SocVersion::ASCEND950, CheckStreamKSKTiling91095}, | 60 | + {NpuArch::DAV_3510, CheckStreamKSKTilingDav3510}, |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | // ------------------------------ CheckStreamKDPSKTiling -------------------------------------------// | 63 | // ------------------------------ CheckStreamKDPSKTiling -------------------------------------------// |
| @@ -66,7 +66,7 @@ bool CheckStreamKDPSKTilingDefault(const MatmulV3CompileInfo & /* compileInfo */ | |||
| 66 | return false; | 66 | return false; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | -bool CheckStreamKDPSKTiling91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) | 69 | +bool CheckStreamKDPSKTilingDav3510(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args) |
| 70 | { | 70 | { |
| 71 | constexpr uint64_t STREAM_K_MIN_K_THRESHOLD = 8192UL; | 71 | constexpr uint64_t STREAM_K_MIN_K_THRESHOLD = 8192UL; |
| 72 | // 如果k轴小于32*256/DtypeSize_ 或 mn轴不是256对齐 或 输入是fp32类型,不走stream-k-dpsk | 72 | // 如果k轴小于32*256/DtypeSize_ 或 mn轴不是256对齐 或 输入是fp32类型,不走stream-k-dpsk |
| @@ -86,8 +86,8 @@ bool CheckStreamKDPSKTiling91095(const MatmulV3CompileInfo &compileInfo, const M | |||
| 86 | 86 | ||
| 87 | using CheckStreamKDPSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); | 87 | using CheckStreamKDPSKTilingFunc = bool (*)(const MatmulV3CompileInfo &, const MatMulV3Args &); |
| 88 | 88 | ||
| 89 | -const static std::map<platform_ascendc::SocVersion, CheckStreamKDPSKTilingFunc> CheckStreamKDPSKTilingFuncMap = { | 89 | +const static std::map<NpuArch, CheckStreamKDPSKTilingFunc> CheckStreamKDPSKTilingFuncMap = { |
| 90 | - {platform_ascendc::SocVersion::ASCEND950, CheckStreamKDPSKTiling91095}, | 90 | + {NpuArch::DAV_3510, CheckStreamKDPSKTilingDav3510}, |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | // ------------------------------ GetL0C2OutFlag -------------------------------------------// | 93 | // ------------------------------ GetL0C2OutFlag -------------------------------------------// |
| @@ -96,7 +96,7 @@ MatMulV3L0C2Out GetL0C2OutFlagDefault(const MatMulV3Args & /* args */) | |||
| 96 | return MatMulV3L0C2Out::ON_THE_FLY; | 96 | return MatMulV3L0C2Out::ON_THE_FLY; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | -MatMulV3L0C2Out GetL0C2OutFlag91095(const MatMulV3Args &args) | 99 | +MatMulV3L0C2Out GetL0C2OutFlagDav3510(const MatMulV3Args &args) |
| 100 | { | 100 | { |
| 101 | if (args.nValue > BASIC_BLOCK_SIZE_64 && args.nValue % BASIC_BLOCK_SIZE_16 != 0 && args.mValue > NUM_TWO && | 101 | if (args.nValue > BASIC_BLOCK_SIZE_64 && args.nValue % BASIC_BLOCK_SIZE_16 != 0 && args.mValue > NUM_TWO && |
| 102 | args.mValue * args.nValue >= BASIC_BLOCK_SIZE_256) { | 102 | args.mValue * args.nValue >= BASIC_BLOCK_SIZE_256) { |
| @@ -107,8 +107,8 @@ MatMulV3L0C2Out GetL0C2OutFlag91095(const MatMulV3Args &args) | |||
| 107 | 107 | ||
| 108 | using GetL0C2OutFlagFunc = MatMulV3L0C2Out (*)(const MatMulV3Args &); | 108 | using GetL0C2OutFlagFunc = MatMulV3L0C2Out (*)(const MatMulV3Args &); |
| 109 | 109 | ||
| 110 | -const static std::map<platform_ascendc::SocVersion, GetL0C2OutFlagFunc> GetL0C2OutFlagFuncMap = { | 110 | +const static std::map<NpuArch, GetL0C2OutFlagFunc> GetL0C2OutFlagFuncMap = { |
| 111 | - {platform_ascendc::SocVersion::ASCEND950, GetL0C2OutFlag91095}, | 111 | + {NpuArch::DAV_3510, GetL0C2OutFlagDav3510}, |
| 112 | }; | 112 | }; |
| 113 | } // namespace | 113 | } // namespace |
| 114 | 114 | ||
| @@ -116,31 +116,31 @@ namespace optiling { | |||
| 116 | namespace matmul_v3_advanced { | 116 | namespace matmul_v3_advanced { |
| 117 | using namespace strategy; | 117 | using namespace strategy; |
| 118 | 118 | ||
| 119 | -MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3StreamKTiling, ASCEND950, STREAM_K); | 119 | +MM_REGISTER_TILING_TEMPLATE(MatMulV3, MatMulV3StreamKTiling, DAV_3510, STREAM_K); |
| 120 | 120 | ||
| 121 | constexpr uint64_t STREAM_K_MAX_K_THRESHOLD = 2000000UL; | 121 | constexpr uint64_t STREAM_K_MAX_K_THRESHOLD = 2000000UL; |
| 122 | 122 | ||
| 123 | bool MatMulV3StreamKTiling::CheckStreamKSKTiling() const | 123 | bool MatMulV3StreamKTiling::CheckStreamKSKTiling() const |
| 124 | { | 124 | { |
| 125 | - auto iter = (CheckStreamKSKTilingFuncMap.find(compileInfo_.socVersion) == CheckStreamKSKTilingFuncMap.end()) | 125 | + auto iter = (CheckStreamKSKTilingFuncMap.find(compileInfo_.npuArch) == CheckStreamKSKTilingFuncMap.end()) |
| 126 | ? CheckStreamKSKTilingDefault | 126 | ? CheckStreamKSKTilingDefault |
| 127 | - : CheckStreamKSKTilingFuncMap.at(compileInfo_.socVersion); | 127 | + : CheckStreamKSKTilingFuncMap.at(compileInfo_.npuArch); |
| 128 | return iter(compileInfo_, args_); | 128 | return iter(compileInfo_, args_); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | bool MatMulV3StreamKTiling::CheckStreamKDPSKTiling() const | 131 | bool MatMulV3StreamKTiling::CheckStreamKDPSKTiling() const |
| 132 | { | 132 | { |
| 133 | - auto iter = (CheckStreamKDPSKTilingFuncMap.find(compileInfo_.socVersion) == CheckStreamKDPSKTilingFuncMap.end()) | 133 | + auto iter = (CheckStreamKDPSKTilingFuncMap.find(compileInfo_.npuArch) == CheckStreamKDPSKTilingFuncMap.end()) |
| 134 | ? CheckStreamKDPSKTilingDefault | 134 | ? CheckStreamKDPSKTilingDefault |
| 135 | - : CheckStreamKDPSKTilingFuncMap.at(compileInfo_.socVersion); | 135 | + : CheckStreamKDPSKTilingFuncMap.at(compileInfo_.npuArch); |
| 136 | return iter(compileInfo_, args_); | 136 | return iter(compileInfo_, args_); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | MatMulV3L0C2Out MatMulV3StreamKTiling::GetL0C2OutFlag() const | 139 | MatMulV3L0C2Out MatMulV3StreamKTiling::GetL0C2OutFlag() const |
| 140 | { | 140 | { |
| 141 | - auto iter = (GetL0C2OutFlagFuncMap.find(compileInfo_.socVersion) == GetL0C2OutFlagFuncMap.end()) | 141 | + auto iter = (GetL0C2OutFlagFuncMap.find(compileInfo_.npuArch) == GetL0C2OutFlagFuncMap.end()) |
| 142 | ? GetL0C2OutFlagDefault | 142 | ? GetL0C2OutFlagDefault |
| 143 | - : GetL0C2OutFlagFuncMap.at(compileInfo_.socVersion); | 143 | + : GetL0C2OutFlagFuncMap.at(compileInfo_.npuArch); |
| 144 | return iter(args_); | 144 | return iter(args_); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| @@ -164,9 +164,8 @@ ge::graphStatus MatMulV3Tiling::DoTiling() | |||
| 164 | } | 164 | } |
| 165 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), reinterpret_cast<void *>(&args_)); | 165 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), reinterpret_cast<void *>(&args_)); |
| 166 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); | 166 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); |
| 167 | - platform_ascendc::SocVersion socVersion = | 167 | + NpuArch npuArch = reinterpret_cast<const MatmulV3CompileInfo *>(tilingCfg.compileInfo)->npuArch; |
| 168 | - reinterpret_cast<const MatmulV3CompileInfo *>(tilingCfg.compileInfo)->socVersion; | 168 | + MMRegisterCfg registerCfg{ "MatMulV3", npuArch, strategy::GetMatMulV3Priorities(npuArch) }; |
| 169 | - MMRegisterCfg registerCfg{ "MatMulV3", socVersion, strategy::GetMatMulV3Priorities(socVersion) }; | ||
| 170 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); | 169 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); |
| 171 | } | 170 | } |
| 172 | 171 | ||
| @@ -99,8 +99,8 @@ void CalL1Tiling310P(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args | |||
| 99 | 99 | ||
| 100 | using CalL1TilingFunc = void (*)(const MatmulV3CompileInfo &, const MatMulV3Args &, MatMulV3RunInfo &); | 100 | using CalL1TilingFunc = void (*)(const MatmulV3CompileInfo &, const MatMulV3Args &, MatMulV3RunInfo &); |
| 101 | 101 | ||
| 102 | -const static std::map<platform_ascendc::SocVersion, CalL1TilingFunc> CalL1TilingFuncMap = { | 102 | +const static std::map<NpuArch, CalL1TilingFunc> CalL1TilingFuncMap = { |
| 103 | - {platform_ascendc::SocVersion::ASCEND310P, CalL1Tiling310P}, | 103 | + {NpuArch::DAV_2002, CalL1Tiling310P}, |
| 104 | }; | 104 | }; |
| 105 | 105 | ||
| 106 | // ------------------------------ ResetBase -------------------------------------------// | 106 | // ------------------------------ ResetBase -------------------------------------------// |
| @@ -123,7 +123,7 @@ void ResetBaseDefault(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args | |||
| 123 | runInfo.tailInfo.nTailMain = INIT_SPLIT_VALUE; | 123 | runInfo.tailInfo.nTailMain = INIT_SPLIT_VALUE; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | -void ResetBase91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, MatMulV3RunInfo &runInfo) | 126 | +void ResetBaseDav3510(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, MatMulV3RunInfo &runInfo) |
| 127 | { | 127 | { |
| 128 | ResetBaseDefault(compileInfo, args, runInfo); | 128 | ResetBaseDefault(compileInfo, args, runInfo); |
| 129 | runInfo.baseM = BASIC_BLOCK_SIZE_256; | 129 | runInfo.baseM = BASIC_BLOCK_SIZE_256; |
| @@ -132,8 +132,8 @@ void ResetBase91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args & | |||
| 132 | 132 | ||
| 133 | using ResetBaseFunc = void (*)(const MatmulV3CompileInfo &, const MatMulV3Args &, MatMulV3RunInfo &); | 133 | using ResetBaseFunc = void (*)(const MatmulV3CompileInfo &, const MatMulV3Args &, MatMulV3RunInfo &); |
| 134 | 134 | ||
| 135 | -const static std::map<platform_ascendc::SocVersion, ResetBaseFunc> ResetBaseFuncMap = { | 135 | +const static std::map<NpuArch, ResetBaseFunc> ResetBaseFuncMap = { |
| 136 | - {platform_ascendc::SocVersion::ASCEND950, ResetBase91095}, | 136 | + {NpuArch::DAV_3510, ResetBaseDav3510}, |
| 137 | }; | 137 | }; |
| 138 | 138 | ||
| 139 | // ------------------------------ GetL0C2Out -------------------------------------------// | 139 | // ------------------------------ GetL0C2Out -------------------------------------------// |
| @@ -143,7 +143,7 @@ MatMulV3L0C2Out GetL0C2OutDefault(const MatmulV3CompileInfo & /* compileInfo */, | |||
| 143 | return MatMulV3L0C2Out::ON_THE_FLY; | 143 | return MatMulV3L0C2Out::ON_THE_FLY; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | -MatMulV3L0C2Out GetL0C2Out91095(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, | 146 | +MatMulV3L0C2Out GetL0C2OutDav3510(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, |
| 147 | const MatMulV3RunInfo &runInfo) | 147 | const MatMulV3RunInfo &runInfo) |
| 148 | { | 148 | { |
| 149 | bool isValidMKN = args.kValue <= BASIC_BLOCK_SIZE_256 && args.mValue >= BASIC_BLOCK_SIZE_256; | 149 | bool isValidMKN = args.kValue <= BASIC_BLOCK_SIZE_256 && args.mValue >= BASIC_BLOCK_SIZE_256; |
| @@ -166,8 +166,8 @@ MatMulV3L0C2Out GetL0C2Out91095(const MatmulV3CompileInfo &compileInfo, const Ma | |||
| 166 | 166 | ||
| 167 | using GetL0C2OutFunc = MatMulV3L0C2Out (*)(const MatmulV3CompileInfo &, const MatMulV3Args &, const MatMulV3RunInfo &); | 167 | using GetL0C2OutFunc = MatMulV3L0C2Out (*)(const MatmulV3CompileInfo &, const MatMulV3Args &, const MatMulV3RunInfo &); |
| 168 | 168 | ||
| 169 | -const static std::map<platform_ascendc::SocVersion, GetL0C2OutFunc> GetL0C2OutFuncMap = { | 169 | +const static std::map<NpuArch, GetL0C2OutFunc> GetL0C2OutFuncMap = { |
| 170 | - {platform_ascendc::SocVersion::ASCEND950, GetL0C2Out91095}, | 170 | + {NpuArch::DAV_3510, GetL0C2OutDav3510}, |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| 173 | 173 | ||
| @@ -177,7 +177,7 @@ uint64_t GetStepSmallKDefault(const MatMulV3Args& /* args */, const MatMulV3RunI | |||
| 177 | return isBL1FullLoad ? runInfo.stepKa : runInfo.stepKb; | 177 | return isBL1FullLoad ? runInfo.stepKa : runInfo.stepKb; |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | -uint64_t GetStepSmallK91095(const MatMulV3Args& args, const MatMulV3RunInfo& runInfo, bool isBL1FullLoad) | 180 | +uint64_t GetStepSmallKDav3510(const MatMulV3Args& args, const MatMulV3RunInfo& runInfo, bool isBL1FullLoad) |
| 181 | { | 181 | { |
| 182 | uint64_t stepBigK = runInfo.stepKa; | 182 | uint64_t stepBigK = runInfo.stepKa; |
| 183 | uint64_t stepSmallK = runInfo.stepKb; | 183 | uint64_t stepSmallK = runInfo.stepKb; |
| @@ -207,8 +207,8 @@ uint64_t GetStepSmallK91095(const MatMulV3Args& args, const MatMulV3RunInfo& run | |||
| 207 | using GetStepSmallKFunc = uint64_t (*)(const MatMulV3Args&, const MatMulV3RunInfo&, bool); | 207 | using GetStepSmallKFunc = uint64_t (*)(const MatMulV3Args&, const MatMulV3RunInfo&, bool); |
| 208 | 208 | ||
| 209 | // 全载模板修改stepK | 209 | // 全载模板修改stepK |
| 210 | -const static std::map<platform_ascendc::SocVersion, GetStepSmallKFunc> GetStepSmallKFuncMap = { | 210 | +const static std::map<NpuArch, GetStepSmallKFunc> GetStepSmallKFuncMap = { |
| 211 | - {platform_ascendc::SocVersion::ASCEND950, GetStepSmallK91095}, | 211 | + {NpuArch::DAV_3510, GetStepSmallKDav3510}, |
| 212 | }; | 212 | }; |
| 213 | } // namespace | 213 | } // namespace |
| 214 | 214 | ||
| @@ -217,36 +217,36 @@ namespace matmul_v3_advanced { | |||
| 217 | void MatMulV3TilingHelper::ResetBase(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, | 217 | void MatMulV3TilingHelper::ResetBase(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, |
| 218 | MatMulV3RunInfo &runInfo) | 218 | MatMulV3RunInfo &runInfo) |
| 219 | { | 219 | { |
| 220 | - auto iter = (ResetBaseFuncMap.find(compileInfo.socVersion) == ResetBaseFuncMap.end()) | 220 | + auto iter = (ResetBaseFuncMap.find(compileInfo.npuArch) == ResetBaseFuncMap.end()) |
| 221 | ? ResetBaseDefault | 221 | ? ResetBaseDefault |
| 222 | - : ResetBaseFuncMap.at(compileInfo.socVersion); | 222 | + : ResetBaseFuncMap.at(compileInfo.npuArch); |
| 223 | iter(compileInfo, args, runInfo); | 223 | iter(compileInfo, args, runInfo); |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | void MatMulV3TilingHelper::CalL1Tiling(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, | 226 | void MatMulV3TilingHelper::CalL1Tiling(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, |
| 227 | MatMulV3RunInfo &runInfo) | 227 | MatMulV3RunInfo &runInfo) |
| 228 | { | 228 | { |
| 229 | - auto iter = (CalL1TilingFuncMap.find(compileInfo.socVersion) == CalL1TilingFuncMap.end()) | 229 | + auto iter = (CalL1TilingFuncMap.find(compileInfo.npuArch) == CalL1TilingFuncMap.end()) |
| 230 | ? CalL1TilingDefault | 230 | ? CalL1TilingDefault |
| 231 | - : CalL1TilingFuncMap.at(compileInfo.socVersion); | 231 | + : CalL1TilingFuncMap.at(compileInfo.npuArch); |
| 232 | iter(compileInfo, args, runInfo); | 232 | iter(compileInfo, args, runInfo); |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | MatMulV3L0C2Out MatMulV3TilingHelper::GetL0C2Out(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, | 235 | MatMulV3L0C2Out MatMulV3TilingHelper::GetL0C2Out(const MatmulV3CompileInfo &compileInfo, const MatMulV3Args &args, |
| 236 | const MatMulV3RunInfo &runInfo) | 236 | const MatMulV3RunInfo &runInfo) |
| 237 | { | 237 | { |
| 238 | - auto iter = (GetL0C2OutFuncMap.find(compileInfo.socVersion) == GetL0C2OutFuncMap.end()) | 238 | + auto iter = (GetL0C2OutFuncMap.find(compileInfo.npuArch) == GetL0C2OutFuncMap.end()) |
| 239 | ? GetL0C2OutDefault | 239 | ? GetL0C2OutDefault |
| 240 | - : GetL0C2OutFuncMap.at(compileInfo.socVersion); | 240 | + : GetL0C2OutFuncMap.at(compileInfo.npuArch); |
| 241 | return iter(compileInfo, args, runInfo); | 241 | return iter(compileInfo, args, runInfo); |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | uint64_t MatMulV3TilingHelper::GetStepSmallK( | 244 | uint64_t MatMulV3TilingHelper::GetStepSmallK( |
| 245 | bool isBL1FullLoad, const MatmulV3CompileInfo& compileInfo, const MatMulV3Args& args, MatMulV3RunInfo& runInfo) | 245 | bool isBL1FullLoad, const MatmulV3CompileInfo& compileInfo, const MatMulV3Args& args, MatMulV3RunInfo& runInfo) |
| 246 | { | 246 | { |
| 247 | - auto iter = (GetStepSmallKFuncMap.find(compileInfo.socVersion) == GetStepSmallKFuncMap.end()) ? | 247 | + auto iter = (GetStepSmallKFuncMap.find(compileInfo.npuArch) == GetStepSmallKFuncMap.end()) ? |
| 248 | GetStepSmallKDefault : | 248 | GetStepSmallKDefault : |
| 249 | - GetStepSmallKFuncMap.at(compileInfo.socVersion); | 249 | + GetStepSmallKFuncMap.at(compileInfo.npuArch); |
| 250 | return iter(args, runInfo, isBL1FullLoad); | 250 | return iter(args, runInfo, isBL1FullLoad); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| @@ -32,18 +32,18 @@ constexpr int32_t BASIC_ASWT = 3; | |||
| 32 | constexpr int32_t FULL_LOAD_BASE = 4; | 32 | constexpr int32_t FULL_LOAD_BASE = 4; |
| 33 | constexpr int32_t BASE = 999; | 33 | constexpr int32_t BASE = 999; |
| 34 | 34 | ||
| 35 | -const static std::map<platform_ascendc::SocVersion, std::vector<int32_t>> MatMulV3PrioritiesMap = { | 35 | +const static std::map<NpuArch, std::vector<int32_t>> MatMulV3PrioritiesMap = { |
| 36 | - {platform_ascendc::SocVersion::ASCEND950, | 36 | + {NpuArch::DAV_3510, |
| 37 | {strategy::MATMUL_INPUT_K_EQUAL_ZERO, strategy::BASIC_STREAM_K, strategy::STREAM_K, strategy::BASIC_ASWT, | 37 | {strategy::MATMUL_INPUT_K_EQUAL_ZERO, strategy::BASIC_STREAM_K, strategy::STREAM_K, strategy::BASIC_ASWT, |
| 38 | strategy::FULL_LOAD_BASE}}, | 38 | strategy::FULL_LOAD_BASE}}, |
| 39 | - {platform_ascendc::SocVersion::RESERVED_VERSION, {strategy::BASE}}, // supportMmadS8S4平台 | 39 | + {NpuArch::DAV_RESV, {strategy::BASE}}, // supportMmadS8S4平台 |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | -inline std::vector<int32_t> GetMatMulV3Priorities(platform_ascendc::SocVersion socVersion) | 42 | +inline std::vector<int32_t> GetMatMulV3Priorities(NpuArch npuArch) |
| 43 | { | 43 | { |
| 44 | std::vector<int32_t> priorities = {}; | 44 | std::vector<int32_t> priorities = {}; |
| 45 | - if (MatMulV3PrioritiesMap.find(socVersion) != MatMulV3PrioritiesMap.end()) { | 45 | + if (MatMulV3PrioritiesMap.find(npuArch) != MatMulV3PrioritiesMap.end()) { |
| 46 | - priorities = MatMulV3PrioritiesMap.at(socVersion); | 46 | + priorities = MatMulV3PrioritiesMap.at(npuArch); |
| 47 | } | 47 | } |
| 48 | return priorities; | 48 | return priorities; |
| 49 | }; | 49 | }; |
| @@ -186,6 +186,7 @@ void MatmulV3BaseTiling::InitCompileInfo() // 检查输入属性是否支持 | |||
| 186 | compileInfo.aicNum = static_cast<uint64_t>(ascendcPlatform.GetCoreNumAic()); | 186 | compileInfo.aicNum = static_cast<uint64_t>(ascendcPlatform.GetCoreNumAic()); |
| 187 | compileInfo.aivNum = static_cast<uint64_t>(ascendcPlatform.GetCoreNumAiv()); | 187 | compileInfo.aivNum = static_cast<uint64_t>(ascendcPlatform.GetCoreNumAiv()); |
| 188 | compileInfo.socVersion = ascendcPlatform.GetSocVersion(); | 188 | compileInfo.socVersion = ascendcPlatform.GetSocVersion(); |
| 189 | + compileInfo.npuArch = ascendcPlatform.GetCurNpuArch(); | ||
| 189 | compileInfo.btSize = compileInfo.supportL0c2out ? 1024UL : 0UL; // 1024 is btSize | 190 | compileInfo.btSize = compileInfo.supportL0c2out ? 1024UL : 0UL; // 1024 is btSize |
| 190 | compileInfo.btSize = compileInfo.supportL12BtBf16 ? 4096 : compileInfo.btSize; // 4096 is btSize | 191 | compileInfo.btSize = compileInfo.supportL12BtBf16 ? 4096 : compileInfo.btSize; // 4096 is btSize |
| 191 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfo.ubSize); | 192 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfo.ubSize); |
| @@ -31,6 +31,7 @@ struct MatmulV3CompileInfo { | |||
| 31 | uint64_t l0BSize{0UL}; | 31 | uint64_t l0BSize{0UL}; |
| 32 | uint64_t btSize{0UL}; | 32 | uint64_t btSize{0UL}; |
| 33 | float cubeFreq{0}; | 33 | float cubeFreq{0}; |
| 34 | + NpuArch npuArch; | ||
| 34 | platform_ascendc::SocVersion socVersion; | 35 | platform_ascendc::SocVersion socVersion; |
| 35 | std::string socVersionStr = ""; | 36 | std::string socVersionStr = ""; |
| 36 | bool supportL0c2out = false; | 37 | bool supportL0c2out = false; |
| @@ -20,15 +20,15 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | namespace optiling { | 22 | namespace optiling { |
| 23 | -const std::initializer_list<platform_ascendc::SocVersion> AdvancedSocVersion = { | 23 | +const std::initializer_list<NpuArch> AdvancedNpuArch = { |
| 24 | - platform_ascendc::SocVersion::ASCEND950, | 24 | + NpuArch::DAV_3510, |
| 25 | - platform_ascendc::SocVersion::RESERVED_VERSION}; // supportMmadS8S4平台 | 25 | + NpuArch::DAV_RESV}; // supportMmadS8S4平台 |
| 26 | 26 | ||
| 27 | template <typename T> | 27 | template <typename T> |
| 28 | inline typename std::enable_if< | 28 | inline typename std::enable_if< |
| 29 | std::is_same<T, gert::TilingParseContext>::value || std::is_same<T, gert::TilingContext>::value, | 29 | std::is_same<T, gert::TilingParseContext>::value || std::is_same<T, gert::TilingContext>::value, |
| 30 | ge::graphStatus>::type | 30 | ge::graphStatus>::type |
| 31 | -GetSocVersion(const T *context, platform_ascendc::SocVersion &socVersion) | 31 | +GetSocVersion(const T *context, NpuArch &npuArch) |
| 32 | { | 32 | { |
| 33 | OP_TILING_CHECK(context == nullptr, CUBE_INNER_ERR_REPORT("MatMulV3", "context is null"), return ge::GRAPH_FAILED); | 33 | OP_TILING_CHECK(context == nullptr, CUBE_INNER_ERR_REPORT("MatMulV3", "context is null"), return ge::GRAPH_FAILED); |
| 34 | fe::PlatFormInfos *platformInfo = context->GetPlatformInfo(); | 34 | fe::PlatFormInfos *platformInfo = context->GetPlatformInfo(); |
| @@ -38,7 +38,7 @@ GetSocVersion(const T *context, platform_ascendc::SocVersion &socVersion) | |||
| 38 | std::string mmad; | 38 | std::string mmad; |
| 39 | bool res = platformInfo->GetPlatformRes("AICoreintrinsicDtypeMap", "Intrinsic_mmad", mmad); | 39 | bool res = platformInfo->GetPlatformRes("AICoreintrinsicDtypeMap", "Intrinsic_mmad", mmad); |
| 40 | bool supportMmadS8S4 = res && mmad.find("s8s4") != std::string::npos; | 40 | bool supportMmadS8S4 = res && mmad.find("s8s4") != std::string::npos; |
| 41 | - socVersion = supportMmadS8S4 ? platform_ascendc::SocVersion::RESERVED_VERSION : ascendcPlatform.GetSocVersion(); | 41 | + npuArch = supportMmadS8S4 ? NpuArch::DAV_RESV : ascendcPlatform.GetCurNpuArch(); |
| 42 | return ge::GRAPH_SUCCESS; | 42 | return ge::GRAPH_SUCCESS; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -46,11 +46,11 @@ template <typename T> | |||
| 46 | inline typename std::enable_if< | 46 | inline typename std::enable_if< |
| 47 | std::is_same<T, gert::TilingParseContext>::value || std::is_same<T, gert::TilingContext>::value, bool>::type | 47 | std::is_same<T, gert::TilingParseContext>::value || std::is_same<T, gert::TilingContext>::value, bool>::type |
| 48 | IsAdvancedSocVersion(T *context) { | 48 | IsAdvancedSocVersion(T *context) { |
| 49 | - platform_ascendc::SocVersion socVersion; | 49 | + NpuArch npuArch; |
| 50 | OP_TILING_CHECK( | 50 | OP_TILING_CHECK( |
| 51 | - GetSocVersion(context, socVersion) == ge::GRAPH_FAILED, | 51 | + GetSocVersion(context, npuArch) == ge::GRAPH_FAILED, |
| 52 | - CUBE_INNER_ERR_REPORT("MatMulV3", "fail to get soc version"), return false); | 52 | + CUBE_INNER_ERR_REPORT("MatMulV3", "fail to get npu arch"), return false); |
| 53 | - return std::find(AdvancedSocVersion.begin(), AdvancedSocVersion.end(), socVersion) != AdvancedSocVersion.end(); | 53 | + return std::find(AdvancedNpuArch.begin(), AdvancedNpuArch.end(), npuArch) != AdvancedNpuArch.end(); |
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| 56 | 56 | ||
| @@ -72,6 +72,7 @@ static ge::graphStatus TilingPrepareForMatmulV3(gert::TilingParseContext *contex | |||
| 72 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); | 72 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); |
| 73 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); | 73 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); |
| 74 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); | 74 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); |
| 75 | + compileInfoPtr->npuArch = ascendcPlatform.GetCurNpuArch(); | ||
| 75 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize | 76 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize |
| 76 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize | 77 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize |
| 77 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 78 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -87,8 +88,8 @@ static ge::graphStatus TilingPrepareForMatmulV3(gert::TilingParseContext *contex | |||
| 87 | } | 88 | } |
| 88 | OP_LOGI( | 89 | OP_LOGI( |
| 89 | context->GetNodeName(), | 90 | context->GetNodeName(), |
| 90 | - "parse compile info success soc:%d, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", | 91 | + "parse compile info success soc:%d, npu arch: %u, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", |
| 91 | - static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->l1Size, compileInfoPtr->l2Size, | 92 | + static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->npuArch, compileInfoPtr->l1Size, compileInfoPtr->l2Size, |
| 92 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); | 93 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); |
| 93 | return ge::GRAPH_SUCCESS; | 94 | return ge::GRAPH_SUCCESS; |
| 94 | } | 95 | } |
| @@ -110,9 +110,9 @@ static aclnnStatus CheckInputParams(const aclTensor* self, const aclTensor* vec, | |||
| 110 | CHECK_RET(CheckDtypeSame(self, vec, out), ACLNN_ERR_PARAM_INVALID); | 110 | CHECK_RET(CheckDtypeSame(self, vec, out), ACLNN_ERR_PARAM_INVALID); |
| 111 | 111 | ||
| 112 | // self dtype 按soc校验。 | 112 | // self dtype 按soc校验。 |
| 113 | - auto socRule = SocMatMulRule::getInstance(); | 113 | + auto archRule = NpuArchMatMulRule::getInstance(); |
| 114 | - CHECK_RET(socRule != nullptr, ACLNN_ERR_PARAM_INVALID); | 114 | + CHECK_RET(archRule != nullptr, ACLNN_ERR_PARAM_INVALID); |
| 115 | - CHECK_RET(socRule->CheckInput(self, vec, nullptr, out, cubeMathType), ACLNN_ERR_PARAM_INVALID); | 115 | + CHECK_RET(archRule -> CheckInput(self, vec, nullptr, out, cubeMathType), ACLNN_ERR_PARAM_INVALID); |
| 116 | 116 | ||
| 117 | // 3. shape: self必须为2维: n x m, vec必须为1维:m, out必须为1维:n | 117 | // 3. shape: self必须为2维: n x m, vec必须为1维:m, out必须为1维:n |
| 118 | CHECK_RET(CheckShape(self, vec, out), ACLNN_ERR_PARAM_INVALID); | 118 | CHECK_RET(CheckShape(self, vec, out), ACLNN_ERR_PARAM_INVALID); |
Mmatmul/quant_batch_matmul_inplace_add/op_host/op_tiling/quant_batch_matmul_inplace_add_tiling.cpp+1-1
| @@ -293,7 +293,7 @@ static ge::graphStatus QuantBatchMatmulInplaceAddTilingFunc(gert::TilingContext* | |||
| 293 | OP_LOGD("QuantBatchMatmulInplaceAddTilingFunc", "Using the tiling strategy in the mx quant."); | 293 | OP_LOGD("QuantBatchMatmulInplaceAddTilingFunc", "Using the tiling strategy in the mx quant."); |
| 294 | return TilingRegistry::GetInstance().DoTilingImpl(context, registerList); | 294 | return TilingRegistry::GetInstance().DoTilingImpl(context, registerList); |
| 295 | } else { | 295 | } else { |
| 296 | - OP_LOGD("QuantBatchMatmulInplaceAddTilingFunc", "Do op tiling failed, now only support 91095."); | 296 | + OP_LOGD("QuantBatchMatmulInplaceAddTilingFunc", "Do op tiling failed, now only support 950."); |
| 297 | return ge::GRAPH_FAILED; | 297 | return ge::GRAPH_FAILED; |
| 298 | } | 298 | } |
| 299 | } | 299 | } |
| @@ -218,7 +218,7 @@ static void TestOneParamCase(const QuantBatchMatmulV4TilingTestParam& param) | |||
| 218 | "L0B_SIZE" : 65536, | 218 | "L0B_SIZE" : 65536, |
| 219 | "L0C_SIZE" : 262144, | 219 | "L0C_SIZE" : 262144, |
| 220 | "CORE_NUM" : 32, | 220 | "CORE_NUM" : 32, |
| 221 | - "socVersion" : "Ascend910_95", | 221 | + "socVersion" : "Ascend950", |
| 222 | "NpuArch" : "3510" | 222 | "NpuArch" : "3510" |
| 223 | }})"; | 223 | }})"; |
| 224 | map<string, string> socInfos; | 224 | map<string, string> socInfos; |
| @@ -328,7 +328,7 @@ static QuantBatchMatmulV4TilingTestParam casesParams[] = { | |||
| 328 | * aicNum | 328 | * aicNum |
| 329 | * aivNum | 329 | * aivNum |
| 330 | */ | 330 | */ |
| 331 | - {"UT-A8W4-PerGroup-ND-Testcase-0_Ascend910D_128_128_128_0_1_4303356032_ND_ND_INT8_INT8_NULL_FP32_FP32_NULL_" | 331 | + {"UT-A8W4-PerGroup-ND-Testcase-0_Ascend950_128_128_128_0_1_4303356032_ND_ND_INT8_INT8_NULL_FP32_FP32_NULL_" |
| 332 | "BF16_32_64", | 332 | "BF16_32_64", |
| 333 | 32, ge::GRAPH_SUCCESS, 533UL}, | 333 | 32, ge::GRAPH_SUCCESS, 533UL}, |
| 334 | 334 | ||
| @@ -252,13 +252,14 @@ static void TestOneParamCase(const QuantBatchMatmulV4TilingTestParam ¶m) | |||
| 252 | map<string, string> socInfos; | 252 | map<string, string> socInfos; |
| 253 | map<string, string> aicoreSpec; | 253 | map<string, string> aicoreSpec; |
| 254 | map<string, string> intrinsics; | 254 | map<string, string> intrinsics; |
| 255 | + map<string, string> version; | ||
| 255 | // 6为替换原aicNum字符串的长度,配置CORE_NUM | 256 | // 6为替换原aicNum字符串的长度,配置CORE_NUM |
| 256 | compileInfoStr = compileInfoStr.replace(compileInfoStr.find("aicNum"), 6, to_string(aicNum)); | 257 | compileInfoStr = compileInfoStr.replace(compileInfoStr.find("aicNum"), 6, to_string(aicNum)); |
| 257 | // 6为替换原aicNum字符串的长度,配置cube_core_cnt | 258 | // 6为替换原aicNum字符串的长度,配置cube_core_cnt |
| 258 | compileInfoStr = compileInfoStr.replace(compileInfoStr.find("aicNum"), 6, to_string(aicNum)); | 259 | compileInfoStr = compileInfoStr.replace(compileInfoStr.find("aicNum"), 6, to_string(aicNum)); |
| 259 | // 6为替换原aivNum字符串的长度,配置vector_core_cnt | 260 | // 6为替换原aivNum字符串的长度,配置vector_core_cnt |
| 260 | compileInfoStr = compileInfoStr.replace(compileInfoStr.find("aivNum"), 6, to_string(aivNum)); | 261 | compileInfoStr = compileInfoStr.replace(compileInfoStr.find("aivNum"), 6, to_string(aivNum)); |
| 261 | - GetPlatFormInfos(compileInfoStr.c_str(), socInfos, aicoreSpec, intrinsics); | 262 | + GetPlatFormInfos(compileInfoStr.c_str(), socInfos, aicoreSpec, intrinsics, version); |
| 262 | aicoreSpec["cube_freq"] = "1800"; | 263 | aicoreSpec["cube_freq"] = "1800"; |
| 263 | 264 | ||
| 264 | // platform info | 265 | // platform info |
| @@ -316,9 +317,7 @@ static void TestOneParamCase(const QuantBatchMatmulV4TilingTestParam ¶m) | |||
| 316 | tilingContext->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); | 317 | tilingContext->GetPlatformInfo()->SetPlatformRes("AICoreSpec", aicoreSpec); |
| 317 | tilingContext->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); | 318 | tilingContext->GetPlatformInfo()->SetCoreNumByCoreType("AICore"); |
| 318 | tilingContext->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); | 319 | tilingContext->GetPlatformInfo()->SetPlatformRes("AICoreintrinsicDtypeMap", intrinsics); |
| 319 | - map<string, string> soc_version_infos; | 320 | + tilingContext->GetPlatformInfo()->SetPlatformRes("version", version); |
| 320 | - soc_version_infos.insert(make_pair("Short_SoC_version", socVersion)); | ||
| 321 | - tilingContext->GetPlatformInfo()->SetPlatformRes("version", soc_version_infos); | ||
| 322 | auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; | 321 | auto tilingParseFunc = gert::OpImplRegistry::GetInstance().GetOpImpl(opType.c_str())->tiling_parse; |
| 323 | ASSERT_NE(tilingParseFunc, nullptr); | 322 | ASSERT_NE(tilingParseFunc, nullptr); |
| 324 | ASSERT_EQ(tilingParseFunc(kernelHold.GetContext<gert::KernelContext>()), ge::GRAPH_SUCCESS); | 323 | ASSERT_EQ(tilingParseFunc(kernelHold.GetContext<gert::KernelContext>()), ge::GRAPH_SUCCESS); |
| @@ -343,64 +342,64 @@ TEST_P(TestQuantBatchMatmulV4Tiling, generalTest) | |||
| 343 | // x2ScaleDtype yScaleDtype x2TableDtype yDtype aicNum aivNum platform weightFormat | 342 | // x2ScaleDtype yScaleDtype x2TableDtype yDtype aicNum aivNum platform weightFormat |
| 344 | static QuantBatchMatmulV4TilingTestParam casesParams[] = { | 343 | static QuantBatchMatmulV4TilingTestParam casesParams[] = { |
| 345 | // MX ND | 344 | // MX ND |
| 346 | - {"mx-1_Ascend910D_128_512_128_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, | 345 | + {"mx-1_Ascend950_128_512_128_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, |
| 347 | - {"mx-menkan40_Ascend910D_944_7680_256_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 17UL}, | 346 | + {"mx-menkan40_Ascend950_944_7680_256_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 17UL}, |
| 348 | - {"mx-menkan18_Ascend910D_736_1536_2800_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, | 347 | + {"mx-menkan18_Ascend950_736_1536_2800_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, |
| 349 | - {"mx-menkan17_Ascend910D_320_1536_224_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 28, ge::GRAPH_SUCCESS, 17UL}, | 348 | + {"mx-menkan17_Ascend950_320_1536_224_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 28, ge::GRAPH_SUCCESS, 17UL}, |
| 350 | - {"mx-menkan12_Ascend910D_48_7680_80_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 9, ge::GRAPH_SUCCESS, 17UL}, | 349 | + {"mx-menkan12_Ascend950_48_7680_80_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 9, ge::GRAPH_SUCCESS, 17UL}, |
| 351 | - {"mx-random0001_Ascend910D_608_1024_704_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 17UL}, | 350 | + {"mx-random0001_Ascend950_608_1024_704_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 17UL}, |
| 352 | - {"mx-random0003_Ascend910D_3840_512_3200_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, | 351 | + {"mx-random0003_Ascend950_3840_512_3200_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, |
| 353 | - {"mx-random0013_Ascend910D_2256_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, | 352 | + {"mx-random0013_Ascend950_2256_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, |
| 354 | - {"mx-random0022_Ascend910D_32_3072_64_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 4, ge::GRAPH_SUCCESS, 17UL}, | 353 | + {"mx-random0022_Ascend950_32_3072_64_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 4, ge::GRAPH_SUCCESS, 17UL}, |
| 355 | - {"mx-random0025_Ascend910D_2720_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, | 354 | + {"mx-random0025_Ascend950_2720_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 17UL}, |
| 356 | - {"mx-error-x1ScaleDtype_Ascend910D_2720_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_BF16_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 17UL}, | 355 | + {"mx-error-x1ScaleDtype_Ascend950_2720_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_BF16_FP8-E8M0_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 17UL}, |
| 357 | - {"mx-error-x2ScaleDtype_Ascend910D_2720_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 17UL}, | 356 | + {"mx-error-x2ScaleDtype_Ascend950_2720_512_192_0_1_32_ND_ND_FP8-E4M3_FP4-E2M1_BF16_FP8-E8M0_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 17UL}, |
| 358 | 357 | ||
| 359 | // PERGROUP NZ | 358 | // PERGROUP NZ |
| 360 | - {"UT-A8W4-PerGroup-NZ-Testcase-0_Ascend910D_848_640_896_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, | 359 | + {"UT-A8W4-PerGroup-NZ-Testcase-0_Ascend950_848_640_896_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, |
| 361 | - {"UT-A8W4-PerGroup-NZ-Testcase-1_Ascend910D_96_8960_8384_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, | 360 | + {"UT-A8W4-PerGroup-NZ-Testcase-1_Ascend950_96_8960_8384_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, |
| 362 | - {"UT-A8W4-PerGroup-NZ-Testcase-2_Ascend910D_176_64_128_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 22, ge::GRAPH_SUCCESS, 268UL}, | 361 | + {"UT-A8W4-PerGroup-NZ-Testcase-2_Ascend950_176_64_128_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 22, ge::GRAPH_SUCCESS, 268UL}, |
| 363 | - {"UT-A8W4-PerGroup-NZ-Testcase-3_Ascend910D_432_192_832_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 268UL}, | 362 | + {"UT-A8W4-PerGroup-NZ-Testcase-3_Ascend950_432_192_832_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 268UL}, |
| 364 | - {"UT-A8W4-PerGroup-NZ-Testcase-4_Ascend910D_592_1856_192_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 268UL}, | 363 | + {"UT-A8W4-PerGroup-NZ-Testcase-4_Ascend950_592_1856_192_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 30, ge::GRAPH_SUCCESS, 268UL}, |
| 365 | - {"UT-A8W4-PerGroup-NZ-Testcase-5_Ascend910D_605_2304_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 19, ge::GRAPH_SUCCESS, 268UL}, | 364 | + {"UT-A8W4-PerGroup-NZ-Testcase-5_Ascend950_605_2304_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 19, ge::GRAPH_SUCCESS, 268UL}, |
| 366 | - {"UT-A8W4-PerGroup-NZ-Testcase-6_Ascend910D_8_7168_576_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 9, ge::GRAPH_SUCCESS, 268UL}, | 365 | + {"UT-A8W4-PerGroup-NZ-Testcase-6_Ascend950_8_7168_576_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 9, ge::GRAPH_SUCCESS, 268UL}, |
| 367 | - {"UT-A8W4-PerGroup-NZ-Testcase-7_Ascend910D_714_128_3392_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, | 366 | + {"UT-A8W4-PerGroup-NZ-Testcase-7_Ascend950_714_128_3392_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, |
| 368 | - {"UT-A8W4-PerGroup-NZ-Testcase-8_Ascend910D_5968_128_576_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, | 367 | + {"UT-A8W4-PerGroup-NZ-Testcase-8_Ascend950_5968_128_576_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, |
| 369 | - {"UT-A8W4-PerGroup-NZ-Testcase-9_Ascend910D_27_64_320_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 10, ge::GRAPH_SUCCESS, 268UL}, | 368 | + {"UT-A8W4-PerGroup-NZ-Testcase-9_Ascend950_27_64_320_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 10, ge::GRAPH_SUCCESS, 268UL}, |
| 370 | - {"UT-A8W4-PerGroup-NZ-Testcase-10_Ascend910D_192_3648_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 12, ge::GRAPH_SUCCESS, 268UL}, | 369 | + {"UT-A8W4-PerGroup-NZ-Testcase-10_Ascend950_192_3648_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 12, ge::GRAPH_SUCCESS, 268UL}, |
| 371 | 370 | ||
| 372 | // k>65535 | 371 | // k>65535 |
| 373 | - {"UT-A8W4-PerGroup-NZ-Testcase-11_Ascend910D_16_65536_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 1, ge::GRAPH_SUCCESS, 268UL}, | 372 | + {"UT-A8W4-PerGroup-NZ-Testcase-11_Ascend950_16_65536_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 1, ge::GRAPH_SUCCESS, 268UL}, |
| 374 | // n>65535 | 373 | // n>65535 |
| 375 | - {"UT-A8W4-PerGroup-NZ-Testcase-12_Ascend910D_16_64_65536_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, | 374 | + {"UT-A8W4-PerGroup-NZ-Testcase-12_Ascend950_16_64_65536_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_NULL_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_SUCCESS, 268UL}, |
| 376 | 375 | ||
| 377 | // PERGROUP NZ ERROR | 376 | // PERGROUP NZ ERROR |
| 378 | // BIAS: dtype != bf16 dtype != fp16 | 377 | // BIAS: dtype != bf16 dtype != fp16 |
| 379 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-0_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_FP32_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 378 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-0_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_FP32_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 380 | // X2Scale dtype != bf16 | 379 | // X2Scale dtype != bf16 |
| 381 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-1_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_FP32_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 380 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-1_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_FP32_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 382 | // X1Scale 不为空 | 381 | // X1Scale 不为空 |
| 383 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-3_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_BF16_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 382 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-3_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_BF16_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 384 | // GroupSize不为32 | 383 | // GroupSize不为32 |
| 385 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-5_Ascend910D_16_64_64_0_0_96_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 384 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-5_Ascend950_16_64_64_0_0_96_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 386 | // GroupNum不为整数倍 | 385 | // GroupNum不为整数倍 |
| 387 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-6_Ascend910D_16_64_64_0_0_65_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 386 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-6_Ascend950_16_64_64_0_0_65_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 388 | // yScale非UINT64 | 387 | // yScale非UINT64 |
| 389 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-7_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_FP32_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 388 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-7_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_FP32_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 390 | // yScale为空 | 389 | // yScale为空 |
| 391 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-8_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_NULL_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 390 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-8_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_NULL_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 392 | // K不为64对齐 | 391 | // K不为64对齐 |
| 393 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-9_Ascend910D_16_65_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 392 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-9_Ascend950_16_65_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 394 | // x2: dtype!=fp4_e2m1 | 393 | // x2: dtype!=fp4_e2m1 |
| 395 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-13_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP8-E4M3_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 394 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-13_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP8-E4M3_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 396 | // y: dtype!=bf16 | 395 | // y: dtype!=bf16 |
| 397 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-14_Ascend910D_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_FP16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 396 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-14_Ascend950_16_64_64_0_0_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_FP16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 398 | // x2 NZ不支持转置 | 397 | // x2 NZ不支持转置 |
| 399 | - {"UT-A8W4-PerGroup-NZ-Testcase-error-15_Ascend910D_16_64_64_0_1_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, | 398 | + {"UT-A8W4-PerGroup-NZ-Testcase-error-15_Ascend950_16_64_64_0_1_32_ND_NZ_FP8-E4M3_FP4-E2M1_BF16_NULL_BF16_UINT64_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 268UL}, |
| 400 | 399 | ||
| 401 | // MX NZ ERROR | 400 | // MX NZ ERROR |
| 402 | // X2: dtype != FP4-E2M1 | 401 | // X2: dtype != FP4-E2M1 |
| 403 | - {"UT-A8W4-MX-NZ-Testcase-error-3_Ascend910D_16_64_64_0_1_32_ND_NZ_FP8-E4M3_FP8-E4M3_BF16_FP8-E8M0_FP8-E8M0_NULL_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 273UL}, | 402 | + {"UT-A8W4-MX-NZ-Testcase-error-3_Ascend950_16_64_64_0_1_32_ND_NZ_FP8-E4M3_FP8-E4M3_BF16_FP8-E8M0_FP8-E8M0_NULL_NULL_BF16_32_64", 32, ge::GRAPH_FAILED, 273UL}, |
| 404 | 403 | ||
| 405 | // RESERVED | 404 | // RESERVED |
| 406 | {"A8W2-LUT-Testcase-0_RESERVED_3072_2048_4096_0_0_16777344_ND_NZ_INT8_INT2_NULL_NULL_UINT64_NULL_INT4_INT8_14_14", 14, ge::GRAPH_SUCCESS, 768UL}, | 405 | {"A8W2-LUT-Testcase-0_RESERVED_3072_2048_4096_0_0_16777344_ND_NZ_INT8_INT2_NULL_NULL_UINT64_NULL_INT4_INT8_14_14", 14, ge::GRAPH_SUCCESS, 768UL}, |
| @@ -96,15 +96,15 @@ static bool CheckDavidLimit(const aclTensor* scale, const aclIntArray* perm_x1, | |||
| 96 | auto x2_need_transpose = ((*perm_x2)[0] == 0 && (*perm_x2)[1] == 1 && (*perm_x2)[2] == 2) || | 96 | auto x2_need_transpose = ((*perm_x2)[0] == 0 && (*perm_x2)[1] == 1 && (*perm_x2)[2] == 2) || |
| 97 | ((*perm_x2)[0] == 0 && (*perm_x2)[1] == 2 && (*perm_x2)[2] == 1); | 97 | ((*perm_x2)[0] == 0 && (*perm_x2)[1] == 2 && (*perm_x2)[2] == 1); |
| 98 | if (!x1_need_transpose) { | 98 | if (!x1_need_transpose) { |
| 99 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "the perm of x1 for ASCEND950 should be [0,1,2] or [1,0,2]."); | 99 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "the perm of x1 for npu arch 3510 should be [0,1,2] or [1,0,2]."); |
| 100 | return false; | 100 | return false; |
| 101 | } | 101 | } |
| 102 | if (!x2_need_transpose) { | 102 | if (!x2_need_transpose) { |
| 103 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "the perm of x2 for ASCEND950 should be [0,1,2] or [0,2,1]."); | 103 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "the perm of x2 for npu arch 3510 should be [0,1,2] or [0,2,1]."); |
| 104 | return false; | 104 | return false; |
| 105 | } | 105 | } |
| 106 | if (scale != nullptr) { | 106 | if (scale != nullptr) { |
| 107 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "ASCEND950 not support scale."); | 107 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "npu arch 3510 not support scale."); |
| 108 | return false; | 108 | return false; |
| 109 | } | 109 | } |
| 110 | return true; | 110 | return true; |
| @@ -136,9 +136,9 @@ static bool CheckShapeValid(const aclTensor* x1, const aclTensor* x2, const aclT | |||
| 136 | 136 | ||
| 137 | auto x1_need_transpose = ((*perm_x1)[0] == 1 && (*perm_x1)[1] == 0 && (*perm_x1)[2] == 2); | 137 | auto x1_need_transpose = ((*perm_x1)[0] == 1 && (*perm_x1)[1] == 0 && (*perm_x1)[2] == 2); |
| 138 | auto x2_need_transpose = ((*perm_x2)[0] == 0 && (*perm_x2)[1] == 1 && (*perm_x2)[2] == 2); | 138 | auto x2_need_transpose = ((*perm_x2)[0] == 0 && (*perm_x2)[1] == 1 && (*perm_x2)[2] == 2); |
| 139 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND950) { | 139 | + if (GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510) { |
| 140 | if (!CheckDavidLimit(scale, perm_x1, perm_x2)) { | 140 | if (!CheckDavidLimit(scale, perm_x1, perm_x2)) { |
| 141 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "ASCEND950 Limit."); | 141 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "npu arch 3510 Limit."); |
| 142 | return false; | 142 | return false; |
| 143 | } | 143 | } |
| 144 | } else { | 144 | } else { |
| @@ -186,8 +186,8 @@ inline static aclnnStatus CheckParams(const aclTensor* x1, const aclTensor* x2, | |||
| 186 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The perm parameter must be three-dimensional!"); | 186 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "The perm parameter must be three-dimensional!"); |
| 187 | return ACLNN_ERR_PARAM_INVALID; | 187 | return ACLNN_ERR_PARAM_INVALID; |
| 188 | } | 188 | } |
| 189 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND950 && cubeMathType == -1) { | 189 | + if (GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_3510 && cubeMathType == -1) { |
| 190 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "cubeMathType[%d] can not be -1 for ASCEND950.", | 190 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "cubeMathType[%d] can not be -1 for npu arch 3510", |
| 191 | cubeMathType); | 191 | cubeMathType); |
| 192 | return ACLNN_ERR_PARAM_INVALID; | 192 | return ACLNN_ERR_PARAM_INVALID; |
| 193 | } | 193 | } |
| @@ -21,7 +21,7 @@ | |||
| 21 | namespace optiling { | 21 | namespace optiling { |
| 22 | namespace transpose_batch_mat_mul_advanced { | 22 | namespace transpose_batch_mat_mul_advanced { |
| 23 | using namespace strategy; | 23 | using namespace strategy; |
| 24 | -MM_REGISTER_TILING_TEMPLATE(TransposeBatchMatMul, TransposeBatchMatMulAswTiling, ASCEND950, BASE); | 24 | +MM_REGISTER_TILING_TEMPLATE(TransposeBatchMatMul, TransposeBatchMatMulAswTiling, DAV_3510, BASE); |
| 25 | 25 | ||
| 26 | template <typename T> | 26 | template <typename T> |
| 27 | T GetAlignNumWithDataType(T size, ge::DataType dtype) { | 27 | T GetAlignNumWithDataType(T size, ge::DataType dtype) { |
Mmatmul/transpose_batch_mat_mul/op_host/op_tiling/arch35/transpose_batch_mat_mul_tiling_advanced.cpp+4-4
| @@ -240,10 +240,10 @@ ge::graphStatus TransposeBatchMatMulTiling::DoTiling() | |||
| 240 | args_.batchInfo = &tempBatchInfo; | 240 | args_.batchInfo = &tempBatchInfo; |
| 241 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void*>(&args_)); | 241 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void*>(&args_)); |
| 242 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); | 242 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); |
| 243 | - platform_ascendc::SocVersion socVersion = | 243 | + NpuArch npuArch = |
| 244 | - static_cast<const MatmulV3CompileInfo*>(tilingCfg.compileInfo)->socVersion; | 244 | + static_cast<const MatmulV3CompileInfo*>(tilingCfg.compileInfo)->npuArch; |
| 245 | - MMRegisterCfg registerCfg{"TransposeBatchMatMul", socVersion, | 245 | + MMRegisterCfg registerCfg{"TransposeBatchMatMul", npuArch, |
| 246 | - strategy::GetTransposeBatchMatMulPriorities(socVersion)}; | 246 | + strategy::GetTransposeBatchMatMulPriorities(npuArch)}; |
| 247 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); | 247 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); |
| 248 | } | 248 | } |
| 249 | 249 | ||
Mmatmul/transpose_batch_mat_mul/op_host/op_tiling/arch35/transpose_batch_mat_mul_tiling_strategy.h+5-6
| @@ -26,16 +26,15 @@ namespace transpose_batch_mat_mul_advanced { | |||
| 26 | namespace strategy { | 26 | namespace strategy { |
| 27 | constexpr int32_t BASE = 999; | 27 | constexpr int32_t BASE = 999; |
| 28 | 28 | ||
| 29 | -const static std::map<platform_ascendc::SocVersion, std::vector<int32_t>> TransposeBatchMatMulPrioritiesMap = { | 29 | +const static std::map<NpuArch, std::vector<int32_t>> TransposeBatchMatMulPrioritiesMap = { |
| 30 | - { platform_ascendc::SocVersion::ASCEND950, | 30 | + { NpuArch::DAV_3510, { strategy::BASE} }, |
| 31 | - { strategy::BASE} }, | ||
| 32 | }; | 31 | }; |
| 33 | 32 | ||
| 34 | -inline std::vector<int32_t> GetTransposeBatchMatMulPriorities(platform_ascendc::SocVersion socVersion) | 33 | +inline std::vector<int32_t> GetTransposeBatchMatMulPriorities(NpuArch NpuArch) |
| 35 | { | 34 | { |
| 36 | std::vector<int32_t> priorities = {}; | 35 | std::vector<int32_t> priorities = {}; |
| 37 | - if (TransposeBatchMatMulPrioritiesMap.find(socVersion) != TransposeBatchMatMulPrioritiesMap.end()) { | 36 | + if (TransposeBatchMatMulPrioritiesMap.find(NpuArch) != TransposeBatchMatMulPrioritiesMap.end()) { |
| 38 | - priorities = TransposeBatchMatMulPrioritiesMap.at(socVersion); | 37 | + priorities = TransposeBatchMatMulPrioritiesMap.at(NpuArch); |
| 39 | } | 38 | } |
| 40 | return priorities; | 39 | return priorities; |
| 41 | }; | 40 | }; |
| @@ -137,6 +137,7 @@ static ge::graphStatus TilingPrepareForTransposeBatchMatMul(gert::TilingParseCon | |||
| 137 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); | 137 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); |
| 138 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); | 138 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); |
| 139 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); | 139 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); |
| 140 | + compileInfoPtr->npuArch = ascendcPlatform.GetCurNpuArch(); | ||
| 140 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize | 141 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize |
| 141 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize | 142 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize |
| 142 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 143 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -151,8 +152,8 @@ static ge::graphStatus TilingPrepareForTransposeBatchMatMul(gert::TilingParseCon | |||
| 151 | } | 152 | } |
| 152 | OP_LOGI( | 153 | OP_LOGI( |
| 153 | context->GetNodeName(), | 154 | context->GetNodeName(), |
| 154 | - "compile info success soc:%d, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", | 155 | + "compile info success soc:%d, npu arch:%u, l1Size:%lu, l2Size:%lu, coreNum:%lu, supportL0c2out:%d, supportL12BtBf16:%d", |
| 155 | - static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->l1Size, compileInfoPtr->l2Size, | 156 | + static_cast<int>(compileInfoPtr->socVersion), compileInfoPtr->npuArch, compileInfoPtr->l1Size, compileInfoPtr->l2Size, |
| 156 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); | 157 | compileInfoPtr->aicNum, compileInfoPtr->supportL0c2out, compileInfoPtr->supportL12BtBf16); |
| 157 | return ge::GRAPH_SUCCESS; | 158 | return ge::GRAPH_SUCCESS; |
| 158 | } | 159 | } |
| @@ -23,7 +23,7 @@ using Ops::NN::MathUtil; | |||
| 23 | namespace optiling { | 23 | namespace optiling { |
| 24 | namespace transpose_quant_batch_mat_mul_advanced { | 24 | namespace transpose_quant_batch_mat_mul_advanced { |
| 25 | using namespace strategy; | 25 | using namespace strategy; |
| 26 | -MM_REGISTER_TILING_TEMPLATE(TransposeQuantBatchMatMul, TransposeQuantBatchMatMulAswTiling, ASCEND950, BASE); | 26 | +MM_REGISTER_TILING_TEMPLATE(TransposeQuantBatchMatMul, TransposeQuantBatchMatMulAswTiling, DAV_3510, BASE); |
| 27 | 27 | ||
| 28 | ge::graphStatus TransposeQuantBatchMatMulAswTiling::DoOpTiling() | 28 | ge::graphStatus TransposeQuantBatchMatMulAswTiling::DoOpTiling() |
| 29 | { | 29 | { |
| @@ -236,10 +236,10 @@ ge::graphStatus TransposeQuantBatchMatMulTiling::DoTiling() | |||
| 236 | args_.batchInfo = &tempBatchInfo; | 236 | args_.batchInfo = &tempBatchInfo; |
| 237 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void*>(&args_)); | 237 | MatMulTilingCfg tilingCfg(false, context_->GetCompileInfo(), static_cast<void*>(&args_)); |
| 238 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); | 238 | OPS_CHECK_NULL_WITH_CONTEXT(context_, tilingCfg.compileInfo); |
| 239 | - platform_ascendc::SocVersion socVersion = | 239 | + NpuArch npuArch = |
| 240 | - static_cast<const MatmulV3CompileInfo*>(tilingCfg.compileInfo)->socVersion; | 240 | + static_cast<const MatmulV3CompileInfo*>(tilingCfg.compileInfo)->npuArch; |
| 241 | - MMRegisterCfg registerCfg{"TransposeQuantBatchMatMul", socVersion, | 241 | + MMRegisterCfg registerCfg{"TransposeQuantBatchMatMul", npuArch, |
| 242 | - strategy::GetTransposeQuantBatchMatMulPriorities(socVersion)}; | 242 | + strategy::GetTransposeQuantBatchMatMulPriorities(npuArch)}; |
| 243 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); | 243 | return MMTilingRegistry::GetInstance().DoTilingImpl(context_, tilingCfg, registerCfg); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| @@ -26,15 +26,15 @@ namespace transpose_quant_batch_mat_mul_advanced { | |||
| 26 | namespace strategy { | 26 | namespace strategy { |
| 27 | constexpr int32_t BASE = 999; | 27 | constexpr int32_t BASE = 999; |
| 28 | 28 | ||
| 29 | -const static std::map<platform_ascendc::SocVersion, std::vector<int32_t>> TransposeQuantBatchMatMulPrioritiesMap = { | 29 | +const static std::map<NpuArch, std::vector<int32_t>> TransposeQuantBatchMatMulPrioritiesMap = { |
| 30 | - {platform_ascendc::SocVersion::ASCEND950, {strategy::BASE}}, | 30 | + {NpuArch::DAV_3510, {strategy::BASE}}, |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | -inline std::vector<int32_t> GetTransposeQuantBatchMatMulPriorities(platform_ascendc::SocVersion socVersion) | 33 | +inline std::vector<int32_t> GetTransposeQuantBatchMatMulPriorities(NpuArch npuArch) |
| 34 | { | 34 | { |
| 35 | std::vector<int32_t> priorities = {}; | 35 | std::vector<int32_t> priorities = {}; |
| 36 | - if (TransposeQuantBatchMatMulPrioritiesMap.find(socVersion) != TransposeQuantBatchMatMulPrioritiesMap.end()) { | 36 | + if (TransposeQuantBatchMatMulPrioritiesMap.find(npuArch) != TransposeQuantBatchMatMulPrioritiesMap.end()) { |
| 37 | - priorities = TransposeQuantBatchMatMulPrioritiesMap.at(socVersion); | 37 | + priorities = TransposeQuantBatchMatMulPrioritiesMap.at(npuArch); |
| 38 | } | 38 | } |
| 39 | return priorities; | 39 | return priorities; |
| 40 | }; | 40 | }; |
Mmatmul/transpose_quant_batch_mat_mul/op_host/op_tiling/transpose_quant_batch_mat_mul_tiling.cpp+1-0
| @@ -52,6 +52,7 @@ static ge::graphStatus TilingPrepareForTransposeQuantBatchMatMul(gert::TilingPar | |||
| 52 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); | 52 | compileInfoPtr->supportL12BtBf16 = (dataMoveL12Bt.find("bf16") != std::string::npos); |
| 53 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); | 53 | compileInfoPtr->aicNum = ascendcPlatform.GetCoreNumAic(); |
| 54 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); | 54 | compileInfoPtr->socVersion = ascendcPlatform.GetSocVersion(); |
| 55 | + compileInfoPtr->npuArch = ascendcPlatform.GetCurNpuArch(); | ||
| 55 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize | 56 | compileInfoPtr->btSize = compileInfoPtr->supportL0c2out ? 1024UL : 0UL; // 1024 is btSize |
| 56 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize | 57 | compileInfoPtr->btSize = compileInfoPtr->supportL12BtBf16 ? 4096UL : compileInfoPtr->btSize; // 4096 is btSize |
| 57 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); | 58 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, compileInfoPtr->ubSize); |
| @@ -14,8 +14,18 @@ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | + | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 20 | +const std::map<std::string, std::string> g_socToNpuArchMap = { | ||
| 21 | + {"Ascend910", "1001"}, | ||
| 22 | + {"Ascend910B", "2201"}, | ||
| 23 | + {"ASCEND910_93", "2201"}, | ||
| 24 | + {"Ascend950", "3510"}, | ||
| 25 | + {"Ascend310", "2002"}, | ||
| 26 | + {"Ascend310P", "2002"} | ||
| 27 | +}; | ||
| 28 | + | ||
| 19 | void GetPlatFormInfos(const char *compile_info_str, map<string, string> &soc_infos, map<string, string> &aicore_spec, | 29 | void GetPlatFormInfos(const char *compile_info_str, map<string, string> &soc_infos, map<string, string> &aicore_spec, |
| 20 | map<string, string> &intrinsics) { | 30 | map<string, string> &intrinsics) { |
| 21 | string default_hardward_info = R"({"hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", "Intrinsic_fix_pipe_l0c2out": false, "Intrinsic_data_move_l12ub": true, "Intrinsic_data_move_l0c2ub": true, "Intrinsic_data_move_out2l1_nd2nz": false, "UB_SIZE": 262144, "L2_SIZE": 33554432, "L1_SIZE": 1048576, "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 262144, "CORE_NUM": 32}})"; | 31 | string default_hardward_info = R"({"hardware_info": {"BT_SIZE": 0, "load3d_constraints": "1", "Intrinsic_fix_pipe_l0c2out": false, "Intrinsic_data_move_l12ub": true, "Intrinsic_data_move_l0c2ub": true, "Intrinsic_data_move_out2l1_nd2nz": false, "UB_SIZE": 262144, "L2_SIZE": 33554432, "L1_SIZE": 1048576, "L0A_SIZE": 65536, "L0B_SIZE": 65536, "L0C_SIZE": 262144, "CORE_NUM": 32}})"; |
| @@ -82,7 +92,7 @@ void GetPlatFormInfos(const char *compile_info_str, map<string, string> &soc_inf | |||
| 82 | return; | 92 | return; |
| 83 | } | 93 | } |
| 84 | 94 | ||
| 85 | - map<string, string> version_keys = {{"Short_SoC_version", "socVersion"}, {"NpuArch", "NpuArch"}}; | 95 | + map<string, string> version_keys = {{"Short_SoC_version", "socVersion"}}; |
| 86 | 96 | ||
| 87 | for (auto &t : version_keys) { | 97 | for (auto &t : version_keys) { |
| 88 | if (compile_info_json.contains("hardware_info") && compile_info_json["hardware_info"].contains(t.second)) { | 98 | if (compile_info_json.contains("hardware_info") && compile_info_json["hardware_info"].contains(t.second)) { |
| @@ -94,6 +104,17 @@ void GetPlatFormInfos(const char *compile_info_str, map<string, string> &soc_inf | |||
| 94 | } | 104 | } |
| 95 | } | 105 | } |
| 96 | } | 106 | } |
| 107 | + | ||
| 108 | + std::string socVersion = version["Short_SoC_version"]; | ||
| 109 | + std::string npuArch = "2001"; | ||
| 110 | + const auto it = g_socToNpuArchMap.find(socVersion); | ||
| 111 | + if (it != g_socToNpuArchMap.end()) { | ||
| 112 | + npuArch = it->second; | ||
| 113 | + } else { | ||
| 114 | + std::cout << "cannot find the corresponding npu arch for socVerion: " << socVersion << std::endl; | ||
| 115 | + std::cout << "the npu arch default value is: " << npuArch << std::endl; | ||
| 116 | + } | ||
| 117 | + version["NpuArch"] = npuArch; | ||
| 97 | } | 118 | } |
| 98 | 119 | ||
| 99 | std::string GetExeDirPath() { | 120 | std::string GetExeDirPath() { |


逻辑运算与副作用: 在CheckSocVersionIsSupportBf16函数中,使用NpuArch枚举值进行SOC版本判断存在逻辑问题。代码只检查了DAV_2201和DAV_3510两种架构,但根据上下文,BF16支持可能还涉及其他SOC版本。这种硬编码的枚举值检查方式不够灵活,当新增支持BF16的SOC版本时,需要修改代码。
问题类型: 逻辑运算与副作用 文件路径:
matmul/batch_mat_mul_v3/op_host/op_api/aclnn_addbmm.cpp行号: 74 问题代码:auto npuArch = op::GetCurrentPlatformInfo().GetCurNpuArch(); return (npuArch == NpuArch::DAV_2201) || (npuArch == NpuArch::DAV_3510);修改建议:
此评论由代码审查工具自动生成