已合并
将mc2下的算子中gen_task包含3-8包编译部分的内容删除 #2793
吴剑飞创建于 3月17日
将mc2下的算子中gen_task包含3-8包编译部分的内容删除 #2793
已合并
吴剑飞创建于 3月17日
已删除 :gen_task合入到cann/ops-transformermaster
28 个文件变更+1-1196
@@ -17,19 +17,13 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "graph/arg_desc_info.h"21#include "graph/arg_desc_info.h"
23#include "graph/kernel_launch_info.h"22#include "graph/kernel_launch_info.h"
24#include "register/op_impl_registry.h"23#include "register/op_impl_registry.h"
25#include "mc2_log.h"24#include "mc2_log.h"
26-#else
27-#include "op_graph/mc2_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 25 
31namespace ops {26namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33static ge::Status AllGatherMatmulCalcOpParam(gert::ExeResGenerationContext *context) {27static ge::Status AllGatherMatmulCalcOpParam(gert::ExeResGenerationContext *context) {
34 return Mc2GenTaskOpsUtils::CommonKFCMc2CalcParamFunc(context, "aicpu kfc server", "kfc_stream");28 return Mc2GenTaskOpsUtils::CommonKFCMc2CalcParamFunc(context, "aicpu kfc server", "kfc_stream");
35}29}
@@ -40,20 +34,4 @@ static ge::Status AllGatherMatmulGenTask(const gert::ExeResGenerationContext *co
40}34}
41 35 
42IMPL_OP(AllGatherMatmul).CalcOpParam(AllGatherMatmulCalcOpParam).GenerateTask(AllGatherMatmulGenTask);36IMPL_OP(AllGatherMatmul).CalcOpParam(AllGatherMatmulCalcOpParam).GenerateTask(AllGatherMatmulGenTask);
43-#else // mc2 gen task utils
44-static ge::Status AllGatherMatmulGenTaskCallback(const gert::ExeResGenerationContext *context,
45- std::vector<domi::TaskDef> &tasks) {
46- return Mc2GenTaskUtils::Mc2GenTaskCallBack910A2(context, tasks);
47-}
48- 
49-static ge::Status AllGatherMatmulCalcOpParam(gert::ExeResGenerationContext *context) {
50- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "aicpu kfc server", "kfc_stream");
51-}
52- 
53-static ge::Status AllGatherMatmulGenTask(const gert::ExeResGenerationContext *context,
54- std::vector<std::vector<uint8_t>> &tasks) {
55- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, AllGatherMatmulGenTaskCallback);
56-}
57-IMPL_OP_CT(AllGatherMatmul).CalcOpParam(AllGatherMatmulCalcOpParam).GenerateTask(AllGatherMatmulGenTask);
58-#endif
59} // namespace ops37} // namespace ops
@@ -14,22 +14,14 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17- 
18-#ifdef BUILD_OPEN_PROJECT
19#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
20#include "op_graph/mc2_gen_task_ops_utils_arch35.h"18#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
21#include "register/op_impl_registry.h"19#include "register/op_impl_registry.h"
22#include "mc2_log.h"20#include "mc2_log.h"
23#include "mc2_platform_info.h"21#include "mc2_platform_info.h"
24-#else
25-#include "ops_error.h"
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 22 
31namespace ops {23namespace ops {
32-#ifdef BUILD_OPEN_PROJECT24+ 
33static ge::Status AllGatherMatmulV2CalcOpParam(gert::ExeResGenerationContext *context)25static ge::Status AllGatherMatmulV2CalcOpParam(gert::ExeResGenerationContext *context)
34{26{
35 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {27 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -52,28 +44,4 @@ static ge::Status AllGatherMatmulV2GenTask(const gert::ExeResGenerationContext *
52}44}
53 45 
54IMPL_OP(AllGatherMatmulV2).CalcOpParam(AllGatherMatmulV2CalcOpParam).GenerateTask(AllGatherMatmulV2GenTask);46IMPL_OP(AllGatherMatmulV2).CalcOpParam(AllGatherMatmulV2CalcOpParam).GenerateTask(AllGatherMatmulV2GenTask);
55-#else // mc2 gen task utils
56-static ge::Status AllGatherMatmulV2CalcOpParam(gert::ExeResGenerationContext *context)
57-{
58- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
59- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU CalcParam");
60- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
61- }
62- OPS_LOG_E(context->GetNodeName(), "Only support A5");
63- return ge::GRAPH_FAILED;
64-}
65- 
66-static ge::Status AllGatherMatmulV2GenTask(const gert::ExeResGenerationContext *context,
67- std::vector<std::vector<uint8_t>> &tasks)
68-{
69- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
70- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU GenTask");
71- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
72- }
73- OPS_LOG_E(context->GetNodeName(), "Only support A5");
74- return ge::GRAPH_FAILED;
75-}
76- 
77-IMPL_OP_CT(AllGatherMatmulV2).CalcOpParam(AllGatherMatmulV2CalcOpParam).GenerateTask(AllGatherMatmulV2GenTask);
78-#endif
79} // namespace ops47} // namespace ops
@@ -17,22 +17,15 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/mc2_moe_gen_task_ops_utils.h"21#include "op_graph/mc2_moe_gen_task_ops_utils.h"
23#include "graph/arg_desc_info.h"22#include "graph/arg_desc_info.h"
24#include "graph/kernel_launch_info.h"23#include "graph/kernel_launch_info.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26#include "mc2_log.h"25#include "mc2_log.h"
27-#else
28-#include "mc2_gen_task_moe.h"
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "register/op_ct_impl_registry.h"
31-#endif
32 26 
33namespace ops {27namespace ops {
34 28 
35-#ifdef BUILD_OPEN_PROJECT
36ge::Status AlltoAllAllGatherBatchMatMulCalcParamFunc(gert::ExeResGenerationContext *context)29ge::Status AlltoAllAllGatherBatchMatMulCalcParamFunc(gert::ExeResGenerationContext *context)
37{30{
38 const ge::AscendString name = "aicpu kfc server";31 const ge::AscendString name = "aicpu kfc server";
@@ -50,22 +43,4 @@ ge::Status AlltoAllAllGatherBatchMatMulGenTaskFunc(const gert::ExeResGenerationC
50IMPL_OP(AlltoAllAllGatherBatchMatMul)43IMPL_OP(AlltoAllAllGatherBatchMatMul)
51 .CalcOpParam(AlltoAllAllGatherBatchMatMulCalcParamFunc)44 .CalcOpParam(AlltoAllAllGatherBatchMatMulCalcParamFunc)
52 .GenerateTask(AlltoAllAllGatherBatchMatMulGenTaskFunc);45 .GenerateTask(AlltoAllAllGatherBatchMatMulGenTaskFunc);
53-#else // mc2 gen task utils
54-ge::Status AlltoAllAllGatherBatchMatMulCalcParamFunc(gert::ExeResGenerationContext *context)
55-{
56- const ge::AscendString name = "aicpu kfc server";
57- const ge::AscendString reuseKey = "kfc_stream";
58- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
59-}
60- 
61-ge::Status AlltoAllAllGatherBatchMatMulGenTaskFunc(const gert::ExeResGenerationContext *context,
62- std::vector<std::vector<uint8_t>> &tasks)
63-{
64- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
65-}
66- 
67-IMPL_OP_CT(AlltoAllAllGatherBatchMatMul)
68- .CalcOpParam(AlltoAllAllGatherBatchMatMulCalcParamFunc)
69- .GenerateTask(AlltoAllAllGatherBatchMatMulGenTaskFunc);
70-#endif
71} // namespace ops46} // namespace ops
@@ -16,18 +16,14 @@
16#include <platform/platform_info.h>16#include <platform/platform_info.h>
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18 18 
19-#ifdef BUILD_OPEN_PROJECT
20#include "op_graph/mc2_gen_task_ops_utils.h"19#include "op_graph/mc2_gen_task_ops_utils.h"
21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"20#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
22#include "register/op_impl_registry.h"21#include "register/op_impl_registry.h"
23#include "mc2_log.h"22#include "mc2_log.h"
24#include "mc2_platform_info.h"23#include "mc2_platform_info.h"
25-#endif
26 24 
27namespace ops {25namespace ops {
28 26 
29-#ifdef BUILD_OPEN_PROJECT
30- 
31ge::Status AlltoAllMatmulGenTaskCallback(const gert::ExeResGenerationContext *context, std::vector<std::vector<uint8_t>> &tasks)27ge::Status AlltoAllMatmulGenTaskCallback(const gert::ExeResGenerationContext *context, std::vector<std::vector<uint8_t>> &tasks)
32{28{
33 return Mc2GenTaskOpsUtils::CommonKFCMc2GenTask(context, tasks);29 return Mc2GenTaskOpsUtils::CommonKFCMc2GenTask(context, tasks);
@@ -53,6 +49,4 @@ static ge::Status AlltoAllMatmulGenTaskFunc(const gert::ExeResGenerationContext
53}49}
54 50 
55IMPL_OP(AlltoAllMatmul).CalcOpParam(AlltoAllMatmulCalcOpParamFunc).GenerateTask(AlltoAllMatmulGenTaskFunc);51IMPL_OP(AlltoAllMatmul).CalcOpParam(AlltoAllMatmulCalcOpParamFunc).GenerateTask(AlltoAllMatmulGenTaskFunc);
56-
57-#endif
58}52}
@@ -14,22 +14,14 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
19#include "op_graph/mc2_moe_gen_task_ops_utils.h"18#include "op_graph/mc2_moe_gen_task_ops_utils.h"
20#include "op_graph/mc2_gen_task_ops_utils_arch35.h"19#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
21#include "register/op_impl_registry.h"20#include "register/op_impl_registry.h"
22#include "mc2_log.h"21#include "mc2_log.h"
23#include "mc2_platform_info.h"22#include "mc2_platform_info.h"
24-#else
25-#include "mc2_gen_task_training.h"
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 23 
31namespace ops {24namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33ge::Status AlltoAllvGroupedMatMulCalcParamFunc(gert::ExeResGenerationContext *context)25ge::Status AlltoAllvGroupedMatMulCalcParamFunc(gert::ExeResGenerationContext *context)
34{26{
35 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {27 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -55,29 +47,5 @@ ge::Status AlltoAllvGroupedMatMulGenTaskFunc(const gert::ExeResGenerationContext
55IMPL_OP(AlltoAllvGroupedMatMul)47IMPL_OP(AlltoAllvGroupedMatMul)
56 .CalcOpParam(AlltoAllvGroupedMatMulCalcParamFunc)48 .CalcOpParam(AlltoAllvGroupedMatMulCalcParamFunc)
57 .GenerateTask(AlltoAllvGroupedMatMulGenTaskFunc);49 .GenerateTask(AlltoAllvGroupedMatMulGenTaskFunc);
58-#else // mc2 gen task utils
59-ge::Status AlltoAllvGroupedMatMulCalcParamFunc(gert::ExeResGenerationContext *context)
60-{
61- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
62- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
63- }
64- const ge::AscendString name = "aicpu kfc server";
65- const ge::AscendString reuseKey = "kfc_stream";
66- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
67-}
68- 
69-ge::Status AlltoAllvGroupedMatMulGenTaskFunc(const gert::ExeResGenerationContext *context,
70- std::vector<std::vector<uint8_t>> &tasks)
71-{
72- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
73- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
74- }
75- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskTraining::Mc2TrainingGenTaskCallback);
76-}
77- 
78-IMPL_OP_CT(AlltoAllvGroupedMatMul)
79- .CalcOpParam(AlltoAllvGroupedMatMulCalcParamFunc)
80- .GenerateTask(AlltoAllvGroupedMatMulGenTaskFunc);
81-#endif
82} // namespace ops50} // namespace ops
83 51 
@@ -14,22 +14,14 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
19#include "op_graph/mc2_moe_gen_task_ops_utils.h"18#include "op_graph/mc2_moe_gen_task_ops_utils.h"
20#include "op_graph/mc2_gen_task_ops_utils_arch35.h"19#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
21#include "register/op_impl_registry.h"20#include "register/op_impl_registry.h"
22#include "mc2_log.h"21#include "mc2_log.h"
23#include "mc2_platform_info.h"22#include "mc2_platform_info.h"
24-#else
25-#include "mc2_gen_task_training.h"
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 23 
31namespace ops {24namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33ge::Status AlltoAllvQuantGroupedMatMulCalcParamFunc(gert::ExeResGenerationContext *context)25ge::Status AlltoAllvQuantGroupedMatMulCalcParamFunc(gert::ExeResGenerationContext *context)
34{26{
35 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {27 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -55,29 +47,5 @@ ge::Status AlltoAllvQuantGroupedMatMulGenTaskFunc(const gert::ExeResGenerationCo
55IMPL_OP(AlltoAllvQuantGroupedMatMul)47IMPL_OP(AlltoAllvQuantGroupedMatMul)
56 .CalcOpParam(AlltoAllvQuantGroupedMatMulCalcParamFunc)48 .CalcOpParam(AlltoAllvQuantGroupedMatMulCalcParamFunc)
57 .GenerateTask(AlltoAllvQuantGroupedMatMulGenTaskFunc);49 .GenerateTask(AlltoAllvQuantGroupedMatMulGenTaskFunc);
58-#else // mc2 gen task utils
59-ge::Status AlltoAllvQuantGroupedMatMulCalcParamFunc(gert::ExeResGenerationContext *context)
60-{
61- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
62- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
63- }
64- const ge::AscendString name = "aicpu kfc server";
65- const ge::AscendString reuseKey = "kfc_stream";
66- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
67-}
68- 
69-ge::Status AlltoAllvQuantGroupedMatMulGenTaskFunc(const gert::ExeResGenerationContext *context,
70- std::vector<std::vector<uint8_t>> &tasks)
71-{
72- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
73- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
74- }
75- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskTraining::Mc2TrainingGenTaskCallback);
76-}
77- 
78-IMPL_OP_CT(AlltoAllvQuantGroupedMatMul)
79- .CalcOpParam(AlltoAllvQuantGroupedMatMulCalcParamFunc)
80- .GenerateTask(AlltoAllvQuantGroupedMatMulGenTaskFunc);
81-#endif
82} // namespace ops50} // namespace ops
83 51 
@@ -19,26 +19,17 @@
19#include "common/utils/op_mc2.h"19#include "common/utils/op_mc2.h"
20#include "platform/platform_info.h"20#include "platform/platform_info.h"
21 21 
22-#ifdef BUILD_OPEN_PROJECT
23#include "op_graph/mc2_gen_task_ops_utils.h"22#include "op_graph/mc2_gen_task_ops_utils.h"
24#include "op_graph/mc2_moe_gen_task_ops_utils.h"23#include "op_graph/mc2_moe_gen_task_ops_utils.h"
25#include "graph/arg_desc_info.h"24#include "graph/arg_desc_info.h"
26#include "graph/kernel_launch_info.h"25#include "graph/kernel_launch_info.h"
27#include "register/op_impl_registry.h"26#include "register/op_impl_registry.h"
28#include "mc2_log.h"27#include "mc2_log.h"
29-#else
30-#include "ops_error.h"
31-#include "mc2_gen_task_moe.h"
32-#include "op_graph/mc2_gen_task_utils.h"
33-#include "register/op_ct_impl_registry.h"
34-#include "register/op_ext_gentask_registry.h"
35-#endif
36 28 
37namespace ops {29namespace ops {
38constexpr char AICPU_KFC_SERVER_NAME[] = "aicpu kfc server";30constexpr char AICPU_KFC_SERVER_NAME[] = "aicpu kfc server";
39constexpr char KFC_STREAM_NAME[] = "kfc_stream";31constexpr char KFC_STREAM_NAME[] = "kfc_stream";
40 32 
41-#ifdef BUILD_OPEN_PROJECT
42ge::Status AttentionToFFNCalcParamFunc(gert::ExeResGenerationContext *context)33ge::Status AttentionToFFNCalcParamFunc(gert::ExeResGenerationContext *context)
43{34{
44 const ge::AscendString name = AICPU_KFC_SERVER_NAME;35 const ge::AscendString name = AICPU_KFC_SERVER_NAME;
@@ -59,24 +50,4 @@ ge::Status AttentionToFFNGenTaskFunc(const gert::ExeResGenerationContext *contex
59IMPL_OP(AttentionToFFN)50IMPL_OP(AttentionToFFN)
60 .CalcOpParam(AttentionToFFNCalcParamFunc)51 .CalcOpParam(AttentionToFFNCalcParamFunc)
61 .GenerateTask(AttentionToFFNGenTaskFunc);52 .GenerateTask(AttentionToFFNGenTaskFunc);
62-#else // mc2 gen task utils
63-ge::Status AttentionToFFNCalcParamFunc(gert::ExeResGenerationContext *context)
64-{
65- const ge::AscendString name = AICPU_KFC_SERVER_NAME;
66- const ge::AscendString reuseKey = KFC_STREAM_NAME;
67- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
68-}
69- 
70-ge::Status AttentionToFFNGenTaskFunc(const gert::ExeResGenerationContext *context,
71- std::vector<std::vector<uint8_t>> &tasks)
72-{
73- OPS_LOG_I(context->GetNodeName(), "MC2 Generate task start.");
74- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
75-}
76- 
77-IMPL_OP_CT(AttentionToFFN)
78- .CalcOpParam(AttentionToFFNCalcParamFunc)
79- .GenerateTask(AttentionToFFNGenTaskFunc);
80-REGISTER_EXT_TASK_TYPE(AttentionToFFN, fe::ExtTaskType::kAicoreTask);
81-#endif
82} // namespace ops53} // namespace ops
@@ -17,22 +17,15 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/mc2_moe_gen_task_ops_utils.h"21#include "op_graph/mc2_moe_gen_task_ops_utils.h"
23#include "graph/arg_desc_info.h"22#include "graph/arg_desc_info.h"
24#include "graph/kernel_launch_info.h"23#include "graph/kernel_launch_info.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26#include "mc2_log.h"25#include "mc2_log.h"
27-#else
28-#include "mc2_gen_task_moe.h"
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "register/op_ct_impl_registry.h"
31-#endif
32 26 
33namespace ops {27namespace ops {
34 28 
35-#ifdef BUILD_OPEN_PROJECT
36ge::Status BatchMatMulReduceScatterAlltoAllCalcParamFunc(gert::ExeResGenerationContext *context)29ge::Status BatchMatMulReduceScatterAlltoAllCalcParamFunc(gert::ExeResGenerationContext *context)
37{30{
38 const ge::AscendString name = "aicpu kfc server";31 const ge::AscendString name = "aicpu kfc server";
@@ -50,22 +43,4 @@ ge::Status BatchMatMulReduceScatterAlltoAllGenTaskFunc(const gert::ExeResGenerat
50IMPL_OP(BatchMatMulReduceScatterAlltoAll)43IMPL_OP(BatchMatMulReduceScatterAlltoAll)
51 .CalcOpParam(BatchMatMulReduceScatterAlltoAllCalcParamFunc)44 .CalcOpParam(BatchMatMulReduceScatterAlltoAllCalcParamFunc)
52 .GenerateTask(BatchMatMulReduceScatterAlltoAllGenTaskFunc);45 .GenerateTask(BatchMatMulReduceScatterAlltoAllGenTaskFunc);
53-#else // mc2 gen task utils
54-ge::Status BatchMatMulReduceScatterAlltoAllCalcParamFunc(gert::ExeResGenerationContext *context)
55-{
56- const ge::AscendString name = "aicpu kfc server";
57- const ge::AscendString reuseKey = "kfc_stream";
58- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
59-}
60- 
61-ge::Status BatchMatMulReduceScatterAlltoAllGenTaskFunc(const gert::ExeResGenerationContext *context,
62- std::vector<std::vector<uint8_t>> &tasks)
63-{
64- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
65-}
66- 
67-IMPL_OP_CT(BatchMatMulReduceScatterAlltoAll)
68- .CalcOpParam(BatchMatMulReduceScatterAlltoAllCalcParamFunc)
69- .GenerateTask(BatchMatMulReduceScatterAlltoAllGenTaskFunc);
70-#endif
71} // namespace ops46} // namespace ops
@@ -1,343 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file mc2_a5_gen_task_utils.cpp
13- * \brief
14- */
15- 
16-#ifndef BUILD_OPEN_PROJECT
17-#include "mc2_a5_gen_task_utils.h"
18-#include "mc2_gen_task_utils.h"
19-#include "runtime/rt_model.h"
20-#include "matmul_allto_all_util.h"
21-#include "error/ops_error.h"
22-#include "error_util.h"
23-#include "proto/task.pb.h"
24-#include "framework/common/taskdown_common.h"
25-#include "exe_graph/runtime/exe_res_generation_context.h"
26-#include "graph/utils/args_format_desc_utils.h"
27-#include "register/hidden_inputs_func_registry.h"
28- 
29-namespace ops {
30- 
31-constexpr int64_t INVALID_INT_VAL = -1;
32-// 对已有结构的重复定义,只在本文件插入 aicpu desc 的时候使用
33-struct HcclCommParamDescTemp {
34- uint64_t version : 4;
35- uint64_t groupNum : 4;
36- uint64_t hasFfts : 1;
37- uint64_t tilingOff : 7;
38- uint64_t isDyn : 48;
39-};
40- 
41-int64_t GetAttachStreamIdByContext(const gert::ExeResGenerationContext *context, size_t idx = 0) {
42-#ifndef ASCEND_OPSPROTO_UT
43- const auto stream_infos = context->GetAttachedStreamInfos();
44- if (idx >= stream_infos.size()) {
45- OPS_LOG_E(context->GetNodeName(), "Invalid index %zu in streams count %zu.", idx, stream_infos.size());
46- return INVALID_INT_VAL;
47- }
48- 
49- const int64_t stream_id = (stream_infos[0].is_valid ? stream_infos[0].stream_id : INVALID_INT_VAL);
50-#else
51- const int64_t stream_id = 1;
52-#endif
53- return stream_id;
54-}
55- 
56-const std::string MOE_DISTRIBUTE_DISPATCH_OP_TYPE = "MoeDistributeDispatch";
57-const std::string MOE_DISTRIBUTE_COMBINE_OP_TYPE = "MoeDistributeCombine";
58-const std::string MOE_DISTRIBUTE_DISPATCH_V2_OP_TYPE = "MoeDistributeDispatchV2";
59-const std::string MOE_DISTRIBUTE_COMBINE_V2_OP_TYPE = "MoeDistributeCombineV2";
60-const std::string ALL_TO_ALLV_GROUPED_MM_OP_TYPE = "AlltoAllvGroupedMatMul";
61-const std::string GROUPED_MM_ALL_TO_ALLV_OP_TYPE = "GroupedMatMulAlltoAllv";
62-const std::string ALL_TO_ALLV_QUANT_GROUPED_MM_OP_TYPE = "AlltoAllvQuantGroupedMatMul";
63-const std::string QUANT_GROUPED_MM_ALL_TO_ALLV_OP_TYPE = "QuantGroupedMatMulAlltoAllv";
64-const std::string ALL_GATHER_MM_V2_OP_TYPE = "AllGatherMatmulV2";
65-const std::string MM_REDUCE_SCATTER_V2_OP_TYPE = "MatmulReduceScatterV2";
66-const std::string MM_ALL_REDUCE_OP_TYPE = "MatmulAllReduce";
67-const std::string MM_ALLTO_ALL_OP_TYPE = "MatmulAlltoAll";
68-const std::string ALLTO_ALL_MM_OP_TYPE = "AlltoAllMatmul";
69-const std::string ATTR_NAME_GROUP = "group";
70-const std::string ATTR_NAME_GROUP_EP = "group_ep";
71-const int32_t MAX_GROUP_CNT = 16;
72- 
73-struct GroupInfo {
74- int32_t groupCnt; // 算子通信域数量
75- std::vector<std::string> groupAttrNames; // 算子通信域属性名
76-};
77-// 当前 GetCCuTaskInfo 接口暂不支持多通信域的接口,对于双通信域的算子,暂时不增加 TP 属性名
78-static const std::map<const std::string, const GroupInfo> GROUP_INFO_MAP_A5 {
79- {ALL_GATHER_MM_V2_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
80- {MM_REDUCE_SCATTER_V2_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
81- {MM_ALL_REDUCE_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
82- {MM_ALLTO_ALL_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
83- {ALLTO_ALL_MM_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
84- {ALL_TO_ALLV_GROUPED_MM_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
85- {GROUPED_MM_ALL_TO_ALLV_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
86- {ALL_TO_ALLV_QUANT_GROUPED_MM_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
87- {QUANT_GROUPED_MM_ALL_TO_ALLV_OP_TYPE, {1, {ATTR_NAME_GROUP}}},
88- {MOE_DISTRIBUTE_DISPATCH_OP_TYPE, {2, {ATTR_NAME_GROUP_EP}}},
89- {MOE_DISTRIBUTE_COMBINE_OP_TYPE, {2, {ATTR_NAME_GROUP_EP}}},
90- {MOE_DISTRIBUTE_DISPATCH_V2_OP_TYPE, {2, {ATTR_NAME_GROUP_EP}}},
91- {MOE_DISTRIBUTE_COMBINE_V2_OP_TYPE, {2, {ATTR_NAME_GROUP_EP}}},
92-};
93- 
94-static bool GetGroupInfo(const gert::ExeResGenerationContext *context, GroupInfo &groupInfo) {
95- const char *opType = context->GetNodeType();
96- if (opType == nullptr) {
97- OPS_LOG_E(context->GetNodeName(), "Op type is nullptr.");
98- return false;
99- }
100- const std::string opTypeStr = opType;
101- if (GROUP_INFO_MAP_A5.find(opTypeStr) == GROUP_INFO_MAP_A5.end()) {
102- OPS_LOG_E(context->GetNodeName(), "Op type [%s] has not registe in group cnt map.", opType);
103- return false;
104- }
105- groupInfo = GROUP_INFO_MAP_A5.at(opTypeStr);
106- const int32_t cnt = groupInfo.groupCnt;
107- if ((cnt <= 0) || (cnt > MAX_GROUP_CNT)) {
108- OPS_LOG_E(context->GetNodeName(), "Group cnt [%d] is invalid, it should in [1, %d].", cnt, MAX_GROUP_CNT);
109- return false;
110- }
111- 
112- OPS_LOG_D(context->GetNodeName(), "Op [%s] get group [%d] success.", opType, cnt);
113- return true;
114-}
115- 
116-ge::Status Mc2A5GenTaskUtils::InsertContextForCcuFusion(const gert::ExeResGenerationContext *context,
117- domi::TaskDef &task_def, std::vector<ge::ArgDesc> args,
118- bool isAllKernel)
119-{
120- auto fusion_task = task_def.mutable_fusion_task();
121- GE_ASSERT_NOTNULL(fusion_task);
122- uint32_t subTaskInfoIdx = 0;
123- // fusion_task中添加两个task: ccu task和 aicore_task
124- fusion_task->add_fusion_sub_task_info();
125- fusion_task->add_fusion_sub_task_info();
126- // sub task 排列顺序ccu + aicore
127- OPS_LOG_I(context->GetNodeName(), "subTaskInfoIdx is %u before before", subTaskInfoIdx);
128- auto ccu_task_def = fusion_task->mutable_fusion_sub_task_info(subTaskInfoIdx++);
129- OPS_LOG_I(context->GetNodeName(), "subTaskInfoIdx is %u before after", subTaskInfoIdx);
130- GE_ASSERT_NOTNULL(ccu_task_def);
131- // ccu task 填充type, ccu task 其他信息由ge填充
132- ccu_task_def->set_type(domi::FusionSubTaskInfo_FusionType::FusionSubTaskInfo_FusionType_CCU);
133- auto ccu_task = ccu_task_def->mutable_task();
134- GE_ASSERT_NOTNULL(ccu_task);
135- auto ccu_task_group = ccu_task->mutable_ccu_task_group();
136- GE_ASSERT_NOTNULL(ccu_task_group);
137- ccu_task_group->add_ccu_task_info();
138- 
139- OPS_LOG_I(context->GetNodeName(), "subTaskInfoIdx is %u before", subTaskInfoIdx);
140- auto aicore_task_def = fusion_task->mutable_fusion_sub_task_info(subTaskInfoIdx++);
141- OPS_LOG_I(context->GetNodeName(), "subTaskInfoIdx is %u after", subTaskInfoIdx);
142- GE_ASSERT_NOTNULL(aicore_task_def);
143- 
144- // task 填充信息都填充到aicore中
145- aicore_task_def->set_type(domi::FusionSubTaskInfo_FusionType::FusionSubTaskInfo_FusionType_AICORE);
146- auto aicore_task = aicore_task_def->mutable_task();
147- GE_ASSERT_NOTNULL(aicore_task);
148- auto aicore_fusion_task_info = aicore_task->mutable_aicore_fusion_task_info();
149- GE_ASSERT_NOTNULL(aicore_fusion_task_info);
150- // is_all_kernel为true表示优先进行二进制复用,如果没有匹配到则进行在线编译
151- aicore_fusion_task_info->set_is_all_kernel(isAllKernel);
152- OPS_LOG_I(context->GetNodeName(), "set is all kernel to %u.", isAllKernel);
153- // 设置attribute中的numBlocks
154- auto config = aicore_fusion_task_info->mutable_config();
155- GE_ASSERT_NOTNULL(config);
156- config->add_launch_attribute();
157- auto launch_attribute = config->mutable_launch_attribute(0);
158- GE_ASSERT_NOTNULL(launch_attribute);
159- launch_attribute->set_id(domi::LaunchAttribute_LaunchAttributeId::LaunchAttribute_LaunchAttributeId_BLOCKDIM);
160- auto value = launch_attribute->mutable_value();
161- GE_ASSERT_NOTNULL(value);
162- 
163- int64_t numBlocks = 1;
164- if (!context->GetIntAttrVal("tvm_blockdim", numBlocks) || numBlocks <= 0) {
165- OPS_LOG_I(context->GetNodeName(), "Can't get valid numBlocks, get numBlocks %ld, set numBlocks 1.", numBlocks);
166- numBlocks = 1;
167- }
168- OPS_LOG_I(context->GetNodeName(), "get numBlocks %ld", numBlocks);
169- value->set_block_dim(numBlocks);
170- 
171- auto aicore_context = aicore_fusion_task_info->mutable_context();
172- GE_ASSERT_NOTNULL(aicore_context);
173- aicore_context->set_kernel_type(static_cast<uint32_t>(ge::ccKernelType::MIX_AICORE));
174- 
175- OPS_LOG_I(context->GetNodeName(), "fusion task op index %zu", context->GetOpId());
176- fusion_task->set_op_index(context->GetOpId());
177- 
178- GroupInfo groupInfo;
179- if (!GetGroupInfo(context, groupInfo)) {
180- return ge::GRAPH_FAILED;
181- }
182- for (const std::string &groupAttrName : groupInfo.groupAttrNames) {
183- ccu_task_group->add_group(groupAttrName);
184- OPS_LOG_D(context->GetNodeName(), "Set group attr [%s] to ccu task info success.", groupAttrName.c_str());
185- }
186- ge::ArgsFormatDescUtils::InsertHiddenInputs(args, 0, ge::HiddenInputsType::HCOM, groupInfo.groupCnt);
187- 
188- // desc 配置
189- union {
190- HcclCommParamDescTemp hcclCommParaDesc;
191- uint64_t customValue;
192- } desc;
193- desc.hcclCommParaDesc.version = 1;
194- desc.hcclCommParaDesc.groupNum = groupInfo.groupCnt;
195- desc.hcclCommParaDesc.hasFfts = 0; // david不使用ffts
196- desc.hcclCommParaDesc.tilingOff = args.size() - 1;
197- desc.hcclCommParaDesc.isDyn = 0;
198- // args 参数顺序: {hcom}{INPUT0}...{INPUTN}{OUTPUT0}...{OUTPUTN}{WORKSPACE}{TILING}{desc}
199- OPS_LOG_I(context->GetNodeName(), "tilingOff is : %d", desc.hcclCommParaDesc.tilingOff);
200- 
201- ge::ArgsFormatDescUtils::InsertCustomValue(args, -1, desc.customValue);
202- fusion_task->set_args_format(ge::ArgsFormatDescUtils::ToString(args));
203- int32_t args_num = args.size() - 1;
204- OPS_LOG_I(context->GetNodeName(), "args num is : %d", args_num);
205- fusion_task->set_kfc_args_format_offset(args_num);
206- OPS_LOG_I(context->GetNodeName(), "args_format is : %s", ge::ArgsFormatDescUtils::ToString(args).c_str());
207- return ge::GRAPH_SUCCESS;
208-}
209- 
210-ge::Status Mc2A5GenTaskUtils::CreateCcuFusionTask(const gert::ExeResGenerationContext *context,
211- domi::TaskDef &ccu_fusion_task, rtModelTaskType_t type,
212- bool is_attached_stream)
213-{
214- GE_ASSERT_NOTNULL(context);
215- int64_t stream_id;
216- if (is_attached_stream) {
217- stream_id = GetAttachStreamIdByContext(context);
218- } else {
219- stream_id = context->GetStreamId();
220- }
221- GE_ASSERT_TRUE(stream_id >= 0);
222- ccu_fusion_task.set_id(context->GetOpId());
223- ccu_fusion_task.set_notify_id(UINT32_MAX);
224- ccu_fusion_task.set_type(type);
225- ccu_fusion_task.set_stream_id(stream_id);
226- // 算子临时规避整网执行方案:aic(1个) + ccu(4个) 一共占据 5 个 sqe
227- ccu_fusion_task.set_sqe_num(5);
228- OPS_LOG_I(context->GetNodeName(), "Create fusion task(type %u) for mc2 node successfully, %s stream id %ld.",
229- static_cast<uint32_t>(type), (is_attached_stream ? "attached" : "main"), stream_id);
230- return ge::GRAPH_SUCCESS;
231-}
232- 
233-ge::Status Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5(const gert::ExeResGenerationContext *context,
234- std::vector<domi::TaskDef> &tasks)
235-{
236- // 获取aicore task 并删除
237- int64_t aicore_idx = Mc2GenTaskUtils::GetTaskIdxByType(context, tasks, RT_MODEL_TASK_ALL_KERNEL);
238- bool isAllKernel = true;
239- if (aicore_idx < 0) {
240- OPS_LOG_D(context->GetNodeName(), "start Mc2MoeDistributeGenTaskCallBackA5 RT_MODEL_TASK_KERNEL");
241- aicore_idx = Mc2GenTaskUtils::GetTaskIdxByType(context, tasks, RT_MODEL_TASK_KERNEL);
242- isAllKernel = false;
243- OPS_LOG_D(context->GetNodeName(), "Set is all kernel to false.");
244- }
245- OP_CHECK(aicore_idx < 0, OPS_LOG_E(context->GetNodeName(), "Failed to get AICore task."), return ge::GRAPH_FAILED);
246- OPS_LOG_I(context->GetNodeName(), "Start to generate task for MC2, task def size %lu, aicore index %ld.",
247- tasks.size(), aicore_idx);
248- // 获取 aicore 的 args_format
249- std::vector<ge::ArgDesc> argDescs;
250- if (Mc2A5GenTaskUtils::GetArgsFormat(context, tasks[static_cast<size_t>(aicore_idx)], argDescs) != ge::GRAPH_SUCCESS) {
251- return ge::GRAPH_FAILED;
252- }
253- OPS_LOG_I(context->GetNodeName(), "before args_format is : %s", ge::ArgsFormatDescUtils::ToString(argDescs).c_str());
254- 
255- auto iter = tasks.erase(tasks.begin() + aicore_idx);
256- // 创建 fusion task
257- domi::TaskDef fusion_task{};
258- GE_ASSERT_SUCCESS(CreateCcuFusionTask(context, fusion_task, RT_MODEL_TASK_FUSION_KERNEL, false));
259- tasks.insert(iter, fusion_task);
260- OPS_LOG_D(context->GetNodeName(), "after CreateCcuFusionTask.");
261- return InsertContextForCcuFusion(context, tasks[static_cast<size_t>(aicore_idx)], argDescs, isAllKernel);
262-}
263- 
264-ge::Status Mc2A5GenTaskUtils::GetArgsFormat(const gert::ExeResGenerationContext *context, domi::TaskDef &aicoreTask,
265- std::vector<ge::ArgDesc> &argDescs)
266-{
267- domi::KernelContext *kernel_context;
268- if (aicoreTask.type() == RT_MODEL_TASK_KERNEL) {
269- auto kernel_def = aicoreTask.mutable_kernel();
270- GE_ASSERT_NOTNULL(kernel_def);
271- kernel_context = kernel_def->mutable_context();
272- } else if (aicoreTask.type() == RT_MODEL_TASK_ALL_KERNEL) {
273- auto kernel_with_handle = aicoreTask.mutable_kernel_with_handle();
274- GE_ASSERT_NOTNULL(kernel_with_handle);
275- kernel_context = kernel_with_handle->mutable_context();
276- } else {
277- OPS_LOG_E(context->GetNodeName(), "Invalid task type [%u].", aicoreTask.type());
278- return ge::GRAPH_FAILED;
279- }
280- const std::string argsFormat = kernel_context->args_format();
281- OPS_ERR_IF(ge::ArgsFormatDescUtils::Parse(argsFormat, argDescs) != ge::GRAPH_SUCCESS || argDescs.empty(),
282- OPS_LOG_E(context->GetNodeName(), "Failed to parse, argsFormat:[%s]", argsFormat.c_str()), return ge::GRAPH_FAILED);
283- OPS_LOG_D(context->GetNodeName(), "end GetArgsFormat %s", argsFormat.c_str());
284- return ge::GRAPH_SUCCESS;
285-}
286- 
287-bool Mc2A5GenTaskUtils::IsTargetPlatformSocVersion(const char *nodeName, const std::set<std::string> &targetPlatform)
288-{
289- fe::PlatFormInfos platform_info;
290- fe::OptionalInfos optional_info;
291- if (fe::PlatformInfoManager::Instance().GetPlatformInfoWithOutSocVersion(platform_info, optional_info) !=
292- ge::GRAPH_SUCCESS) {
293- OPS_LOG_E(nodeName, "Cannot get platform info in gentask!");
294- return false;
295- }
296- std::string short_soc_version;
297- if (!platform_info.GetPlatformRes("version", "Short_SoC_version", short_soc_version) || short_soc_version.empty()) {
298- OPS_LOG_E(nodeName, "Cannot get short soc version in Mc2A5GenTaskUtils::IsTargetPlatformSocVersion!");
299- return false;
300- }
301- OPS_LOG_D(nodeName, "Get soc version: %s", short_soc_version.c_str());
302- return targetPlatform.count(short_soc_version) > 0;
303-}
304- 
305-bool Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(const char *nodeName, const std::set<std::string> &targetPlatform)
306-{
307- fe::PlatFormInfos platform_info;
308- fe::OptionalInfos optional_info;
309- if (fe::PlatformInfoManager::Instance().GetPlatformInfoWithOutSocVersion(platform_info, optional_info) !=
310- ge::GRAPH_SUCCESS) {
311- OPS_LOG_E(nodeName, "Cannot get platform info in Mc2A5GenTaskUtils::IsTargetPlatformNpuArch!");
312- return false;
313- }
314- auto ascendcPlatform = platform_ascendc::PlatformAscendC(&platform_info);
315- std::string socNpuArch = std::to_string(static_cast<uint32_t>(ascendcPlatform.GetCurNpuArch()));
316- OPS_LOG_D(nodeName, "Current GenTask Platform (NpuArch) %s", socNpuArch.c_str());
317- return targetPlatform.count(socNpuArch) > 0;
318-}
319- 
320-const std::string Mc2A5GenTaskUtils::GetCommAlg(const gert::ExeResGenerationContext *context, const size_t commAlgIdx)
321-{
322- auto *attrs = context->GetAttrs();
323- if (attrs == nullptr) {
324- OPS_LOG_E(context->GetNodeName(), "Attrs pointer is null.");
325- return "";
326- }
327- const char *commAlgPtr = attrs->GetStr(commAlgIdx);
328- if (commAlgPtr == nullptr) {
329- OPS_LOG_E(context->GetNodeName(), "Comm alg pointer is null.");
330- return "";
331- }
332- const std::string commAlg = commAlgPtr;
333- if (commAlg.empty()) {
334- OPS_LOG_W(context->GetNodeName(), "Comm alg is empty, will use mte alg.");
335- return "mte";
336- }
337- OPS_LOG_D(context->GetNodeName(), "Comm alg is %s.", commAlg.c_str());
338- return commAlg;
339-}
340- 
341-} // namespace ops
342- 
343-#endif
@@ -1,57 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10-/*!
11- * \file mc2_a5_gen_task_utils.h
12- * \brief
13- */
14- 
15-#ifndef OPS_TRANSFORMER_DEV_MC2_COMMON_INC_MC2_A5_GEN_TASK_UTILS_H
16-#define OPS_TRANSFORMER_DEV_MC2_COMMON_INC_MC2_A5_GEN_TASK_UTILS_H
17- 
18-#ifndef BUILD_OPEN_PROJECT
19- 
20-#include <set>
21-#include "runtime/rt_model.h"
22-#include "proto/task.pb.h"
23-#include "exe_graph/runtime/exe_res_generation_context.h"
24-#include "graph/utils/args_format_desc_utils.h"
25-#include "platform/platform_info.h"
26-#include "platform/platform_ascendc.h"
27-#include "platform/soc_spec.h"
28- 
29-namespace ops {
30-const std::set<std::string> PLATFORM_A2 = {"Ascend910B"};
31-const std::set<std::string> PLATFORM_A3 = {"Ascend910_93"};
32-const std::set<std::string> NPUARCH_A5 = {std::to_string(static_cast<uint32_t>(NpuArch::DAV_3510))};
33- 
34-const std::string COMM_ALG_FULLMESH_V1 = "fullmesh_v1";
35-const std::string COMM_ALG_FULLMESH_V2 = "fullmesh_v2";
36-const std::string COMM_ALG_MTE = "mte";
37-const std::string COMM_ALG_CCU = "ccu";
38-class Mc2A5GenTaskUtils {
39-public:
40- static void DeleteTaskIdxByType(const gert::ExeResGenerationContext *context,
41- const std::vector<domi::TaskDef> &tasks, rtModelTaskType_t type);
42- static ge::Status CreateCcuFusionTask(const gert::ExeResGenerationContext *context, domi::TaskDef &ccu_fusion_task,
43- rtModelTaskType_t type, bool is_attached_stream);
44- static ge::Status InsertContextForCcuFusion(const gert::ExeResGenerationContext *context, domi::TaskDef &task_def,
45- std::vector<ge::ArgDesc> args, bool isAllKernel);
46- static ge::Status Mc2GenTaskCallBack910A5(const gert::ExeResGenerationContext *context,
47- std::vector<domi::TaskDef> &tasks);
48- static ge::Status GetArgsFormat(const gert::ExeResGenerationContext *context, domi::TaskDef &aicoreTask,
49- std::vector<ge::ArgDesc> &argDescs);
50- static bool IsTargetPlatformSocVersion(const char *nodeName, const std::set<std::string> &targetPlatform);
51- static bool IsTargetPlatformNpuArch(const char *nodeName, const std::set<std::string> &targetPlatform);
52- static const std::string GetCommAlg(const gert::ExeResGenerationContext *context, const size_t commAlgIdx);
53-};
54-}
55-#endif
56- 
57-#endif // OPS_TRANSFORMER_DEV_MC2_COMMON_INC_MC2_A5_GEN_TASK_UTILS_H
@@ -17,23 +17,15 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/mc2_moe_gen_task_ops_utils.h"21#include "op_graph/mc2_moe_gen_task_ops_utils.h"
23#include "graph/arg_desc_info.h"22#include "graph/arg_desc_info.h"
24#include "graph/kernel_launch_info.h"23#include "graph/kernel_launch_info.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26#include "mc2_log.h"25#include "mc2_log.h"
27-#else
28-#include "mc2_gen_task_moe.h"
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "register/op_ct_impl_registry.h"
31-#include "register/op_ext_gentask_registry.h"
32-#endif
33 26 
34namespace ops {27namespace ops {
35 28 
36-#ifdef BUILD_OPEN_PROJECT
37ge::Status DistributeBarrierCalcParamFunc(gert::ExeResGenerationContext *context)29ge::Status DistributeBarrierCalcParamFunc(gert::ExeResGenerationContext *context)
38{30{
39 const ge::AscendString name = "aicpu kfc server";31 const ge::AscendString name = "aicpu kfc server";
@@ -49,22 +41,4 @@ ge::Status DistributeBarrierGenTaskFunc(const gert::ExeResGenerationContext *con
49 41 
50// new ver42// new ver
51IMPL_OP(DistributeBarrier).CalcOpParam(DistributeBarrierCalcParamFunc).GenerateTask(DistributeBarrierGenTaskFunc);43IMPL_OP(DistributeBarrier).CalcOpParam(DistributeBarrierCalcParamFunc).GenerateTask(DistributeBarrierGenTaskFunc);
52-#else // mc2 gen task utils
53-ge::Status DistributeBarrierCalcParamFunc(gert::ExeResGenerationContext *context)
54-{
55- const ge::AscendString name = "aicpu kfc server";
56- const ge::AscendString reuseKey = "kfc_stream";
57- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
58-}
59- 
60-ge::Status DistributeBarrierGenTaskFunc(const gert::ExeResGenerationContext *context,
61- std::vector<std::vector<uint8_t>> &tasks)
62-{
63- // 移除判断走A2V1的
64- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
65-}
66- 
67-IMPL_OP_CT(DistributeBarrier).CalcOpParam(DistributeBarrierCalcParamFunc).GenerateTask(DistributeBarrierGenTaskFunc);
68-REGISTER_EXT_TASK_TYPE(DistributeBarrier, fe::ExtTaskType::kAicoreTask);
69-#endif
70} // namespace ops44} // namespace ops
@@ -19,27 +19,18 @@
19#include "common/utils/op_mc2.h"19#include "common/utils/op_mc2.h"
20#include "platform/platform_info.h"20#include "platform/platform_info.h"
21 21 
22-#ifdef BUILD_OPEN_PROJECT
23#include "op_graph/mc2_gen_task_ops_utils.h"22#include "op_graph/mc2_gen_task_ops_utils.h"
24#include "op_graph/mc2_moe_gen_task_ops_utils.h"23#include "op_graph/mc2_moe_gen_task_ops_utils.h"
25#include "mc2_log.h"24#include "mc2_log.h"
26#include "graph/arg_desc_info.h"25#include "graph/arg_desc_info.h"
27#include "graph/kernel_launch_info.h"26#include "graph/kernel_launch_info.h"
28#include "register/op_impl_registry.h"27#include "register/op_impl_registry.h"
29-#else
30-#include "ops_error.h"
31-#include "op_graph/mc2_gen_task_utils.h"
32-#include "mc2_gen_task_moe.h"
33-#include "register/op_ct_impl_registry.h"
34-#include "register/op_ext_gentask_registry.h"
35-#endif
36 28 
37namespace ops {29namespace ops {
38 30 
39constexpr char AICPU_KFC_SERVER_NAME[] = "aicpu kfc server";31constexpr char AICPU_KFC_SERVER_NAME[] = "aicpu kfc server";
40constexpr char KFC_STREAM_NAME[] = "kfc_stream";32constexpr char KFC_STREAM_NAME[] = "kfc_stream";
41 33 
42-#ifdef BUILD_OPEN_PROJECT
43ge::Status FFNToAttentionCalcParamFunc(gert::ExeResGenerationContext *context)34ge::Status FFNToAttentionCalcParamFunc(gert::ExeResGenerationContext *context)
44{35{
45 const ge::AscendString name = AICPU_KFC_SERVER_NAME;36 const ge::AscendString name = AICPU_KFC_SERVER_NAME;
@@ -59,24 +50,4 @@ ge::Status FFNToAttentionGenTaskFunc(const gert::ExeResGenerationContext *contex
59IMPL_OP(FFNToAttention)50IMPL_OP(FFNToAttention)
60 .CalcOpParam(FFNToAttentionCalcParamFunc)51 .CalcOpParam(FFNToAttentionCalcParamFunc)
61 .GenerateTask(FFNToAttentionGenTaskFunc);52 .GenerateTask(FFNToAttentionGenTaskFunc);
62-#else // mc2 gen task utils
63-ge::Status FFNToAttentionCalcParamFunc(gert::ExeResGenerationContext *context)
64-{
65- const ge::AscendString name = AICPU_KFC_SERVER_NAME;
66- const ge::AscendString reuseKey = KFC_STREAM_NAME;
67- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
68-}
69- 
70-ge::Status FFNToAttentionGenTaskFunc(const gert::ExeResGenerationContext *context,
71- std::vector<std::vector<uint8_t>> &tasks)
72-{
73- OPS_LOG_I(context->GetNodeName(), "MC2 Generate task start.");
74- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
75-}
76- 
77-IMPL_OP_CT(FFNToAttention)
78- .CalcOpParam(FFNToAttentionCalcParamFunc)
79- .GenerateTask(FFNToAttentionGenTaskFunc);
80-REGISTER_EXT_TASK_TYPE(FFNToAttention, fe::ExtTaskType::kAicoreTask);
81-#endif
82} // namespace ops53} // namespace ops
@@ -14,22 +14,14 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
19#include "op_graph/mc2_moe_gen_task_ops_utils.h"18#include "op_graph/mc2_moe_gen_task_ops_utils.h"
20#include "op_graph/mc2_gen_task_ops_utils_arch35.h"19#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
21#include "register/op_impl_registry.h"20#include "register/op_impl_registry.h"
22#include "mc2_log.h"21#include "mc2_log.h"
23#include "mc2_platform_info.h"22#include "mc2_platform_info.h"
24-#else
25-#include "mc2_gen_task_training.h"
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 23 
31namespace ops {24namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33ge::Status GroupedMatMulAlltoAllvCalcParamFunc(gert::ExeResGenerationContext *context)25ge::Status GroupedMatMulAlltoAllvCalcParamFunc(gert::ExeResGenerationContext *context)
34{26{
35 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {27 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -55,28 +47,4 @@ ge::Status GroupedMatMulAlltoAllvGenTaskFunc(const gert::ExeResGenerationContext
55IMPL_OP(GroupedMatMulAlltoAllv)47IMPL_OP(GroupedMatMulAlltoAllv)
56 .CalcOpParam(GroupedMatMulAlltoAllvCalcParamFunc)48 .CalcOpParam(GroupedMatMulAlltoAllvCalcParamFunc)
57 .GenerateTask(GroupedMatMulAlltoAllvGenTaskFunc);49 .GenerateTask(GroupedMatMulAlltoAllvGenTaskFunc);
58-#else // mc2 gen task utils
59-ge::Status GroupedMatMulAlltoAllvCalcParamFunc(gert::ExeResGenerationContext *context)
60-{
61- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
62- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
63- }
64- const ge::AscendString name = "aicpu kfc server";
65- const ge::AscendString reuseKey = "kfc_stream";
66- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
67-}
68- 
69-ge::Status GroupedMatMulAlltoAllvGenTaskFunc(const gert::ExeResGenerationContext *context,
70- std::vector<std::vector<uint8_t>> &tasks)
71-{
72- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
73- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
74- }
75- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskTraining::Mc2TrainingGenTaskCallback);
76-}
77- 
78-IMPL_OP_CT(GroupedMatMulAlltoAllv)
79- .CalcOpParam(GroupedMatMulAlltoAllvCalcParamFunc)
80- .GenerateTask(GroupedMatMulAlltoAllvGenTaskFunc);
81-#endif
82} // namespace ops50} // namespace ops
@@ -17,22 +17,15 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/matmul_all_reduce_gen_task_ops_utils.h" // in transformer dev21#include "op_graph/matmul_all_reduce_gen_task_ops_utils.h" // in transformer dev
23#include "graph/arg_desc_info.h"22#include "graph/arg_desc_info.h"
24#include "graph/kernel_launch_info.h"23#include "graph/kernel_launch_info.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26#include "mc2_log.h"25#include "mc2_log.h"
27-#else
28-#include "op_graph/matmul_all_reduce_gen_task_utils.h" // in canndev
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "register/op_ct_impl_registry.h"
31-#endif
32 26 
33namespace ops {27namespace ops {
34 28 
35-#ifdef BUILD_OPEN_PROJECT
36ge::Status InplaceMatmulAllReduceAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)29ge::Status InplaceMatmulAllReduceAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)
37{30{
38 const ge::AscendString name = "aicpu kfc server";31 const ge::AscendString name = "aicpu kfc server";
@@ -50,23 +43,4 @@ ge::Status InplaceMatmulAllReduceAddRmsNormGenTaskFunc(const gert::ExeResGenerat
50IMPL_OP(InplaceMatmulAllReduceAddRmsNorm)43IMPL_OP(InplaceMatmulAllReduceAddRmsNorm)
51 .CalcOpParam(InplaceMatmulAllReduceAddRmsNormCalcParamFunc)44 .CalcOpParam(InplaceMatmulAllReduceAddRmsNormCalcParamFunc)
52 .GenerateTask(InplaceMatmulAllReduceAddRmsNormGenTaskFunc);45 .GenerateTask(InplaceMatmulAllReduceAddRmsNormGenTaskFunc);
53-#else // mc2 gen task utils
54-ge::Status InplaceMatmulAllReduceAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)
55-{
56- const ge::AscendString name = "aicpu kfc server";
57- const ge::AscendString reuseKey = "kfc_stream";
58- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
59-}
60- 
61-ge::Status InplaceMatmulAllReduceAddRmsNormGenTaskFunc(const gert::ExeResGenerationContext *context,
62- std::vector<std::vector<uint8_t>> &tasks)
63-{
64- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks,
65- MatmulAllReduceGenTaskUtils::MatmulAllReduceGenTaskCallback);
66-}
67- 
68-IMPL_OP_CT(InplaceMatmulAllReduceAddRmsNorm)
69- .CalcOpParam(InplaceMatmulAllReduceAddRmsNormCalcParamFunc)
70- .GenerateTask(InplaceMatmulAllReduceAddRmsNormGenTaskFunc);
71-#endif
72} // namespace ops46} // namespace ops
@@ -14,22 +14,14 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
19#include "op_graph/matmul_all_reduce_gen_task_ops_utils.h" //in transformer dev18#include "op_graph/matmul_all_reduce_gen_task_ops_utils.h" //in transformer dev
20#include "op_graph/mc2_gen_task_ops_utils_arch35.h"19#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
21#include "register/op_impl_registry.h"20#include "register/op_impl_registry.h"
22#include "mc2_log.h"21#include "mc2_log.h"
23#include "mc2_platform_info.h"22#include "mc2_platform_info.h"
24-#else
25-#include "op_graph/matmul_all_reduce_gen_task_utils.h" //in canndev
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 23 
31namespace ops {24namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33ge::Status MatmulAllReduceCalcParamFunc(gert::ExeResGenerationContext *context)25ge::Status MatmulAllReduceCalcParamFunc(gert::ExeResGenerationContext *context)
34{26{
35 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {27 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -53,27 +45,4 @@ ge::Status MatmulAllReduceGenTaskFunc(const gert::ExeResGenerationContext *conte
53 45 
54// new ver46// new ver
55IMPL_OP(MatmulAllReduce).CalcOpParam(MatmulAllReduceCalcParamFunc).GenerateTask(MatmulAllReduceGenTaskFunc);47IMPL_OP(MatmulAllReduce).CalcOpParam(MatmulAllReduceCalcParamFunc).GenerateTask(MatmulAllReduceGenTaskFunc);
56-#else // mc2 gen task utils
57-ge::Status MatmulAllReduceCalcParamFunc(gert::ExeResGenerationContext *context)
58-{
59- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
60- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
61- }
62- const ge::AscendString name = "aicpu kfc server";
63- const ge::AscendString reuseKey = "kfc_stream";
64- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
65-}
66- 
67-ge::Status MatmulAllReduceGenTaskFunc(const gert::ExeResGenerationContext *context,
68- std::vector<std::vector<uint8_t>> &tasks)
69-{
70- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
71- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
72- }
73- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks,
74- MatmulAllReduceGenTaskUtils::MatmulAllReduceGenTaskCallback);
75-}
76- 
77-IMPL_OP_CT(MatmulAllReduce).CalcOpParam(MatmulAllReduceCalcParamFunc).GenerateTask(MatmulAllReduceGenTaskFunc);
78-#endif
79} // namespace ops48} // namespace ops
@@ -17,22 +17,15 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/matmul_all_reduce_gen_task_ops_utils.h"21#include "op_graph/matmul_all_reduce_gen_task_ops_utils.h"
23#include "graph/arg_desc_info.h"22#include "graph/arg_desc_info.h"
24#include "graph/kernel_launch_info.h"23#include "graph/kernel_launch_info.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26#include "mc2_log.h"25#include "mc2_log.h"
27-#else
28-#include "op_graph/matmul_all_reduce_gen_task_utils.h"
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "register/op_ct_impl_registry.h"
31-#endif
32 26 
33namespace ops {27namespace ops {
34 28 
35-#ifdef BUILD_OPEN_PROJECT
36ge::Status MatmulAllReduceAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)29ge::Status MatmulAllReduceAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)
37{30{
38 const ge::AscendString name = "aicpu kfc server";31 const ge::AscendString name = "aicpu kfc server";
@@ -50,23 +43,4 @@ ge::Status MatmulAllReduceAddRmsNormGenTaskFunc(const gert::ExeResGenerationCont
50IMPL_OP(MatmulAllReduceAddRmsNorm)43IMPL_OP(MatmulAllReduceAddRmsNorm)
51 .CalcOpParam(MatmulAllReduceAddRmsNormCalcParamFunc)44 .CalcOpParam(MatmulAllReduceAddRmsNormCalcParamFunc)
52 .GenerateTask(MatmulAllReduceAddRmsNormGenTaskFunc);45 .GenerateTask(MatmulAllReduceAddRmsNormGenTaskFunc);
53-#else // mc2 gen task utils
54-ge::Status MatmulAllReduceAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)
55-{
56- const ge::AscendString name = "aicpu kfc server";
57- const ge::AscendString reuseKey = "kfc_stream";
58- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
59-}
60- 
61-ge::Status MatmulAllReduceAddRmsNormGenTaskFunc(const gert::ExeResGenerationContext *context,
62- std::vector<std::vector<uint8_t>> &tasks)
63-{
64- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks,
65- MatmulAllReduceGenTaskUtils::MatmulAllReduceGenTaskCallback);
66-}
67- 
68-IMPL_OP_CT(MatmulAllReduceAddRmsNorm)
69- .CalcOpParam(MatmulAllReduceAddRmsNormCalcParamFunc)
70- .GenerateTask(MatmulAllReduceAddRmsNormGenTaskFunc);
71-#endif
72} // namespace ops46} // namespace ops
@@ -16,18 +16,14 @@
16#include <platform/platform_info.h>16#include <platform/platform_info.h>
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18 18 
19-#ifdef BUILD_OPEN_PROJECT
20#include "op_graph/mc2_gen_task_ops_utils.h"19#include "op_graph/mc2_gen_task_ops_utils.h"
21#include "register/op_impl_registry.h"20#include "register/op_impl_registry.h"
22#include "op_graph/mc2_gen_task_ops_utils_arch35.h"21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
23#include "mc2_log.h"22#include "mc2_log.h"
24#include "mc2_platform_info.h"23#include "mc2_platform_info.h"
25-#endif
26 24 
27namespace ops {25namespace ops {
28 26 
29-#ifdef BUILD_OPEN_PROJECT
30- 
31ge::Status MatmulAlltoAllGenTaskCallback(const gert::ExeResGenerationContext *context, std::vector<std::vector<uint8_t>> &tasks)27ge::Status MatmulAlltoAllGenTaskCallback(const gert::ExeResGenerationContext *context, std::vector<std::vector<uint8_t>> &tasks)
32{28{
33 return Mc2GenTaskOpsUtils::CommonKFCMc2GenTask(context, tasks);29 return Mc2GenTaskOpsUtils::CommonKFCMc2GenTask(context, tasks);
@@ -53,6 +49,4 @@ static ge::Status MatmulAlltoAllGenTaskFunc(const gert::ExeResGenerationContext
53}49}
54 50 
55IMPL_OP(MatmulAlltoAll).CalcOpParam(MatmulAlltoAllCalcOpParamFunc).GenerateTask(MatmulAlltoAllGenTaskFunc);51IMPL_OP(MatmulAlltoAll).CalcOpParam(MatmulAlltoAllCalcOpParamFunc).GenerateTask(MatmulAlltoAllGenTaskFunc);
56-
57-#endif
58}52}
@@ -17,19 +17,13 @@
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18#include "platform/platform_info.h"18#include "platform/platform_info.h"
19 19 
20-#ifdef BUILD_OPEN_PROJECT
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "mc2_log.h"21#include "mc2_log.h"
23#include "graph/kernel_launch_info.h"22#include "graph/kernel_launch_info.h"
24#include "graph/arg_desc_info.h"23#include "graph/arg_desc_info.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26-#else
27-#include "op_graph/mc2_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#endif
30 25 
31namespace ops {26namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33static ge::Status MatmulReduceScatterCalcOpParam(gert::ExeResGenerationContext *context)27static ge::Status MatmulReduceScatterCalcOpParam(gert::ExeResGenerationContext *context)
34{28{
35 return Mc2GenTaskOpsUtils::CommonKFCMc2CalcParamFunc(context, "aicpu kfc server", "kfc_stream");29 return Mc2GenTaskOpsUtils::CommonKFCMc2CalcParamFunc(context, "aicpu kfc server", "kfc_stream");
@@ -42,24 +36,4 @@ static ge::Status MatmulReduceScatterGenTask(const gert::ExeResGenerationContext
42}36}
43 37 
44IMPL_OP(MatmulReduceScatter).CalcOpParam(MatmulReduceScatterCalcOpParam).GenerateTask(MatmulReduceScatterGenTask);38IMPL_OP(MatmulReduceScatter).CalcOpParam(MatmulReduceScatterCalcOpParam).GenerateTask(MatmulReduceScatterGenTask);
45-#else // mc2 gen task utils
46-static ge::Status MatmulReduceScatterGenTaskCallback(const gert::ExeResGenerationContext *context,
47- std::vector<domi::TaskDef> &tasks)
48-{
49- return Mc2GenTaskUtils::Mc2GenTaskCallBack910A2(context, tasks);
50-}
51- 
52-static ge::Status MatmulReduceScatterCalcOpParam(gert::ExeResGenerationContext *context)
53-{
54- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "aicpu kfc server", "kfc_stream");
55-}
56- 
57-static ge::Status MatmulReduceScatterGenTask(const gert::ExeResGenerationContext *context,
58- std::vector<std::vector<uint8_t>> &tasks)
59-{
60- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, MatmulReduceScatterGenTaskCallback);
61-}
62- 
63-IMPL_OP_CT(MatmulReduceScatter).CalcOpParam(MatmulReduceScatterCalcOpParam).GenerateTask(MatmulReduceScatterGenTask);
64-#endif
65} // namespace ops39} // namespace ops
@@ -13,21 +13,13 @@
13 * \brief13 * \brief
14 */14 */
15 15 
16-#ifdef BUILD_OPEN_PROJECT
17#include "op_graph/mc2_gen_task_ops_utils.h"16#include "op_graph/mc2_gen_task_ops_utils.h"
18#include "op_graph/mc2_gen_task_ops_utils_arch35.h"17#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
19#include "register/op_impl_registry.h"18#include "register/op_impl_registry.h"
20#include "mc2_log.h"19#include "mc2_log.h"
21#include "mc2_platform_info.h"20#include "mc2_platform_info.h"
22-#else
23-#include "ops_error.h"
24-#include "op_graph/mc2_gen_task_utils.h"
25-#include "op_graph/mc2_a5_gen_task_utils.h"
26-#include "register/op_ct_impl_registry.h"
27-#endif
28 21 
29namespace ops {22namespace ops {
30-#ifdef BUILD_OPEN_PROJECT
31static ge::Status MatmulReduceScatterV2CalcOpParam(gert::ExeResGenerationContext *context)23static ge::Status MatmulReduceScatterV2CalcOpParam(gert::ExeResGenerationContext *context)
32{24{
33 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {25 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -50,28 +42,4 @@ static ge::Status MatmulReduceScatterV2GenTask(const gert::ExeResGenerationConte
50}42}
51 43 
52IMPL_OP(MatmulReduceScatterV2).CalcOpParam(MatmulReduceScatterV2CalcOpParam).GenerateTask(MatmulReduceScatterV2GenTask);44IMPL_OP(MatmulReduceScatterV2).CalcOpParam(MatmulReduceScatterV2CalcOpParam).GenerateTask(MatmulReduceScatterV2GenTask);
53-#else // mc2 gen task utils
54-static ge::Status MatmulReduceScatterV2CalcOpParam(gert::ExeResGenerationContext *context)
55-{
56- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
57- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU CalcParam");
58- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
59- }
60- OPS_LOG_E(context->GetNodeName(), "Only support A5");
61- return ge::GRAPH_FAILED;
62-}
63- 
64-static ge::Status MatmulReduceScatterV2GenTask(const gert::ExeResGenerationContext *context,
65- std::vector<std::vector<uint8_t>> &tasks)
66-{
67- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
68- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU GenTask");
69- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
70- }
71- OPS_LOG_E(context->GetNodeName(), "Only support A5");
72- return ge::GRAPH_FAILED;
73-}
74- 
75-IMPL_OP_CT(MatmulReduceScatterV2).CalcOpParam(MatmulReduceScatterV2CalcOpParam).GenerateTask(MatmulReduceScatterV2GenTask);
76-#endif
77} // namespace ops45} // namespace ops
@@ -14,23 +14,13 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
19#include "op_graph/mc2_moe_gen_task_ops_utils.h"18#include "op_graph/mc2_moe_gen_task_ops_utils.h"
20#include "register/op_impl_registry.h"19#include "register/op_impl_registry.h"
21#include "mc2_log.h"20#include "mc2_log.h"
22#include "mc2_platform_info.h"21#include "mc2_platform_info.h"
23-#else
24-#include "ops_error.h"
25-#include "mc2_gen_task_moe.h"
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#include "register/op_ext_gentask_registry.h"
30-#endif
31 22 
32namespace ops {23namespace ops {
33-#ifdef BUILD_OPEN_PROJECT
34ge::Status MoeDistributeCombineCalcParamFunc(gert::ExeResGenerationContext *context)24ge::Status MoeDistributeCombineCalcParamFunc(gert::ExeResGenerationContext *context)
35{25{
36 OPS_LOG_D(context->GetNodeName(), "Do general calc param");26 OPS_LOG_D(context->GetNodeName(), "Do general calc param");
@@ -53,29 +43,4 @@ ge::Status MoeDistributeCombineGenTaskFunc(const gert::ExeResGenerationContext *
53IMPL_OP(MoeDistributeCombine)43IMPL_OP(MoeDistributeCombine)
54 .CalcOpParam(MoeDistributeCombineCalcParamFunc)44 .CalcOpParam(MoeDistributeCombineCalcParamFunc)
55 .GenerateTask(MoeDistributeCombineGenTaskFunc);45 .GenerateTask(MoeDistributeCombineGenTaskFunc);
56-#else // mc2 gen task utils
57-ge::Status MoeDistributeCombineCalcParamFunc(gert::ExeResGenerationContext *context)
58-{
59- const ge::AscendString name = "aicpu kfc server";
60- const ge::AscendString reuseKey = "kfc_stream";
61- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
62-}
63- 
64-ge::Status MoeDistributeCombineGenTaskFunc(const gert::ExeResGenerationContext *context,
65- std::vector<std::vector<uint8_t>> &tasks)
66-{
67- const char *nodeName = context->GetNodeName();
68- if (Mc2A5GenTaskUtils::IsTargetPlatformSocVersion(nodeName, PLATFORM_A2)) {
69- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
70- }
71- OPS_LOG_D(context->GetNodeName(), "Do MTE gen task.");
72- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
73-}
74- 
75-IMPL_OP_CT(MoeDistributeCombine)
76- .CalcOpParam(MoeDistributeCombineCalcParamFunc)
77- .GenerateTask(MoeDistributeCombineGenTaskFunc);
78- 
79-REGISTER_EXT_TASK_TYPE(MoeDistributeCombine, fe::ExtTaskType::kAicoreTask);
80-#endif
81} // namespace ops46} // namespace ops
@@ -19,20 +19,12 @@
19#include "common/utils/op_mc2.h"19#include "common/utils/op_mc2.h"
20#include "platform/platform_info.h"20#include "platform/platform_info.h"
21 21 
22-#ifdef BUILD_OPEN_PROJECT
23#include "op_graph/mc2_gen_task_ops_utils.h"22#include "op_graph/mc2_gen_task_ops_utils.h"
24#include "op_graph/mc2_moe_gen_task_ops_utils.h"23#include "op_graph/mc2_moe_gen_task_ops_utils.h"
25#include "graph/arg_desc_info.h"24#include "graph/arg_desc_info.h"
26#include "graph/kernel_launch_info.h"25#include "graph/kernel_launch_info.h"
27#include "register/op_impl_registry.h"26#include "register/op_impl_registry.h"
28#include "mc2_log.h"27#include "mc2_log.h"
29-#else
30-#include "ops_error.h"
31-#include "mc2_gen_task_moe.h"
32-#include "op_graph/mc2_gen_task_utils.h"
33-#include "register/op_ct_impl_registry.h"
34-#include "register/op_ext_gentask_registry.h"
35-#endif
36 28 
37namespace ops {29namespace ops {
38 30 
@@ -55,7 +47,6 @@ static bool IsPlatform910B(const char *nodeName)
55 return supported_soc.count(short_soc_version) > 0;47 return supported_soc.count(short_soc_version) > 0;
56}48}
57 49 
58-#ifdef BUILD_OPEN_PROJECT
59ge::Status MoeDistributeCombineAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)50ge::Status MoeDistributeCombineAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)
60{51{
61 const ge::AscendString name = "aicpu kfc server";52 const ge::AscendString name = "aicpu kfc server";
@@ -78,28 +69,4 @@ ge::Status MoeDistributeCombineAddRmsNormGenTaskFunc(const gert::ExeResGeneratio
78IMPL_OP(MoeDistributeCombineAddRmsNorm)69IMPL_OP(MoeDistributeCombineAddRmsNorm)
79 .CalcOpParam(MoeDistributeCombineAddRmsNormCalcParamFunc)70 .CalcOpParam(MoeDistributeCombineAddRmsNormCalcParamFunc)
80 .GenerateTask(MoeDistributeCombineAddRmsNormGenTaskFunc);71 .GenerateTask(MoeDistributeCombineAddRmsNormGenTaskFunc);
81-#else // mc2 gen task utils
82-ge::Status MoeDistributeCombineAddRmsNormCalcParamFunc(gert::ExeResGenerationContext *context)
83-{
84- const ge::AscendString name = "aicpu kfc server";
85- const ge::AscendString reuseKey = "kfc_stream";
86- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
87-}
88- 
89-ge::Status MoeDistributeCombineAddRmsNormGenTaskFunc(const gert::ExeResGenerationContext *context,
90- std::vector<std::vector<uint8_t>> &tasks)
91-{
92- const char *nodeName = context->GetNodeName();
93- if (IsPlatform910B(nodeName)) {
94- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
95- }
96- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
97-}
98- 
99-IMPL_OP_CT(MoeDistributeCombineAddRmsNorm)
100- .CalcOpParam(MoeDistributeCombineAddRmsNormCalcParamFunc)
101- .GenerateTask(MoeDistributeCombineAddRmsNormGenTaskFunc);
102- 
103-REGISTER_EXT_TASK_TYPE(MoeDistributeCombineAddRmsNorm, fe::ExtTaskType::kAicoreTask);
104-#endif
105} // namespace ops72} // namespace ops
@@ -19,22 +19,12 @@
19#include "common/utils/op_mc2.h"19#include "common/utils/op_mc2.h"
20#include "platform/platform_info.h"20#include "platform/platform_info.h"
21 21 
22-#ifdef BUILD_OPEN_PROJECT
23#include "op_graph/mc2_gen_task_ops_utils.h"22#include "op_graph/mc2_gen_task_ops_utils.h"
24#include "op_graph/mc2_moe_gen_task_ops_utils.h"23#include "op_graph/mc2_moe_gen_task_ops_utils.h"
25#include "register/op_impl_registry.h"24#include "register/op_impl_registry.h"
26#include "mc2_log.h"25#include "mc2_log.h"
27-#else
28-#include "ops_error.h"
29-#include "mc2_gen_task_moe.h"
30-#include "op_graph/mc2_gen_task_utils.h"
31-#include "register/op_ct_impl_registry.h"
32-#include "register/op_ext_gentask_registry.h"
33-#endif
34- 
35namespace ops {26namespace ops {
36 27 
37-#ifdef BUILD_OPEN_PROJECT
38ge::Status MoeDistributeCombineSetupCalcParamFunc(gert::ExeResGenerationContext *context)28ge::Status MoeDistributeCombineSetupCalcParamFunc(gert::ExeResGenerationContext *context)
39{29{
40 const ge::AscendString name = "aicpu kfc server";30 const ge::AscendString name = "aicpu kfc server";
@@ -54,26 +44,4 @@ ge::Status MoeDistributeCombineSetupGenTaskFunc(const gert::ExeResGenerationCont
54IMPL_OP(MoeDistributeCombineSetup)44IMPL_OP(MoeDistributeCombineSetup)
55 .CalcOpParam(MoeDistributeCombineSetupCalcParamFunc)45 .CalcOpParam(MoeDistributeCombineSetupCalcParamFunc)
56 .GenerateTask(MoeDistributeCombineSetupGenTaskFunc);46 .GenerateTask(MoeDistributeCombineSetupGenTaskFunc);
57-#else // mc2 gen task utils
58-ge::Status MoeDistributeCombineSetupCalcParamFunc(gert::ExeResGenerationContext *context)
59-{
60- const ge::AscendString name = "aicpu kfc server";
61- const ge::AscendString reuseKey = "kfc_stream";
62- OPS_LOG_D(context->GetNodeName(), "Do A3 aicpu CalcParam.");
63- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
64-}
65- 
66-ge::Status MoeDistributeCombineSetupGenTaskFunc(const gert::ExeResGenerationContext *context,
67- std::vector<std::vector<uint8_t>> &tasks)
68-{
69- OPS_LOG_D(context->GetNodeName(), "Do A3 aicpu GenTask.");
70- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
71-}
72- 
73-IMPL_OP_CT(MoeDistributeCombineSetup)
74- .CalcOpParam(MoeDistributeCombineSetupCalcParamFunc)
75- .GenerateTask(MoeDistributeCombineSetupGenTaskFunc);
76- 
77-REGISTER_EXT_TASK_TYPE(MoeDistributeCombineSetup, fe::ExtTaskType::kAicoreTask);
78-#endif
79} // namespace ops47} // namespace ops
@@ -16,25 +16,15 @@
16#include <set>16#include <set>
17#include <string>17#include <string>
18 18 
19-#ifdef BUILD_OPEN_PROJECT
20#include "op_graph/mc2_gen_task_ops_utils.h"19#include "op_graph/mc2_gen_task_ops_utils.h"
21#include "op_graph/mc2_moe_gen_task_ops_utils.h"20#include "op_graph/mc2_moe_gen_task_ops_utils.h"
22#include "op_graph/mc2_gen_task_ops_utils_arch35.h"21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
23#include "register/op_impl_registry.h"22#include "register/op_impl_registry.h"
24#include "mc2_log.h"23#include "mc2_log.h"
25#include "mc2_platform_info.h"24#include "mc2_platform_info.h"
26-#else
27-#include "ops_error.h"
28-#include "mc2_gen_task_moe.h"
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "op_graph/mc2_a5_gen_task_utils.h"
31-#include "register/op_ct_impl_registry.h"
32-#include "register/op_ext_gentask_registry.h"
33-#endif
34 25 
35namespace ops {26namespace ops {
36static const size_t ATTR_INDEX_COMM_ALG_DISTRIBUTE_COMBINE_V2 = 14;27static const size_t ATTR_INDEX_COMM_ALG_DISTRIBUTE_COMBINE_V2 = 14;
37-#ifdef BUILD_OPEN_PROJECT
38ge::Status MoeDistributeCombineV2CalcParamFunc(gert::ExeResGenerationContext *context)28ge::Status MoeDistributeCombineV2CalcParamFunc(gert::ExeResGenerationContext *context)
39{29{
40 if ((IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) &&30 if ((IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) &&
@@ -76,45 +66,4 @@ ge::Status MoeDistributeCombineV2GenTaskFunc(const gert::ExeResGenerationContext
76IMPL_OP(MoeDistributeCombineV2)66IMPL_OP(MoeDistributeCombineV2)
77 .CalcOpParam(MoeDistributeCombineV2CalcParamFunc)67 .CalcOpParam(MoeDistributeCombineV2CalcParamFunc)
78 .GenerateTask(MoeDistributeCombineV2GenTaskFunc);68 .GenerateTask(MoeDistributeCombineV2GenTaskFunc);
79-#else // mc2 gen task utils
80-ge::Status MoeDistributeCombineV2CalcParamFunc(gert::ExeResGenerationContext *context)
81-{
82- if ((Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) &&
83- (Mc2A5GenTaskUtils::GetCommAlg(context, ATTR_INDEX_COMM_ALG_DISTRIBUTE_COMBINE_V2) != COMM_ALG_MTE)) {
84- OPS_LOG_D(context->GetNodeName(), "Do A5 ccu calc param.");
85- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
86- }
87- const ge::AscendString name = "aicpu kfc server";
88- const ge::AscendString reuseKey = "kfc_stream";
89- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
90-}
91- 
92-ge::Status MoeDistributeCombineV2GenTaskFunc(const gert::ExeResGenerationContext *context,
93- std::vector<std::vector<uint8_t>> &tasks)
94-{
95- const char *nodeName = context->GetNodeName();
96- if (Mc2A5GenTaskUtils::IsTargetPlatformSocVersion(context->GetNodeName(), PLATFORM_A2)) {
97- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
98- } else if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
99- const std::string commAlg = Mc2A5GenTaskUtils::GetCommAlg(context, ATTR_INDEX_COMM_ALG_DISTRIBUTE_COMBINE_V2);
100- if (commAlg == COMM_ALG_MTE) {
101- OPS_LOG_D(context->GetNodeName(), "Do A5 mte gen task.");
102- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
103- } else if (commAlg == COMM_ALG_CCU) {
104- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU gen task.");
105- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
106- } else {
107- OPS_LOG_E(context->GetNodeName(), "Got unsupported commAlg %s.", commAlg.c_str());
108- return ge::GRAPH_FAILED;
109- }
110- }
111- OPS_LOG_D(context->GetNodeName(), "Do A3 gen task.");
112- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
113-}
114- 
115-IMPL_OP_CT(MoeDistributeCombineV2)
116- .CalcOpParam(MoeDistributeCombineV2CalcParamFunc)
117- .GenerateTask(MoeDistributeCombineV2GenTaskFunc);
118-REGISTER_EXT_TASK_TYPE(MoeDistributeCombineV2, fe::ExtTaskType::kAicoreTask);
119-#endif
120} // namespace ops69} // namespace ops
@@ -14,23 +14,13 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "op_graph/mc2_gen_task_ops_utils.h"17#include "op_graph/mc2_gen_task_ops_utils.h"
19#include "op_graph/mc2_moe_gen_task_ops_utils.h"18#include "op_graph/mc2_moe_gen_task_ops_utils.h"
20#include "register/op_impl_registry.h"19#include "register/op_impl_registry.h"
21#include "mc2_log.h"20#include "mc2_log.h"
22#include "mc2_platform_info.h"21#include "mc2_platform_info.h"
23-#else
24-#include "ops_error.h"
25-#include "mc2_gen_task_moe.h"
26-#include "op_graph/mc2_gen_task_utils.h"
27-#include "op_graph/mc2_a5_gen_task_utils.h"
28-#include "register/op_ct_impl_registry.h"
29-#include "register/op_ext_gentask_registry.h"
30-#endif
31 22 
32namespace ops {23namespace ops {
33-#ifdef BUILD_OPEN_PROJECT
34ge::Status MoeDistributeDispatchCalcParamFunc(gert::ExeResGenerationContext *context)24ge::Status MoeDistributeDispatchCalcParamFunc(gert::ExeResGenerationContext *context)
35{25{
36 OPS_LOG_D(context->GetNodeName(), "Do general calc param");26 OPS_LOG_D(context->GetNodeName(), "Do general calc param");
@@ -53,28 +43,4 @@ ge::Status MoeDistributeDispatchGenTaskFunc(const gert::ExeResGenerationContext
53IMPL_OP(MoeDistributeDispatch)43IMPL_OP(MoeDistributeDispatch)
54 .CalcOpParam(MoeDistributeDispatchCalcParamFunc)44 .CalcOpParam(MoeDistributeDispatchCalcParamFunc)
55 .GenerateTask(MoeDistributeDispatchGenTaskFunc);45 .GenerateTask(MoeDistributeDispatchGenTaskFunc);
56-#else // mc2 gen task utils
57-ge::Status MoeDistributeDispatchCalcParamFunc(gert::ExeResGenerationContext *context)
58-{
59- const ge::AscendString name = "aicpu kfc server";
60- const ge::AscendString reuseKey = "kfc_stream";
61- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
62-}
63- 
64-ge::Status MoeDistributeDispatchGenTaskFunc(const gert::ExeResGenerationContext *context,
65- std::vector<std::vector<uint8_t>> &tasks)
66-{
67- const char *nodeName = context->GetNodeName();
68- if (Mc2A5GenTaskUtils::IsTargetPlatformSocVersion(nodeName, PLATFORM_A2)) {
69- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
70- }
71- OPS_LOG_D(context->GetNodeName(), "Do MTE gen task.");
72- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
73-}
74- 
75-IMPL_OP_CT(MoeDistributeDispatch)
76- .CalcOpParam(MoeDistributeDispatchCalcParamFunc)
77- .GenerateTask(MoeDistributeDispatchGenTaskFunc);
78-REGISTER_EXT_TASK_TYPE(MoeDistributeDispatch, fe::ExtTaskType::kAicoreTask);
79-#endif
80} // namespace ops46} // namespace ops
@@ -16,25 +16,15 @@
16#include <set>16#include <set>
17#include <string>17#include <string>
18 18 
19-#ifdef BUILD_OPEN_PROJECT
20#include "op_graph/mc2_gen_task_ops_utils.h"19#include "op_graph/mc2_gen_task_ops_utils.h"
21#include "op_graph/mc2_moe_gen_task_ops_utils.h"20#include "op_graph/mc2_moe_gen_task_ops_utils.h"
22#include "op_graph/mc2_gen_task_ops_utils_arch35.h"21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
23#include "register/op_impl_registry.h"22#include "register/op_impl_registry.h"
24#include "mc2_log.h"23#include "mc2_log.h"
25#include "mc2_platform_info.h"24#include "mc2_platform_info.h"
26-#else
27-#include "ops_error.h"
28-#include "mc2_gen_task_moe.h"
29-#include "op_graph/mc2_gen_task_utils.h"
30-#include "op_graph/mc2_a5_gen_task_utils.h"
31-#include "register/op_ct_impl_registry.h"
32-#include "register/op_ext_gentask_registry.h"
33-#endif
34 25 
35namespace ops {26namespace ops {
36static const size_t ATTR_INDEX_COMM_ALG_DISTRIBUTE_DISPATCH_V2 = 13;27static const size_t ATTR_INDEX_COMM_ALG_DISTRIBUTE_DISPATCH_V2 = 13;
37-#ifdef BUILD_OPEN_PROJECT
38ge::Status MoeDistributeDispatchV2CalcParamFunc(gert::ExeResGenerationContext *context)28ge::Status MoeDistributeDispatchV2CalcParamFunc(gert::ExeResGenerationContext *context)
39{29{
40 if ((IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) &&30 if ((IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) &&
@@ -76,46 +66,4 @@ ge::Status MoeDistributeDispatchV2GenTaskFunc(const gert::ExeResGenerationContex
76IMPL_OP(MoeDistributeDispatchV2)66IMPL_OP(MoeDistributeDispatchV2)
77 .CalcOpParam(MoeDistributeDispatchV2CalcParamFunc)67 .CalcOpParam(MoeDistributeDispatchV2CalcParamFunc)
78 .GenerateTask(MoeDistributeDispatchV2GenTaskFunc);68 .GenerateTask(MoeDistributeDispatchV2GenTaskFunc);
79-#else // mc2 gen task utils
80-ge::Status MoeDistributeDispatchV2CalcParamFunc(gert::ExeResGenerationContext *context)
81-{
82- if ((Mc2A5GenTaskUtils::IsTargetPlatform(context->GetNodeName(), NPUARCH_A5)) &&
83- (Mc2A5GenTaskUtils::GetCommAlg(context, ATTR_INDEX_COMM_ALG_DISTRIBUTE_DISPATCH_V2) == COMM_ALG_CCU)) {
84- OPS_LOG_D(context->GetNodeName(), "Do A5 ccu calc param.");
85- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
86- }
87- const ge::AscendString name = "aicpu kfc server";
88- const ge::AscendString reuseKey = "kfc_stream";
89- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
90-}
91- 
92-ge::Status MoeDistributeDispatchV2GenTaskFunc(const gert::ExeResGenerationContext *context,
93- std::vector<std::vector<uint8_t>> &tasks)
94-{
95- const char *nodeName = context->GetNodeName();
96- if (Mc2A5GenTaskUtils::IsTargetPlatformSocVersion(context->GetNodeName(), PLATFORM_A2)) {
97- OPS_LOG_D(nodeName, "Do A2 mte gen task.");
98- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallback);
99- } else if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
100- const std::string commAlg = Mc2A5GenTaskUtils::GetCommAlg(context, ATTR_INDEX_COMM_ALG_DISTRIBUTE_DISPATCH_V2);
101- if ((commAlg == COMM_ALG_MTE) || (commAlg == COMM_ALG_FULLMESH_V1) || (commAlg == COMM_ALG_FULLMESH_V2)) {
102- OPS_LOG_D(context->GetNodeName(), "Do A5 mte gen task.");
103- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
104- } else if (commAlg == COMM_ALG_CCU) {
105- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU gen task.");
106- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
107- } else {
108- OPS_LOG_E(context->GetNodeName(), "Got unsupported commAlg %s.", commAlg.c_str());
109- return ge::GRAPH_FAILED;
110- }
111- }
112- OPS_LOG_D(context->GetNodeName(), "Do A3 gen task.");
113- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
114-}
115- 
116-IMPL_OP_CT(MoeDistributeDispatchV2)
117- .CalcOpParam(MoeDistributeDispatchV2CalcParamFunc)
118- .GenerateTask(MoeDistributeDispatchV2GenTaskFunc);
119-REGISTER_EXT_TASK_TYPE(MoeDistributeDispatchV2, fe::ExtTaskType::kAicoreTask);
120-#endif
121} // namespace ops69} // namespace ops
@@ -16,25 +16,15 @@
16#include <platform/platform_info.h>16#include <platform/platform_info.h>
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18 18 
19-#ifdef BUILD_OPEN_PROJECT
20#include "register/op_impl_registry.h"19#include "register/op_impl_registry.h"
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/mc2_gen_task_ops_utils_arch35.h"21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
23#include "op_graph/mc2_moe_gen_task_ops_utils.h"22#include "op_graph/mc2_moe_gen_task_ops_utils.h"
24#include "mc2_log.h"23#include "mc2_log.h"
25#include "mc2_platform_info.h"24#include "mc2_platform_info.h"
26-#else
27-#include "ops_error.h"
28-#include "register/op_ext_gentask_registry.h"
29-#include "register/op_ct_impl_registry.h"
30-#include "op_graph/mc2_gen_task_utils.h"
31-#include "mc2_gen_task_moe.h"
32-#include "op_graph/mc2_a5_gen_task_utils.h"
33-#endif
34 25 
35namespace ops {26namespace ops {
36 27 
37-#ifdef BUILD_OPEN_PROJECT
38 28 
39static ge::Status QuantAllReduceCalcOpParam(gert::ExeResGenerationContext *context)29static ge::Status QuantAllReduceCalcOpParam(gert::ExeResGenerationContext *context)
40{30{
@@ -61,38 +51,4 @@ static ge::Status QuantAllReduceGenTask(const gert::ExeResGenerationContext *con
61IMPL_OP(QuantAllReduce)51IMPL_OP(QuantAllReduce)
62 .CalcOpParam(QuantAllReduceCalcOpParam)52 .CalcOpParam(QuantAllReduceCalcOpParam)
63 .GenerateTask(QuantAllReduceGenTask);53 .GenerateTask(QuantAllReduceGenTask);
64- 
65-#else
66- 
67-static ge::Status QuantAllReduceCalcOpParam(gert::ExeResGenerationContext *context)
68-{
69- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
70- OPS_LOG_D(context->GetNodeName(), "Do A5 MTE CalcParam in QuantAllReduce");
71- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "mte server", "mte_stream");
72- }
73- const ge::AscendString name = "aicpu kfc server";
74- const ge::AscendString reuseKey = "kfc_stream";
75- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
76-}
77- 
78-static ge::Status QuantAllReduceGenTask(const gert::ExeResGenerationContext *context,
79- std::vector<std::vector<uint8_t>> &tasks)
80-{
81- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
82- OPS_LOG_D(context->GetNodeName(), "Do MTE general GenTask in QuantAllReduce");
83- // 这里调用moe的接口
84- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
85- }
86- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU GenTask in QuantAllReduce");
87- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
88-}
89- 
90-IMPL_OP_CT(QuantAllReduce)
91- .CalcOpParam(QuantAllReduceCalcOpParam)
92- .GenerateTask(QuantAllReduceGenTask);
93- 
94-REGISTER_EXT_TASK_TYPE(QuantAllReduce, fe::ExtTaskType::kAicoreTask);
95- 
96-#endif
97- 
98} // namespace ops54} // namespace ops
@@ -14,22 +14,14 @@
14 */14 */
15#include <vector>15#include <vector>
16 16 
17-#ifdef BUILD_OPEN_PROJECT
18#include "register/op_impl_registry.h"17#include "register/op_impl_registry.h"
19#include "mc2_log.h"18#include "mc2_log.h"
20#include "op_graph/mc2_gen_task_ops_utils.h"19#include "op_graph/mc2_gen_task_ops_utils.h"
21#include "op_graph/mc2_moe_gen_task_ops_utils.h"20#include "op_graph/mc2_moe_gen_task_ops_utils.h"
22#include "op_graph/mc2_gen_task_ops_utils_arch35.h"21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
23#include "mc2_platform_info.h"22#include "mc2_platform_info.h"
24-#else
25-#include "op_graph/mc2_a5_gen_task_utils.h"
26-#include "register/op_ct_impl_registry.h"
27-#include "mc2_gen_task_training.h"
28-#include "op_graph/mc2_gen_task_utils.h"
29-#endif
30 23 
31namespace ops {24namespace ops {
32-#ifdef BUILD_OPEN_PROJECT
33ge::Status QuantGroupedMatMulAlltoAllvCalcParamFunc(gert::ExeResGenerationContext *context)25ge::Status QuantGroupedMatMulAlltoAllvCalcParamFunc(gert::ExeResGenerationContext *context)
34{26{
35 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {27 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -55,28 +47,4 @@ ge::Status QuantGroupedMatMulAlltoAllvGenTaskFunc(const gert::ExeResGenerationCo
55IMPL_OP(QuantGroupedMatMulAlltoAllv)47IMPL_OP(QuantGroupedMatMulAlltoAllv)
56 .CalcOpParam(QuantGroupedMatMulAlltoAllvCalcParamFunc)48 .CalcOpParam(QuantGroupedMatMulAlltoAllvCalcParamFunc)
57 .GenerateTask(QuantGroupedMatMulAlltoAllvGenTaskFunc);49 .GenerateTask(QuantGroupedMatMulAlltoAllvGenTaskFunc);
58-#else // mc2 gen task utils
59-ge::Status QuantGroupedMatMulAlltoAllvCalcParamFunc(gert::ExeResGenerationContext *context)
60-{
61- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
62- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "ccu server", "ccu_stream");
63- }
64- const ge::AscendString name = "aicpu kfc server";
65- const ge::AscendString reuseKey = "kfc_stream";
66- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
67-}
68- 
69-ge::Status QuantGroupedMatMulAlltoAllvGenTaskFunc(const gert::ExeResGenerationContext *context,
70- std::vector<std::vector<uint8_t>> &tasks)
71-{
72- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
73- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
74- }
75- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskTraining::Mc2TrainingGenTaskCallback);
76-}
77- 
78-IMPL_OP_CT(QuantGroupedMatMulAlltoAllv)
79- .CalcOpParam(QuantGroupedMatMulAlltoAllvCalcParamFunc)
80- .GenerateTask(QuantGroupedMatMulAlltoAllvGenTaskFunc);
81-#endif
82} // namespace ops50} // namespace ops
@@ -16,26 +16,15 @@
16#include <platform/platform_info.h>16#include <platform/platform_info.h>
17#include "common/utils/op_mc2.h"17#include "common/utils/op_mc2.h"
18 18
19-#ifdef BUILD_OPEN_PROJECT
20#include "register/op_impl_registry.h"19#include "register/op_impl_registry.h"
21#include "op_graph/mc2_gen_task_ops_utils.h"20#include "op_graph/mc2_gen_task_ops_utils.h"
22#include "op_graph/mc2_gen_task_ops_utils_arch35.h"21#include "op_graph/mc2_gen_task_ops_utils_arch35.h"
23#include "op_graph/mc2_moe_gen_task_ops_utils.h"22#include "op_graph/mc2_moe_gen_task_ops_utils.h"
24#include "mc2_log.h"23#include "mc2_log.h"
25#include "mc2_platform_info.h"24#include "mc2_platform_info.h"
26-#else
27-#include "ops_error.h"
28-#include "register/op_ext_gentask_registry.h"
29-#include "register/op_ct_impl_registry.h"
30-#include "op_graph/mc2_gen_task_utils.h"
31-#include "mc2_gen_task_moe.h"
32-#include "op_graph/mc2_a5_gen_task_utils.h"
33-#endif
34 25 
35namespace ops {26namespace ops {
36 27 
37-#ifdef BUILD_OPEN_PROJECT
38- 
39static ge::Status QuantReduceScatterCalcOpParam(gert::ExeResGenerationContext *context)28static ge::Status QuantReduceScatterCalcOpParam(gert::ExeResGenerationContext *context)
40{29{
41 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {30 if (IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
@@ -61,38 +50,4 @@ static ge::Status QuantReduceScatterGenTask(const gert::ExeResGenerationContext
61IMPL_OP(QuantReduceScatter)50IMPL_OP(QuantReduceScatter)
62 .CalcOpParam(QuantReduceScatterCalcOpParam)51 .CalcOpParam(QuantReduceScatterCalcOpParam)
63 .GenerateTask(QuantReduceScatterGenTask);52 .GenerateTask(QuantReduceScatterGenTask);
64- 
65-#else
66- 
67-static ge::Status QuantReduceScatterCalcOpParam(gert::ExeResGenerationContext *context)
68-{
69- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
70- OPS_LOG_D(context->GetNodeName(), "Do A5 MTE CalcParam in QuantReduceScatter");
71- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, "mte server", "mte_stream");
72- }
73- const ge::AscendString name = "aicpu kfc server";
74- const ge::AscendString reuseKey = "kfc_stream";
75- return Mc2GenTaskUtils::CommonKFCMc2CalcParamFunc(context, name, reuseKey);
76-}
77- 
78-static ge::Status QuantReduceScatterGenTask(const gert::ExeResGenerationContext *context,
79- std::vector<std::vector<uint8_t>> &tasks)
80-{
81- if (Mc2A5GenTaskUtils::IsTargetPlatformNpuArch(context->GetNodeName(), NPUARCH_A5)) {
82- OPS_LOG_D(context->GetNodeName(), "Do MTE general GenTask in QuantReduceScatter");
83- // 这里调用moe的接口
84- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2GenTaskMoe::Mc2MoeGenTaskCallbackV2);
85- }
86- OPS_LOG_D(context->GetNodeName(), "Do A5 CCU GenTask in QuantReduceScatter");
87- return Mc2GenTaskUtils::CommonKFCMc2GenTask(context, tasks, Mc2A5GenTaskUtils::Mc2GenTaskCallBack910A5);
88-}
89- 
90-IMPL_OP_CT(QuantReduceScatter)
91- .CalcOpParam(QuantReduceScatterCalcOpParam)
92- .GenerateTask(QuantReduceScatterGenTask);
93- 
94-REGISTER_EXT_TASK_TYPE(QuantReduceScatter, fe::ExtTaskType::kAicoreTask);
95- 
96-#endif
97- 
98} // namespace ops53} // namespace ops