Merged
【PR】feat:support conv2D & support dynamic shape for matmul #2689
xuyafeiAdd on May 9
【PR】feat:support conv2D & support dynamic shape for matmul #2689
Merged
xuyafeiAdd on May 9
Total: 46 files changed+8895-406
@@ -103,7 +103,7 @@ class LoadAscIrCodegenImpl : public AscIrCodegen {
103 std::string GetApiName() const override {103 std::string GetApiName() const override {
104 return "Load";104 return "Load";
105 }105 }
106- std::vector<std::string> LoadApiHeaderFiles() const override {106+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
107 return {"datacopy.h"};107 return {"datacopy.h"};
108 }108 }
109 std::vector<std::string> IncludeApiHeaderFiles() const override {109 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -128,7 +128,7 @@ class BroadcastAscIrCodegenImpl : public AscIrCodegen {
128 std::string GetApiName() const override {128 std::string GetApiName() const override {
129 return "Broadcast";129 return "Broadcast";
130 }130 }
131- std::vector<std::string> LoadApiHeaderFiles() const override {131+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
132 return {"duplicate.h", "broadcast.h"};132 return {"duplicate.h", "broadcast.h"};
133 }133 }
134 std::vector<std::string> IncludeApiHeaderFiles() const override {134 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -167,7 +167,7 @@ class CastAscIrCodegenImpl : public AscIrCodegen {
167 std::string GetApiName() const override {167 std::string GetApiName() const override {
168 return "Cast";168 return "Cast";
169 }169 }
170- std::vector<std::string> LoadApiHeaderFiles() const override {170+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
171 return {"cast.h"};171 return {"cast.h"};
172 }172 }
173 std::vector<std::string> IncludeApiHeaderFiles() const override {173 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -198,7 +198,7 @@ class AbsAscIrCodegenImpl : public AscIrCodegen {
198 (void) abs_node;198 (void) abs_node;
199 return true;199 return true;
200 }200 }
201- std::vector<std::string> LoadApiHeaderFiles() const override {201+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
202 return {"abs.h"};202 return {"abs.h"};
203 }203 }
204 std::vector<std::string> IncludeApiHeaderFiles() const override {204 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -251,7 +251,7 @@ class RemovePadAscIrCodegenImpl : public AscIrCodegen {
251 std::string GetApiName() const override {251 std::string GetApiName() const override {
252 return "RemovePad";252 return "RemovePad";
253 }253 }
254- std::vector<std::string> LoadApiHeaderFiles() const override {254+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
255 return {"removepad.h"};255 return {"removepad.h"};
256 }256 }
257 std::vector<std::string> IncludeApiHeaderFiles() const override {257 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -357,7 +357,7 @@ class RsqrtAscIrCodegenImpl : public AscIrCodegen {
357 std::string GetApiName() const override {357 std::string GetApiName() const override {
358 return "RsqrtExtend";358 return "RsqrtExtend";
359 }359 }
360- std::vector<std::string> LoadApiHeaderFiles() const override {360+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
361 return {"rsqrt.h"};361 return {"rsqrt.h"};
362 }362 }
363 bool IsInplaceSupported(const ge::AscNode &rsqrt_node) const override {363 bool IsInplaceSupported(const ge::AscNode &rsqrt_node) const override {
@@ -443,7 +443,7 @@ class ReciprocalAscIrCodegenImpl : public AscIrCodegen {
443 std::string GetApiName() const override {443 std::string GetApiName() const override {
444 return "ReciprocalExtend";444 return "ReciprocalExtend";
445 }445 }
446- std::vector<std::string> LoadApiHeaderFiles() const override {446+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
447 return {"reciprocal.h"};447 return {"reciprocal.h"};
448 }448 }
449 bool IsInplaceSupported(const ge::AscNode &reciprocal_node) const override {449 bool IsInplaceSupported(const ge::AscNode &reciprocal_node) const override {
@@ -476,7 +476,7 @@ class SignAscIrCodegenImpl : public AscIrCodegen {
476 std::string GetApiName() const override {476 std::string GetApiName() const override {
477 return "SignExtend";477 return "SignExtend";
478 }478 }
479- std::vector<std::string> LoadApiHeaderFiles() const override {479+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
480 return {"cast.h", "sign.h"};480 return {"cast.h", "sign.h"};
481 }481 }
482 std::vector<std::string> IncludeApiHeaderFiles() const override {482 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -506,7 +506,7 @@ class IsnanAscIrCodegenImpl : public AscIrCodegen {
506 std::string GetApiName() const override {506 std::string GetApiName() const override {
507 return "IsnanExtend";507 return "IsnanExtend";
508 }508 }
509- std::vector<std::string> LoadApiHeaderFiles() const override {509+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
510 return {"isnan.h"};510 return {"isnan.h"};
511 }511 }
512 std::vector<std::string> IncludeApiHeaderFiles() const override {512 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -537,7 +537,7 @@ class IsFiniteAscIrCodegenImpl : public AscIrCodegen {
537 std::string GetApiName() const override {537 std::string GetApiName() const override {
538 return "IsFiniteExtend";538 return "IsFiniteExtend";
539 }539 }
540- std::vector<std::string> LoadApiHeaderFiles() const override {540+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
541 return {"isfinite.h"};541 return {"isfinite.h"};
542 }542 }
543 std::vector<std::string> IncludeApiHeaderFiles() const override {543 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -569,7 +569,7 @@ class LogicalNotAscIrCodegenImpl : public AscIrCodegen {
569 std::string GetApiName() const override {569 std::string GetApiName() const override {
570 return "LogicalNot";570 return "LogicalNot";
571 }571 }
572- std::vector<std::string> LoadApiHeaderFiles() const override {572+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
573 return {"logical_not.h"};573 return {"logical_not.h"};
574 }574 }
575 bool IsInplaceSupported(const ge::AscNode &not_node) const override {575 bool IsInplaceSupported(const ge::AscNode &not_node) const override {
@@ -603,7 +603,7 @@ class MaxAscIrCodegenImpl : public AscIrCodegen {
603 std::string GetApiName() const override {603 std::string GetApiName() const override {
604 return "Max";604 return "Max";
605 }605 }
606- std::vector<std::string> LoadApiHeaderFiles() const override {606+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
607 return {"reduce_init.h", "reduce.h"};607 return {"reduce_init.h", "reduce.h"};
608 }608 }
609 std::vector<std::string> IncludeApiHeaderFiles() const override {609 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -635,7 +635,7 @@ class ArgMaxAscIrCodegenImpl : public AscIrCodegen {
635 std::string GetApiName() const override {635 std::string GetApiName() const override {
636 return "ArgMax";636 return "ArgMax";
637 }637 }
638- std::vector<std::string> LoadApiHeaderFiles() const override {638+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
639 return {"reduce_init.h", "reduce.h", "argmax.h", "compare.h", "compare_v2.h", "duplicate.h", "where.h", "argmax_with_value.h"};639 return {"reduce_init.h", "reduce.h", "argmax.h", "compare.h", "compare_v2.h", "duplicate.h", "where.h", "argmax_with_value.h"};
640 }640 }
641 std::vector<std::string> IncludeApiHeaderFiles() const override {641 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -662,7 +662,7 @@ class ArgMaxMultiRPhase1AscIrCodegenImpl : public AscIrCodegen {
662 std::string GetApiName() const override {662 std::string GetApiName() const override {
663 return "ArgMaxMultiRPhase1";663 return "ArgMaxMultiRPhase1";
664 }664 }
665- std::vector<std::string> LoadApiHeaderFiles() const override {665+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
666 return {"reduce_init.h", "reduce.h", "argmax.h", "compare.h", "compare_v2.h", "duplicate.h", "where.h", "argmax_with_value.h"};666 return {"reduce_init.h", "reduce.h", "argmax.h", "compare.h", "compare_v2.h", "duplicate.h", "where.h", "argmax_with_value.h"};
667 }667 }
668 std::vector<std::string> IncludeApiHeaderFiles() const override {668 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -689,7 +689,7 @@ class ArgMaxMultiRPhase2AscIrCodegenImpl : public AscIrCodegen {
689 std::string GetApiName() const override {689 std::string GetApiName() const override {
690 return "ArgMaxMultiRPhase2";690 return "ArgMaxMultiRPhase2";
691 }691 }
692- std::vector<std::string> LoadApiHeaderFiles() const override {692+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
693 return {"reduce_init.h", "reduce.h", "argmax.h", "compare.h", "compare_v2.h", "duplicate.h", "where.h", "argmax_with_value.h"};693 return {"reduce_init.h", "reduce.h", "argmax.h", "compare.h", "compare_v2.h", "duplicate.h", "where.h", "argmax_with_value.h"};
694 }694 }
695 std::vector<std::string> IncludeApiHeaderFiles() const override {695 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -716,7 +716,7 @@ class SumAscIrCodegenImpl : public AscIrCodegen {
716 std::string GetApiName() const override {716 std::string GetApiName() const override {
717 return "Sum";717 return "Sum";
718 }718 }
719- std::vector<std::string> LoadApiHeaderFiles() const override {719+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
720 return {"reduce_init.h", "reduce.h"};720 return {"reduce_init.h", "reduce.h"};
721 }721 }
722 std::vector<std::string> IncludeApiHeaderFiles() const override {722 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -748,7 +748,7 @@ class MinAscIrCodegenImpl : public AscIrCodegen {
748 std::string GetApiName() const override {748 std::string GetApiName() const override {
749 return "Min";749 return "Min";
750 }750 }
751- std::vector<std::string> LoadApiHeaderFiles() const override {751+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
752 return {"reduce_init.h", "reduce.h"};752 return {"reduce_init.h", "reduce.h"};
753 }753 }
754 std::vector<std::string> IncludeApiHeaderFiles() const override {754 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -780,7 +780,7 @@ class MeanAscIrCodegenImpl : public AscIrCodegen {
780 std::string GetApiName() const override {780 std::string GetApiName() const override {
781 return "Mean";781 return "Mean";
782 }782 }
783- std::vector<std::string> LoadApiHeaderFiles() const override {783+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
784 return {"reduce_init.h", "reduce.h"};784 return {"reduce_init.h", "reduce.h"};
785 }785 }
786 std::vector<std::string> IncludeApiHeaderFiles() const override {786 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -812,7 +812,7 @@ class ProdAscIrCodegenImpl : public AscIrCodegen {
812 std::string GetApiName() const override {812 std::string GetApiName() const override {
813 return "Prod";813 return "Prod";
814 }814 }
815- std::vector<std::string> LoadApiHeaderFiles() const override {815+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
816 return {"reduce_init.h", "reduce.h"};816 return {"reduce_init.h", "reduce.h"};
817 }817 }
818 std::vector<std::string> IncludeApiHeaderFiles() const override {818 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -844,7 +844,7 @@ class AnyAscIrCodegenImpl : public AscIrCodegen {
844 std::string GetApiName() const override {844 std::string GetApiName() const override {
845 return "Any";845 return "Any";
846 }846 }
847- std::vector<std::string> LoadApiHeaderFiles() const override {847+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
848 return {"reduce_init.h", "reduce.h"};848 return {"reduce_init.h", "reduce.h"};
849 }849 }
850 std::vector<std::string> IncludeApiHeaderFiles() const override {850 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -876,7 +876,7 @@ class AllAscIrCodegenImpl : public AscIrCodegen {
876 std::string GetApiName() const override {876 std::string GetApiName() const override {
877 return "All";877 return "All";
878 }878 }
879- std::vector<std::string> LoadApiHeaderFiles() const override {879+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
880 return {"reduce_init.h", "reduce.h"};880 return {"reduce_init.h", "reduce.h"};
881 }881 }
882 std::vector<std::string> IncludeApiHeaderFiles() const override {882 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -908,7 +908,7 @@ class GeAscIrCodegenImpl : public AscIrCodegen {
908 std::string GetApiName() const override {908 std::string GetApiName() const override {
909 return "GE";909 return "GE";
910 }910 }
911- std::vector<std::string> LoadApiHeaderFiles() const override {911+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
912 return {"compare.h", "compare_v2.h"};912 return {"compare.h", "compare_v2.h"};
913 }913 }
914 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {914 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -953,7 +953,7 @@ class EqAscIrCodegenImpl : public AscIrCodegen {
953 std::string GetApiName() const override {953 std::string GetApiName() const override {
954 return "EQ";954 return "EQ";
955 }955 }
956- std::vector<std::string> LoadApiHeaderFiles() const override {956+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
957 return {"compare.h", "compare_v2.h"};957 return {"compare.h", "compare_v2.h"};
958 }958 }
959 std::vector<std::string> IncludeApiHeaderFiles() const override {959 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -987,7 +987,7 @@ class NeAscIrCodegenImpl : public AscIrCodegen {
987 std::string GetApiName() const override {987 std::string GetApiName() const override {
988 return "NE";988 return "NE";
989 }989 }
990- std::vector<std::string> LoadApiHeaderFiles() const override {990+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
991 return {"compare.h", "compare_v2.h"};991 return {"compare.h", "compare_v2.h"};
992 }992 }
993 bool IsScalarInputSupportedIfExchangeInputs(const std::vector<bool> &is_scalar_list) const override {993 bool IsScalarInputSupportedIfExchangeInputs(const std::vector<bool> &is_scalar_list) const override {
@@ -1028,7 +1028,7 @@ class GtAscIrCodegenImpl : public AscIrCodegen {
1028 std::string GetApiName() const override {1028 std::string GetApiName() const override {
1029 return "GT";1029 return "GT";
1030 }1030 }
1031- std::vector<std::string> LoadApiHeaderFiles() const override {1031+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1032 return {"compare.h", "compare_v2.h"};1032 return {"compare.h", "compare_v2.h"};
1033 }1033 }
1034 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1034 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1065,7 +1065,7 @@ class LeAscIrCodegenImpl : public AscIrCodegen {
1065 std::string GetApiName() const override {1065 std::string GetApiName() const override {
1066 return "LE";1066 return "LE";
1067 }1067 }
1068- std::vector<std::string> LoadApiHeaderFiles() const override {1068+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1069 return {"compare.h", "compare_v2.h"};1069 return {"compare.h", "compare_v2.h"};
1070 }1070 }
1071 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1071 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1102,7 +1102,7 @@ class LtAscIrCodegenImpl : public AscIrCodegen {
1102 std::string GetApiName() const override {1102 std::string GetApiName() const override {
1103 return "LT";1103 return "LT";
1104 }1104 }
1105- std::vector<std::string> LoadApiHeaderFiles() const override {1105+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1106 return {"compare.h", "compare_v2.h"};1106 return {"compare.h", "compare_v2.h"};
1107 }1107 }
1108 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1108 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1139,7 +1139,7 @@ class SigmoidAscIrCodegenImpl : public AscIrCodegen {
1139 std::string GetApiName() const override {1139 std::string GetApiName() const override {
1140 return "SigmoidExtend";1140 return "SigmoidExtend";
1141 }1141 }
1142- std::vector<std::string> LoadApiHeaderFiles() const override {1142+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1143 return {"sigmoid.h"};1143 return {"sigmoid.h"};
1144 }1144 }
1145 std::vector<std::string> IncludeApiHeaderFiles() const override {1145 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1191,7 +1191,7 @@ class DivAscIrCodegenImpl : public AscIrCodegen {
1191 std::string GetApiName() const override {1191 std::string GetApiName() const override {
1192 return "Div";1192 return "Div";
1193 }1193 }
1194- std::vector<std::string> LoadApiHeaderFiles() const override {1194+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1195 return {"scalar_div.h"};1195 return {"scalar_div.h"};
1196 }1196 }
1197 1197 
@@ -1232,7 +1232,7 @@ class SubAscIrCodegenImpl : public AscIrCodegen {
1232 std::string GetApiName() const override {1232 std::string GetApiName() const override {
1233 return "Sub";1233 return "Sub";
1234 }1234 }
1235- std::vector<std::string> LoadApiHeaderFiles() const override {1235+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1236 return {"scalar_sub.h"};1236 return {"scalar_sub.h"};
1237 }1237 }
1238 1238 
@@ -1270,7 +1270,7 @@ class AddAscIrCodegenImpl : public AscIrCodegen {
1270 std::string GetApiName() const override {1270 std::string GetApiName() const override {
1271 return "Add";1271 return "Add";
1272 }1272 }
1273- std::vector<std::string> LoadApiHeaderFiles() const override {1273+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1274 return {"scalar_add.h"};1274 return {"scalar_add.h"};
1275 }1275 }
1276 bool IsBrcInlineSupported(const ge::AscNode &node) const override {1276 bool IsBrcInlineSupported(const ge::AscNode &node) const override {
@@ -1309,7 +1309,7 @@ class MulAscIrCodegenImpl : public AscIrCodegen {
1309 std::string GetApiName() const override {1309 std::string GetApiName() const override {
1310 return "Mul";1310 return "Mul";
1311 }1311 }
1312- std::vector<std::string> LoadApiHeaderFiles() const override {1312+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1313 return {"scalar_mul.h"};1313 return {"scalar_mul.h"};
1314 }1314 }
1315 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1315 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1351,7 +1351,7 @@ class TrueDivAscIrCodegenImpl : public AscIrCodegen {
1351 std::string GetApiName() const override {1351 std::string GetApiName() const override {
1352 return "TrueDivExtend";1352 return "TrueDivExtend";
1353 }1353 }
1354- std::vector<std::string> LoadApiHeaderFiles() const override {1354+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1355 return {"scalar_div.h", "true_div.h"};1355 return {"scalar_div.h", "true_div.h"};
1356 }1356 }
1357 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1357 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1384,7 +1384,7 @@ class RemainderAscIrCodegenImpl : public AscIrCodegen {
1384 std::string GetApiName() const override {1384 std::string GetApiName() const override {
1385 return "RemainderExtend";1385 return "RemainderExtend";
1386 }1386 }
1387- std::vector<std::string> LoadApiHeaderFiles() const override {1387+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1388 return {"remainder.h"};1388 return {"remainder.h"};
1389 }1389 }
1390 std::vector<std::string> IncludeApiHeaderFiles() const override {1390 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1412,7 +1412,7 @@ class MinimumAscIrCodegenImpl : public AscIrCodegen {
1412 std::string GetApiName() const override {1412 std::string GetApiName() const override {
1413 return "AscendC::Min";1413 return "AscendC::Min";
1414 }1414 }
1415- std::vector<std::string> LoadApiHeaderFiles() const override {1415+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1416 return {"scalar_minimum.h"};1416 return {"scalar_minimum.h"};
1417 }1417 }
1418 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1418 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1451,7 +1451,7 @@ class MaximumAscIrCodegenImpl : public AscIrCodegen {
1451 std::string GetApiName() const override {1451 std::string GetApiName() const override {
1452 return "AscendC::Max";1452 return "AscendC::Max";
1453 }1453 }
1454- std::vector<std::string> LoadApiHeaderFiles() const override {1454+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1455 return {"scalar_maximum.h"};1455 return {"scalar_maximum.h"};
1456 }1456 }
1457 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1457 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1494,7 +1494,7 @@ class WhereAscIrCodegenImpl : public AscIrCodegen {
1494 std::string GetApiName() const override {1494 std::string GetApiName() const override {
1495 return "Where";1495 return "Where";
1496 }1496 }
1497- std::vector<std::string> LoadApiHeaderFiles() const override {1497+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1498 return {"duplicate.h", "where.h"};1498 return {"duplicate.h", "where.h"};
1499 }1499 }
1500 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1500 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1531,7 +1531,7 @@ class SelectAscIrCodegenImpl : public AscIrCodegen {
1531 std::string GetApiName() const override {1531 std::string GetApiName() const override {
1532 return "Select";1532 return "Select";
1533 }1533 }
1534- std::vector<std::string> LoadApiHeaderFiles() const override {1534+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1535 return {"duplicate.h", "where.h"};1535 return {"duplicate.h", "where.h"};
1536 }1536 }
1537 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1537 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1594,7 +1594,7 @@ class ClipByValueAscIrCodegenImpl : public AscIrCodegen {
1594 std::string GetApiName() const override {1594 std::string GetApiName() const override {
1595 return "ClipByValue";1595 return "ClipByValue";
1596 }1596 }
1597- std::vector<std::string> LoadApiHeaderFiles() const override {1597+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1598 return {"clipbyvalue.h"};1598 return {"clipbyvalue.h"};
1599 }1599 }
1600 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1600 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1624,7 +1624,7 @@ class StoreAscIrCodegenImpl : public AscIrCodegen {
1624 std::string GetApiName() const override {1624 std::string GetApiName() const override {
1625 return "Store";1625 return "Store";
1626 }1626 }
1627- std::vector<std::string> LoadApiHeaderFiles() const override {1627+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1628 return {"datacopy.h"};1628 return {"datacopy.h"};
1629 }1629 }
1630 std::vector<std::string> IncludeApiHeaderFiles() const override {1630 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1648,7 +1648,7 @@ class ConcatAscIrCodegenImpl : public AscIrCodegen {
1648 std::string GetApiName() const override {1648 std::string GetApiName() const override {
1649 return "Concat";1649 return "Concat";
1650 }1650 }
1651- std::vector<std::string> LoadApiHeaderFiles() const override {1651+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1652 return {"concat.h"};1652 return {"concat.h"};
1653 }1653 }
1654 std::vector<std::string> IncludeApiHeaderFiles() const override {1654 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1675,7 +1675,7 @@ class GatherAscIrCodegenImpl : public AscIrCodegen {
1675 std::string GetApiName() const override {1675 std::string GetApiName() const override {
1676 return "GatherExtend";1676 return "GatherExtend";
1677 }1677 }
1678- std::vector<std::string> LoadApiHeaderFiles() const override {1678+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1679 return {"gather.h"};1679 return {"gather.h"};
1680 }1680 }
1681 std::vector<std::string> IncludeApiHeaderFiles() const override {1681 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1707,7 +1707,7 @@ class TransposeAscIrCodegenImpl : public AscIrCodegen {
1707 std::string GetApiName() const override {1707 std::string GetApiName() const override {
1708 return "Transpose";1708 return "Transpose";
1709 }1709 }
1710- std::vector<std::string> LoadApiHeaderFiles() const override {1710+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1711 return {"transpose_base_type.h", "transpose.h"};1711 return {"transpose_base_type.h", "transpose.h"};
1712 }1712 }
1713 std::vector<std::string> IncludeApiHeaderFiles() const override {1713 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1811,7 +1811,7 @@ class LogicalOrAscIrCodegenImpl : public AscIrCodegen {
1811 std::string GetApiName() const override {1811 std::string GetApiName() const override {
1812 return "LogicalOr";1812 return "LogicalOr";
1813 }1813 }
1814- std::vector<std::string> LoadApiHeaderFiles() const override {1814+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1815 return {"logical.h"};1815 return {"logical.h"};
1816 }1816 }
1817 bool IsScalarInputSupportedIfExchangeInputs(const std::vector<bool> &is_scalar_list) const override {1817 bool IsScalarInputSupportedIfExchangeInputs(const std::vector<bool> &is_scalar_list) const override {
@@ -1847,7 +1847,7 @@ class LogicalAndAscIrCodegenImpl : public AscIrCodegen {
1847 std::string GetApiName() const override {1847 std::string GetApiName() const override {
1848 return "LogicalAnd";1848 return "LogicalAnd";
1849 }1849 }
1850- std::vector<std::string> LoadApiHeaderFiles() const override {1850+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1851 return {"logical.h"};1851 return {"logical.h"};
1852 }1852 }
1853 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1853 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1884,7 +1884,7 @@ class BitwiseAndAscIrCodegenImpl : public AscIrCodegen {
1884 std::string GetApiName() const override {1884 std::string GetApiName() const override {
1885 return "BitwiseAndExtend";1885 return "BitwiseAndExtend";
1886 }1886 }
1887- std::vector<std::string> LoadApiHeaderFiles() const override {1887+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1888 return {"bitwise_and.h"};1888 return {"bitwise_and.h"};
1889 }1889 }
1890 std::vector<std::string> IncludeApiHeaderFiles() const override {1890 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1913,7 +1913,7 @@ class FloorDivAscIrCodegenImpl : public AscIrCodegen {
1913 std::string GetApiName() const override {1913 std::string GetApiName() const override {
1914 return "FloorDivExtend";1914 return "FloorDivExtend";
1915 }1915 }
1916- std::vector<std::string> LoadApiHeaderFiles() const override {1916+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1917 return {"floor_div.h"};1917 return {"floor_div.h"};
1918 }1918 }
1919 std::vector<std::string> IncludeApiHeaderFiles() const override {1919 std::vector<std::string> IncludeApiHeaderFiles() const override {
@@ -1944,7 +1944,7 @@ class PowAscIrCodegenImpl : public AscIrCodegen {
1944 std::string GetApiName() const override {1944 std::string GetApiName() const override {
1945 return "Pow";1945 return "Pow";
1946 }1946 }
1947- std::vector<std::string> LoadApiHeaderFiles() const override {1947+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1948 return {"pow.h"};1948 return {"pow.h"};
1949 }1949 }
1950 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {1950 bool IsScalarInputSupported(const std::vector<bool> &is_scalar_list) const override {
@@ -1975,7 +1975,7 @@ class AxpyAscIrCodegenImpl : public AscIrCodegen {
1975 std::string GetApiName() const override {1975 std::string GetApiName() const override {
1976 return "AxpyExtend";1976 return "AxpyExtend";
1977 }1977 }
1978- std::vector<std::string> LoadApiHeaderFiles() const override {1978+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
1979 return {"axpy.h"};1979 return {"axpy.h"};
1980 }1980 }
1981 bool IsInplaceSupported(const ge::AscNode &axpy_node) const override {1981 bool IsInplaceSupported(const ge::AscNode &axpy_node) const override {
@@ -2006,11 +2006,18 @@ class MatMulAscIrCodegenImpl : public AscIrCodegen {
2006 std::string GetApiName() const override {2006 std::string GetApiName() const override {
2007 return "MatMul";2007 return "MatMul";
2008 }2008 }
2009- std::vector<std::string> LoadApiHeaderFiles() const override {2009+ std::vector<std::string> LoadApiHeaderFiles(bool is_dynamic) const override {
2010- return {"mat_mul_tiling_key.h",2010+ if (is_dynamic) {
2011- "matmul_include_headers.h",2011+ return {"mat_mul_tiling_key_dynamic.h",
2012- "mat_mul_pingpong_basic_cmct.h",2012+ "matmul_include_headers.h",
2013- "matmul.h"};2013+ "mat_mul_pingpong_basic_cmct_dynamic.h",
2014+ "matmul_dynamic.h"};
2015+ } else {
2016+ return {"mat_mul_tiling_key.h",
2017+ "matmul_include_headers.h",
2018+ "mat_mul_pingpong_basic_cmct.h",
2019+ "matmul.h"};
2020+ }
2014 }2021 }
2015 std::vector<std::string> IncludeApiHeaderFiles() const override {2022 std::vector<std::string> IncludeApiHeaderFiles() const override {
2016 return {2023 return {
@@ -2035,11 +2042,18 @@ class BatchMatMulAscIrCodegenImpl : public AscIrCodegen {
2035 std::string GetApiName() const override {2042 std::string GetApiName() const override {
2036 return "BatchMatMul";2043 return "BatchMatMul";
2037 }2044 }
2038- std::vector<std::string> LoadApiHeaderFiles() const override {2045+ std::vector<std::string> LoadApiHeaderFiles(bool is_dynamic) const override {
2039- return {"batch_mat_mul_v3_tiling_key.h",2046+ if (is_dynamic) {
2040- "batch_matmul_include_headers.h",2047+ return {"batch_mat_mul_v3_tiling_key_dynamic.h",
2041- "mat_mul_pingpong_basic_cmct.h",2048+ "batch_matmul_include_headers.h",
2042- "batch_matmul.h"};2049+ "mat_mul_pingpong_basic_cmct_dynamic.h",
2050+ "batch_matmul_dynamic.h"};
2051+ } else {
2052+ return {"batch_mat_mul_v3_tiling_key.h",
2053+ "batch_matmul_include_headers.h",
2054+ "mat_mul_pingpong_basic_cmct.h",
2055+ "batch_matmul.h"};
2056+ }
2043 }2057 }
2044 std::vector<std::string> IncludeApiHeaderFiles() const override {2058 std::vector<std::string> IncludeApiHeaderFiles() const override {
2045 return {2059 return {
@@ -2064,9 +2078,9 @@ class Conv2DAscIrCodegenImpl : public AscIrCodegen {
2064 std::string GetApiName() const override {2078 std::string GetApiName() const override {
2065 return "Conv2D";2079 return "Conv2D";
2066 }2080 }
2067- std::vector<std::string> LoadApiHeaderFiles() const override {2081+ std::vector<std::string> LoadApiHeaderFiles([[maybe_unused]] bool is_dynamic) const override {
2068 return {"conv2d_include_headers.h",2082 return {"conv2d_include_headers.h",
2069- "conv2d_v2_tilingkey.h",2083+ "conv2d_v2_tilingkey_cv.h",
2070 "conv_pingpong_basic_atcos.h",2084 "conv_pingpong_basic_atcos.h",
2071 "conv2d.h"};2085 "conv2d.h"};
2072 }2086 }
@@ -76,6 +76,7 @@ graphStatus CreateConvSubgraphAttr(const NodePtr &node, vector<const Node *> &co
76 conv_input_desc->SetFormat(data_format); // 2.conv节点的输入更新为与输出一致(filter输入会不一样,单算子执行时tiling会校验这个format一致)76 conv_input_desc->SetFormat(data_format); // 2.conv节点的输入更新为与输出一致(filter输入会不一样,单算子执行时tiling会校验这个format一致)
77 const auto new_shape = TransferShapeBetweenHwcnNchw(conv_input_desc->GetShape(), old_format, data_format);77 const auto new_shape = TransferShapeBetweenHwcnNchw(conv_input_desc->GetShape(), old_format, data_format);
78 conv_input_desc->SetShape(new_shape);78 conv_input_desc->SetShape(new_shape);
79+ conv_input_desc->SetOriginShape(new_shape);
79 const auto &src_anchor = node->GetInDataAnchor(i);80 const auto &src_anchor = node->GetInDataAnchor(i);
80 GE_ASSERT_NOTNULL(src_anchor);81 GE_ASSERT_NOTNULL(src_anchor);
81 auto peer_anchor = src_anchor->GetPeerOutAnchor();82 auto peer_anchor = src_anchor->GetPeerOutAnchor();
@@ -914,4 +914,4 @@ std::string AutofuseUtils::SimplifyNodeName(const std::string &node_name) {
914 return ProcessGeneralFormat(parts);914 return ProcessGeneralFormat(parts);
915 }915 }
916}916}
917-} // namespace ge917+} // namespace ge
@@ -19,6 +19,7 @@
19#include "common_utils.h"19#include "common_utils.h"
20#include "common/ge_common/debug/log.h"20#include "common/ge_common/debug/log.h"
21#include "codegen_infershape.h"21#include "codegen_infershape.h"
22+#include "common/platform_context.h"
22 23 
23using namespace codegen;24using namespace codegen;
24using namespace ascgen_utils;25using namespace ascgen_utils;
@@ -39,7 +40,17 @@ std::string GetKernelTaskType(const ascir::FusedScheduledResult &schedule_result
39 if (ascgen_utils::IsJustCubeFixpip(schedule_results)) {40 if (ascgen_utils::IsJustCubeFixpip(schedule_results)) {
40 return kKernelTaskTypeAICOnly;41 return kKernelTaskTypeAICOnly;
41 } else if (ascgen_utils::IsCubeFusedScheduled(schedule_results)) {42 } else if (ascgen_utils::IsCubeFusedScheduled(schedule_results)) {
42- return kKernelTaskTypeMixAICOneTwo;43+ if (ascgen_utils::IsConv2DFusedScheduled(schedule_results)) {
44+ std::string npu_arch;
45+ GE_ASSERT_SUCCESS(ge::PlatformContext::GetInstance().GetCurrentPlatformString(npu_arch));
46+ if (npu_arch == "5102") {
47+ return kKernelTaskTypeMixAICOneOne;
48+ } else {
49+ return kKernelTaskTypeMixAICOneTwo;
50+ }
51+ } else {
52+ return kKernelTaskTypeMixAICOneTwo;
53+ }
43 }54 }
44 return schedule_results.workspace_nodes.size() != 0 ? kKernelTaskTypeMixAIVOneZero : kKernelTaskTypeAIVOnly;55 return schedule_results.workspace_nodes.size() != 0 ? kKernelTaskTypeMixAIVOneZero : kKernelTaskTypeAIVOnly;
45}56}
@@ -384,7 +395,7 @@ std::string Codegen::GenGetKernelAndJson(const std::string &kernel_path, const s
384 ss << " std::vector<uint8_t> temp_kernel = {};" << std::endl;395 ss << " std::vector<uint8_t> temp_kernel = {};" << std::endl;
385 ss << " return;" << std::endl;396 ss << " return;" << std::endl;
386 } else {397 } else {
387- ss << " std::vector<uint8_t> temp_kernel = {";398+ ss << " static const uint8_t temp_kernel[] = {";
388 for (uint32_t i = 0; i < kernel_file_size; i++) {399 for (uint32_t i = 0; i < kernel_file_size; i++) {
389 if (i % ELEMENTS_PER_LINE == 0) {400 if (i % ELEMENTS_PER_LINE == 0) {
390 ss << std::endl << " ";401 ss << std::endl << " ";
@@ -393,8 +404,8 @@ std::string Codegen::GenGetKernelAndJson(const std::string &kernel_path, const s
393 }404 }
394 ss << "};" << std::endl;405 ss << "};" << std::endl;
395 406 
396- ss << " kernel_bin.resize(temp_kernel.size());" << std::endl;407+ ss << " kernel_bin.resize(sizeof(temp_kernel));" << std::endl;
397- ss << " std::memcpy(kernel_bin.data(), temp_kernel.data(), temp_kernel.size() * sizeof(uint8_t));" << std::endl;408+ ss << " std::memcpy(kernel_bin.data(), temp_kernel, sizeof(temp_kernel));" << std::endl;
398 }409 }
399 ss << "}";410 ss << "}";
400 return ss.str();411 return ss.str();
@@ -1143,8 +1143,12 @@ Status TPipe::InitTQueBuffers(const TQue &que, std::string &result) const {
1143 std::string blk_align;1143 std::string blk_align;
1144 GE_CHK_STATUS_RET(KernelUtils::BlkAlign(ge::DT_UINT8, blk_align), "Codegen blk align failed");1144 GE_CHK_STATUS_RET(KernelUtils::BlkAlign(ge::DT_UINT8, blk_align), "Codegen blk align failed");
1145 if (this->cv_fusion_type == ascir::CubeTemplateType::kUBFuse || !using_att_calc_qbt_size_) {1145 if (this->cv_fusion_type == ascir::CubeTemplateType::kUBFuse || !using_att_calc_qbt_size_) {
1146- ss << this->name << "."1146+ if (using_global_tpipe_) {
1147- << "InitBuffer(" << que << ", " << que.buf_num << ", " << blk_align << "(" << que.size << "));";1147+ ss << "GetTPipePtr()->InitBuffer(" << que << ", " << que.buf_num << ", " << blk_align << "(" << que.size << "));";
1148+ } else {
1149+ ss << this->name << "."
1150+ << "InitBuffer(" << que << ", " << que.buf_num << ", " << blk_align << "(" << que.size << "));";
1151+ }
1148 } else {1152 } else {
1149 ss << "// ";1153 ss << "// ";
1150 ss << this->name << "."1154 ss << this->name << "."
@@ -337,6 +337,7 @@ class TPipe : public Variable {
337 }337 }
338 Status BlkTensorAllocAndInit(std::string &result) const;338 Status BlkTensorAllocAndInit(std::string &result) const;
339 void SetUsingAttCalcQBTSizeConfig(bool using_att_calc_qbt_size);339 void SetUsingAttCalcQBTSizeConfig(bool using_att_calc_qbt_size);
340+ void SetUsingGlobalTpipe(bool using_global_tpipe);
340 Status GetCVFusionCubeOutputUBTensorIdAndQueId(const ascir::ImplGraph &graph);341 Status GetCVFusionCubeOutputUBTensorIdAndQueId(const ascir::ImplGraph &graph);
341 Status LocalTensorDefine(std::string &result) const;342 Status LocalTensorDefine(std::string &result) const;
342 std::string TensorSizeDefine() const;343 std::string TensorSizeDefine() const;
@@ -349,6 +350,7 @@ class TPipe : public Variable {
349 Status ParseTBufReuse(TBuf buf, std::string& reuse_dtype_name, bool& is_buf_reuse,350 Status ParseTBufReuse(TBuf buf, std::string& reuse_dtype_name, bool& is_buf_reuse,
350 std::vector<const Tensor *>& reuse_buf_tensors, std::stringstream &tensor_size_max) const;351 std::vector<const Tensor *>& reuse_buf_tensors, std::stringstream &tensor_size_max) const;
351 bool using_att_calc_qbt_size_ = true;352 bool using_att_calc_qbt_size_ = true;
353+ bool using_global_tpipe_ = false;
352};354};
353 355 
354struct CodegenConfig {356struct CodegenConfig {
@@ -410,12 +412,12 @@ class Kernel {
410 std::string GenTilingFuncCall(const std::string &impl_graph_name, const std::string &tiling_data) const;412 std::string GenTilingFuncCall(const std::string &impl_graph_name, const std::string &tiling_data) const;
411 std::string GenCubeTilingFuncCall(const ascir::ImplGraph &impl_graph) const;413 std::string GenCubeTilingFuncCall(const ascir::ImplGraph &impl_graph) const;
412 std::string GenCubeTilingSingleFuncCall(const bool is_batch, const bool is_cv_fuse, bool is_bias,414 std::string GenCubeTilingSingleFuncCall(const bool is_batch, const bool is_cv_fuse, bool is_bias,
413- bool is_offset_w) const;415+ bool is_offset_w, bool is_conv2d) const;
414- ge::Status GenCubeCommonTiling(std::stringstream &ss, const bool is_batch) const;416+ ge::Status GenCubeCommonTiling(std::stringstream &ss, const bool is_batch, bool is_conv2d = false) const;
415 std::string GenCubeCommonTilingSingleFuncCall(const ascir::ImplGraph &impl_graph) const;417 std::string GenCubeCommonTilingSingleFuncCall(const ascir::ImplGraph &impl_graph) const;
416 static std::string KernelFuncDeclare(const std::string &graph_name,418 static std::string KernelFuncDeclare(const std::string &graph_name,
417 const ascir::FusedScheduledResult &fused_schedule_result,419 const ascir::FusedScheduledResult &fused_schedule_result,
418- bool use_list_tensor = false, bool is_inductor = false);420+ bool use_list_tensor = false, bool is_inductor = false, bool is_conv2d = false);
419 Status GlobalTensorInit(std::string &result) const;421 Status GlobalTensorInit(std::string &result) const;
420 Status GlobalTensorAssign(std::string &result) const;422 Status GlobalTensorAssign(std::string &result) const;
421 Status GlobalTensorDefine(std::string &result) const;423 Status GlobalTensorDefine(std::string &result) const;
@@ -429,13 +431,13 @@ class Kernel {
429 Status ParseScalarNeedGenBlkTensors(const ascir::NodeView &node, ascir::TensorId id);431 Status ParseScalarNeedGenBlkTensors(const ascir::NodeView &node, ascir::TensorId id);
430 Status OutputTensorIsUbScalar(const ascir::NodeView &node, bool &is_ub_scalar) const;432 Status OutputTensorIsUbScalar(const ascir::NodeView &node, bool &is_ub_scalar) const;
431 Status GenerateKernelByNode(const ascir::ImplGraph &graph, std::stringstream &ss,433 Status GenerateKernelByNode(const ascir::ImplGraph &graph, std::stringstream &ss,
432- std::unordered_set<const std::string *> &kernel_file_ptr);434+ std::unordered_set<const std::string *> &kernel_file_ptr, bool is_dynamic);
433 Status GenerateMacro(std::stringstream &ss);435 Status GenerateMacro(std::stringstream &ss);
434 Status GenerateSubGraphFuncDef(const Loop *loop, std::stringstream &ss) const;436 Status GenerateSubGraphFuncDef(const Loop *loop, std::stringstream &ss) const;
435 void SetUsingAttCalcQBTSizeConfig(bool using_att_calc_qbt_size);437 void SetUsingAttCalcQBTSizeConfig(bool using_att_calc_qbt_size);
436 void SetEnableParallelCompile(bool enable_parallel_compile);438 void SetEnableParallelCompile(bool enable_parallel_compile);
437 bool GetEnableParallelCompile() const;439 bool GetEnableParallelCompile() const;
438- Status GenerateVecFuncOfCVFusion(std::stringstream &result, bool vector_no_db_flag);440+ Status GenerateVecFuncOfCVFusion(std::stringstream &result, bool vector_no_db_flag, bool is_conv2d);
439 Status InitCVFusionAddr(std::stringstream &result, bool vector_no_db_flag);441 Status InitCVFusionAddr(std::stringstream &result, bool vector_no_db_flag);
440 static std::string GenKernelFuncCallForInductor(const ascir::FusedScheduledResult &fused_schedule_result);442 static std::string GenKernelFuncCallForInductor(const ascir::FusedScheduledResult &fused_schedule_result);
441 Status ParseUbScalarOptimizationInfo(const ascir::NodeView& node, Tensor& t, ascir::TensorId id, bool is_all_link_vf);443 Status ParseUbScalarOptimizationInfo(const ascir::NodeView& node, Tensor& t, ascir::TensorId id, bool is_all_link_vf);
@@ -32,6 +32,7 @@
32#include "graph/utils/type_utils.h"32#include "graph/utils/type_utils.h"
33#include "backend/backend_spec.h"33#include "backend/backend_spec.h"
34#include "common/ascgraph_info_complete.h"34#include "common/ascgraph_info_complete.h"
35+#include "codegen_tiling_cube_wrapper.h"
35 36 
36namespace codegen {37namespace codegen {
37using optimize::AscGraphInfoComplete;38using optimize::AscGraphInfoComplete;
@@ -13,6 +13,7 @@
13#include <sstream>13#include <sstream>
14#include "ascir.h"14#include "ascir.h"
15#include "schedule_result.h"15#include "schedule_result.h"
16+#include "ascgen_log.h"
16 17 
17namespace codegen {18namespace codegen {
18const std::string kTilingHeadIdentify = "TilingHead";19const std::string kTilingHeadIdentify = "TilingHead";
@@ -24,6 +25,53 @@ const std::string kTilingHeadEndGuard = "#endif";
24const std::string kTilingHeadTilingContext = "#include \"exe_graph/runtime/tiling_context.h\"";25const std::string kTilingHeadTilingContext = "#include \"exe_graph/runtime/tiling_context.h\"";
25const std::string kTilingDefAndConstIdentify = "tiling_def_and_tiling_const";26const std::string kTilingDefAndConstIdentify = "tiling_def_and_tiling_const";
26const std::string kCubeTilingHeadInclude = "#include \"autofuse_cube_tiling_data.h\"";27const std::string kCubeTilingHeadInclude = "#include \"autofuse_cube_tiling_data.h\"";
28+const std::string kCubeKernelTilingWrapperHpp = "CubeKernelTilingWrapperHpp";
29+const std::string kCubeKernelTilingWrapperCpp = "CubeKernelTilingWrapperCpp";
30+const std::string kCubeKernelTilingWrapperInclude = "#include \"cube_kernel_tiling_wrapper.h\"";
31+ 
32+struct MatMulCubeInfo {
33+ bool transpose_x1 = false;
34+ bool transpose_x2 = false;
35+ int32_t offset_x = 0;
36+ int64_t enable_hf32 = false;
37+ bool is_batch = false;
38+ bool has_relu = false;
39+ uint32_t input_num = 0U;
40+ uint32_t type_size = 4U;
41+ ge::AscNodePtr matmul_node = nullptr;
42+};
43+ 
44+struct TensorInfo {
45+ std::string param_name;
46+ std::vector<ge::Expression> shape;
47+ std::vector<ge::Expression> ori_shape;
48+ std::string dtype;
49+ std::string format;
50+ std::string name;
51+};
52+ 
53+struct AttrInfo {
54+ std::string name;
55+ std::string dtype;
56+ std::string value_str;
57+ bool value_bool = false;
58+ int64_t value_int = 0;
59+ double value_float = 0.0;
60+ std::vector<int64_t> value_list_int;
61+ std::vector<double> value_list_float;
62+ std::vector<std::string> value_list_str;
63+ bool is_list = false;
64+};
65+ 
66+struct CompileInfo {
67+ std::string soc_version;
68+ std::string core_type;
69+ std::string op_kernel_lib;
70+ std::string op_impl_mode;
71+ int64_t aicore_num = 0;
72+ int64_t aiv_num = 0;
73+ std::map<std::string, std::string> extra_info;
74+};
27 75 
28 using TilingLibCodegenFunc = bool (*)(const std::string &op_name,76 using TilingLibCodegenFunc = bool (*)(const std::string &op_name,
29 const ::ascir::FusedScheduledResult& fused_schedule_result,77 const ::ascir::FusedScheduledResult& fused_schedule_result,
@@ -190,13 +238,44 @@ const std::string kCubeTilingHeadInclude = "#include \"autofuse_cube_tiling_data
190 std::string GenGetTilingKeyKernelTypeForStatic(const ::ascir::FusedScheduledResult &fused_schedule_result) const;238 std::string GenGetTilingKeyKernelTypeForStatic(const ::ascir::FusedScheduledResult &fused_schedule_result) const;
191 std::string GenCVTilingFunc() const;239 std::string GenCVTilingFunc() const;
192 std::string GenTilingDataBlockDimAndWss() const;240 std::string GenTilingDataBlockDimAndWss() const;
241+ void AppendCVFusionHeaders(std::stringstream &ss, bool is_static) const;
242+ std::map<std::string, std::string> GenerateCVFusionStatic(
243+ const ::ascir::FusedScheduledResult &elemwise_schedule_result,
244+ const std::map<std::string, std::string> &shape_info, const std::string &pgo_dir,
245+ const std::string &core_num) const;
246+ std::map<std::string, std::string> GenerateCVFusionDynamic(
247+ const ::ascir::FusedScheduledResult &fused_schedule_result,
248+ const ::ascir::FusedScheduledResult &elemwise_schedule_result,
249+ const std::map<std::string, std::string> &shape_info, const std::string &pgo_dir,
250+ const std::string &core_num) const;
193 std::map<std::string, std::string> GenerateCVFusion(const ::ascir::FusedScheduledResult &fused_schedule_result,251 std::map<std::string, std::string> GenerateCVFusion(const ::ascir::FusedScheduledResult &fused_schedule_result,
194 const std::map<std::string, std::string> &shape_info,252 const std::map<std::string, std::string> &shape_info,
195 const std::string &pgo_dir, const std::string &core_num) const;253 const std::string &pgo_dir, const std::string &core_num) const;
254+ std::string GenCubeFusionTilingBody(const ::ascir::FusedScheduledResult &fused_schedule_result,
255+ const std::string &shape_dim_param) const;
256+ std::string GenNonCubeFusionTilingBody(const ::ascir::FusedScheduledResult &fused_schedule_result,
257+ const std::string &tiling, const std::string &shape_dim_param) const;
196 std::string GenExternTilingFuncBody(const ::ascir::FusedScheduledResult &fused_schedule_result,258 std::string GenExternTilingFuncBody(const ::ascir::FusedScheduledResult &fused_schedule_result,
197 const std::map<std::string, std::string> &shape_info, const std::string &tiling,259 const std::map<std::string, std::string> &shape_info, const std::string &tiling,
198 const std::string &pgo_dir) const;260 const std::string &pgo_dir) const;
199 std::string GenAscirTilingAndLaunchFunc(const ::ascir::FusedScheduledResult &fused_schedule_result) const;261 std::string GenAscirTilingAndLaunchFunc(const ::ascir::FusedScheduledResult &fused_schedule_result) const;
262+ Status ExtractMatMulCubeInfoFromImplGraph(const ge::AscGraph &impl_graph, MatMulCubeInfo &cube_info) const;
263+ Status ExtractMatMulCubeInfoFromFusedResult(const ::ascir::FusedScheduledResult &fused_schedule_result,
264+ MatMulCubeInfo &cube_info) const;
265+ Status GetInputTensorInfoFromLoadNode(const ge::NodePtr &load_node, TensorInfo &tensor_info) const;
266+ Status ExtractInputsFromMatMulNode(const ge::AscNodePtr &matmul_node, std::vector<TensorInfo> &inputs) const;
267+ Status ExtractOutputsFromMatMulNode(const ge::AscNodePtr &matmul_node, std::vector<TensorInfo> &outputs) const;
268+ std::string GenerateTensorInfoCode(const TensorInfo &tensor, const std::string &var_name) const;
269+ std::string GenerateAttrInfoCode(const AttrInfo &attr, const std::string &var_name) const;
270+ void PrepareMatMulAttrs(const MatMulCubeInfo &cube_info, std::vector<AttrInfo> &attrs) const;
271+ void GenerateTensorListCode(std::stringstream &code_ss, const std::vector<TensorInfo> &inputs,
272+ const std::vector<TensorInfo> &outputs) const;
273+ void GenerateTilingCallCode(std::stringstream &code_ss, bool is_batch) const;
274+ std::string GenerateMatMulTilingCode(const CompileInfo &compile_info, const std::vector<TensorInfo> &inputs,
275+ const std::vector<TensorInfo> &outputs, const std::vector<AttrInfo> &attrs,
276+ bool is_batch) const;
277+ std::string ProcessCubeKernelTilingFromFusedResult(
278+ const ::ascir::FusedScheduledResult &fused_schedule_result) const;
200 TilingLibCodegenFunc codegen_func_{nullptr};279 TilingLibCodegenFunc codegen_func_{nullptr};
201 bool enable_autofuse_pgo_{false};280 bool enable_autofuse_pgo_{false};
202 };281 };
@@ -732,7 +732,7 @@ bool IsCubeType(const ascir::ImplGraph &impl_graph) {
732 return false;732 return false;
733}733}
734 734 
735-bool IsCubeTypeWithBatch(const ascir::ImplGraph &impl_graph) {735+bool IsMatMulTypeWithBatch(const ascir::ImplGraph &impl_graph) {
736 for (const auto &node : impl_graph.GetAllNodes()) {736 for (const auto &node : impl_graph.GetAllNodes()) {
737 if ((node->GetType() == kBatchMatMul) || (node->GetType() == kBatchMatMulBias) ||737 if ((node->GetType() == kBatchMatMul) || (node->GetType() == kBatchMatMulBias) ||
738 (node->GetType() == kBatchMatMulOffset) || (node->GetType() == kBatchMatMulOffsetBias)) {738 (node->GetType() == kBatchMatMulOffset) || (node->GetType() == kBatchMatMulOffsetBias)) {
@@ -742,7 +742,7 @@ bool IsCubeTypeWithBatch(const ascir::ImplGraph &impl_graph) {
742 return false;742 return false;
743}743}
744 744 
745-bool IsCubeTypeWithBias(const ascir::ImplGraph &impl_graph) {745+bool IsMatMulTypeWithBias(const ascir::ImplGraph &impl_graph) {
746 for (const auto &node : impl_graph.GetAllNodes()) {746 for (const auto &node : impl_graph.GetAllNodes()) {
747 if ((node->GetType() == kMatMulBias) || (node->GetType() == kBatchMatMulBias) ||747 if ((node->GetType() == kMatMulBias) || (node->GetType() == kBatchMatMulBias) ||
748 (node->GetType() == kMatMulOffsetBias) || (node->GetType() == kBatchMatMulOffsetBias)) {748 (node->GetType() == kMatMulOffsetBias) || (node->GetType() == kBatchMatMulOffsetBias)) {
@@ -752,7 +752,7 @@ bool IsCubeTypeWithBias(const ascir::ImplGraph &impl_graph) {
752 return false;752 return false;
753}753}
754 754 
755-bool IsCubeTypeWithOffsetW(const ascir::ImplGraph &impl_graph) {755+bool IsMatMulTypeWithOffsetW(const ascir::ImplGraph &impl_graph) {
756 for (const auto &node : impl_graph.GetAllNodes()) {756 for (const auto &node : impl_graph.GetAllNodes()) {
757 if ((node->GetType() == kMatMulOffset) || (node->GetType() == kBatchMatMulOffset) ||757 if ((node->GetType() == kMatMulOffset) || (node->GetType() == kBatchMatMulOffset) ||
758 (node->GetType() == kMatMulOffsetBias) || (node->GetType() == kBatchMatMulOffsetBias)) {758 (node->GetType() == kMatMulOffsetBias) || (node->GetType() == kBatchMatMulOffsetBias)) {
@@ -762,6 +762,56 @@ bool IsCubeTypeWithOffsetW(const ascir::ImplGraph &impl_graph) {
762 return false;762 return false;
763}763}
764 764 
765+bool IsConv2DTypeWithBias(const ascir::ImplGraph &impl_graph) {
766+ for (const auto &node : impl_graph.GetAllNodes()) {
767+ if ((node->GetType() == kConv2DBias) || (node->GetType() == kConv2DOffsetBias)) {
768+ return true;
769+ }
770+ }
771+ return false;
772+}
773+ 
774+bool IsConv2DTypeWithOffsetW(const ascir::ImplGraph &impl_graph) {
775+ for (const auto &node : impl_graph.GetAllNodes()) {
776+ if ((node->GetType() == kConv2DOffset) || (node->GetType() == kConv2DOffsetBias)) {
777+ return true;
778+ }
779+ }
780+ return false;
781+}
782+ 
783+bool IsConv2DGraphType(const ascir::ImplGraph &impl_graph) {
784+ for (const auto &node : impl_graph.GetAllNodes()) {
785+ if ((node->GetType() == kConv2DOffset) || (node->GetType() == kConv2DOffsetBias) ||
786+ (node->GetType() == kConv2DBias) || (node->GetType() == kConv2D)) {
787+ return true;
788+ }
789+ }
790+ return false;
791+}
792+ 
793+bool IsConv2DFusedScheduled(const ascir::FusedScheduledResult &fused_schedule_result) {
794+ auto check_conv2d_in_impl_graphs = [](const auto &schedule_groups) {
795+ for (const auto &schedule_group : schedule_groups) {
796+ for (const auto &impl_graph : schedule_group.impl_graphs) {
797+ if (IsConv2DGraphType(impl_graph)) {
798+ return true;
799+ }
800+ }
801+ }
802+ return false;
803+ };
804+ 
805+ for (const auto &scheduled_results : fused_schedule_result.node_idx_to_scheduled_results) {
806+ for (const auto &scheduled_result : scheduled_results) {
807+ if (check_conv2d_in_impl_graphs(scheduled_result.schedule_groups)) {
808+ return true;
809+ }
810+ }
811+ }
812+ return false;
813+}
814+ 
765bool IsCubeGroupType(const ascir::ScheduleGroup &sched_group) {815bool IsCubeGroupType(const ascir::ScheduleGroup &sched_group) {
766 for (const auto &impl_graph : sched_group.impl_graphs) {816 for (const auto &impl_graph : sched_group.impl_graphs) {
767 if (IsCubeType(impl_graph)) {817 if (IsCubeType(impl_graph)) {
@@ -775,7 +825,7 @@ bool IsSatetyResultType(const ascir::ScheduledResult &sched_result) {
775 return sched_result.cube_type == ascir::CubeTemplateType::kCommon;825 return sched_result.cube_type == ascir::CubeTemplateType::kCommon;
776}826}
777 827 
778-ge::Status GetMutmulOutputTypeSize(const ascir::NodeView &node, uint32_t &length) {828+ge::Status GetCubeOutputTypeSize(const ascir::NodeView &node, uint32_t &length) {
779 if (node->attr.api.compute_type == ge::ComputeType::kComputeCube) {829 if (node->attr.api.compute_type == ge::ComputeType::kComputeCube) {
780 GE_ASSERT_TRUE(node->outputs().size() > 0U);830 GE_ASSERT_TRUE(node->outputs().size() > 0U);
781 for (const auto output : node->outputs()) {831 for (const auto output : node->outputs()) {
@@ -786,7 +836,7 @@ ge::Status GetMutmulOutputTypeSize(const ascir::NodeView &node, uint32_t &length
786 return ge::FAILED;836 return ge::FAILED;
787}837}
788 838 
789-ge::Status GetMutmulInputNum(const ascir::NodeView &node, uint32_t &num) {839+ge::Status GetCubeInputNum(const ascir::NodeView &node, uint32_t &num) {
790 if (node->attr.api.compute_type == ge::ComputeType::kComputeCube) {840 if (node->attr.api.compute_type == ge::ComputeType::kComputeCube) {
791 num = node->inputs().size();841 num = node->inputs().size();
792 GE_ASSERT_TRUE(num > 1U);842 GE_ASSERT_TRUE(num > 1U);
@@ -829,12 +879,31 @@ ge::Status ParseMatmulAttr(const ascir::NodeView &node, MatMulAttr &mm_attr_data
829 return ge::SUCCESS;879 return ge::SUCCESS;
830}880}
831 881 
882+ge::Status ParseConv2DAttr(const ascir::NodeView &node, Conv2DAttr &conv_attr_data) {
883+ if (node->GetType() == kConv2D) {
884+ GET_CONV2D_ATTRS(node, Conv2D, conv_attr_data);
885+ } else if (node->GetType() == kConv2DBias) {
886+ GET_CONV2D_ATTRS(node, Conv2DBias, conv_attr_data);
887+ conv_attr_data.is_bias = true;
888+ } else if (node->GetType() == kConv2DOffset) {
889+ GET_CONV2D_ATTRS(node, Conv2DOffset, conv_attr_data);
890+ conv_attr_data.is_offset_w = true;
891+ } else if (node->GetType() == kConv2DOffsetBias) {
892+ GET_CONV2D_ATTRS(node, Conv2DOffsetBias, conv_attr_data);
893+ conv_attr_data.is_bias = true;
894+ conv_attr_data.is_offset_w = true;
895+ } else {
896+ GELOGE(ge::FAILED, "can't parse conv2d node attr, type=%s", node->GetType().c_str());
897+ }
898+ return ge::SUCCESS;
899+}
900+ 
832ge::Status UpdateAttGroup(ascir::ScheduledResult &scheduled_result,901ge::Status UpdateAttGroup(ascir::ScheduledResult &scheduled_result,
833 std::function<void(ge::AscGraph &)> update_graph_axis) {902 std::function<void(ge::AscGraph &)> update_graph_axis) {
834 for (auto &group : scheduled_result.schedule_groups) {903 for (auto &group : scheduled_result.schedule_groups) {
835 std::vector<ge::AscGraph> impl_graphs_tmp;904 std::vector<ge::AscGraph> impl_graphs_tmp;
836 for (auto &impl_graph : group.impl_graphs) {905 for (auto &impl_graph : group.impl_graphs) {
837- auto new_graph_name = impl_graph.GetName() + "_for_matmul";906+ auto new_graph_name = impl_graph.GetName() + "_for_cube";
838 ge::AscGraph att_graph(new_graph_name.c_str());907 ge::AscGraph att_graph(new_graph_name.c_str());
839 att_graph.CopyFrom(impl_graph);908 att_graph.CopyFrom(impl_graph);
840 update_graph_axis(att_graph);909 update_graph_axis(att_graph);
@@ -28,6 +28,7 @@ namespace ascgen_utils {
28 const std::string kKernelTaskTypeMixAIVOneZero = "KERNEL_TYPE_MIX_AIV_1_0";28 const std::string kKernelTaskTypeMixAIVOneZero = "KERNEL_TYPE_MIX_AIV_1_0";
29 const std::string kKernelTaskTypeAICOnly = "KERNEL_TYPE_AIC_ONLY";29 const std::string kKernelTaskTypeAICOnly = "KERNEL_TYPE_AIC_ONLY";
30 const std::string kKernelTaskTypeMixAICOneTwo = "KERNEL_TYPE_MIX_AIC_1_2";30 const std::string kKernelTaskTypeMixAICOneTwo = "KERNEL_TYPE_MIX_AIC_1_2";
31+ const std::string kKernelTaskTypeMixAICOneOne = "KERNEL_TYPE_MIX_AIC_1_1";
31 32 
32 const std::string kMatMul = "MatMul";33 const std::string kMatMul = "MatMul";
33 const std::string kMatMulBias = "MatMulBias";34 const std::string kMatMulBias = "MatMulBias";
@@ -37,6 +38,10 @@ namespace ascgen_utils {
37 const std::string kBatchMatMulBias = "BatchMatMulBias";38 const std::string kBatchMatMulBias = "BatchMatMulBias";
38 const std::string kBatchMatMulOffset = "BatchMatMulOffset";39 const std::string kBatchMatMulOffset = "BatchMatMulOffset";
39 const std::string kBatchMatMulOffsetBias = "BatchMatMulOffsetBias";40 const std::string kBatchMatMulOffsetBias = "BatchMatMulOffsetBias";
41+ const std::string kConv2D = "Conv2D";
42+ const std::string kConv2DBias = "Conv2DBias";
43+ const std::string kConv2DOffset = "Conv2DOffset";
44+ const std::string kConv2DOffsetBias = "Conv2DOffsetBias";
40 45 
41 struct MatMulAttr {46 struct MatMulAttr {
42 int64_t transpose_x1{0};47 int64_t transpose_x1{0};
@@ -56,6 +61,21 @@ namespace ascgen_utils {
56 std::string k;61 std::string k;
57 };62 };
58 63 
64+ struct Conv2DAttr {
65+ std::vector<int64_t> strides;
66+ std::vector<int64_t> pads;
67+ std::vector<int64_t> dilations;
68+ int64_t groups{1};
69+ std::string pad_mode{"SPECIFIC"};
70+ std::string data_format{"NCHW"};
71+ int64_t offset_x{0};
72+ bool enable_hf32{false};
73+ bool is_bias{false};
74+ bool is_offset_w{false};
75+ std::string output_dtype;
76+ std::string input_dtype;
77+ };
78+ 
59#define GET_MATMUL_ATTRS(Node, AttrType, AttrData) \79#define GET_MATMUL_ATTRS(Node, AttrType, AttrData) \
60 auto mm_attr = node->attr.ir_attr->DownCastTo<ge::ascir_op::AttrType::Asc##AttrType##IrAttrDef>(); \80 auto mm_attr = node->attr.ir_attr->DownCastTo<ge::ascir_op::AttrType::Asc##AttrType##IrAttrDef>(); \
61 GE_ASSERT_NOTNULL(mm_attr); \81 GE_ASSERT_NOTNULL(mm_attr); \
@@ -74,6 +94,18 @@ namespace ascgen_utils {
74 GE_ASSERT_SUCCESS(mm_attr->GetAdj_x1(AttrData.adj_x1)); \94 GE_ASSERT_SUCCESS(mm_attr->GetAdj_x1(AttrData.adj_x1)); \
75 GE_ASSERT_SUCCESS(mm_attr->GetAdj_x2(AttrData.adj_x2));95 GE_ASSERT_SUCCESS(mm_attr->GetAdj_x2(AttrData.adj_x2));
76 96 
97+#define GET_CONV2D_ATTRS(Node, AttrType, AttrData) \
98+ auto conv_attr = node->attr.ir_attr->DownCastTo<ge::ascir_op::AttrType::Asc##AttrType##IrAttrDef>(); \
99+ GE_ASSERT_NOTNULL(conv_attr); \
100+ GE_ASSERT_SUCCESS(conv_attr->GetStrides(AttrData.strides)); \
101+ GE_ASSERT_SUCCESS(conv_attr->GetPads(AttrData.pads)); \
102+ GE_ASSERT_SUCCESS(conv_attr->GetDilations(AttrData.dilations)); \
103+ GE_ASSERT_SUCCESS(conv_attr->GetGroups(AttrData.groups)); \
104+ GE_ASSERT_SUCCESS(conv_attr->GetPad_mode(AttrData.pad_mode)); \
105+ GE_ASSERT_SUCCESS(conv_attr->GetData_format(AttrData.data_format)); \
106+ GE_ASSERT_SUCCESS(conv_attr->GetOffset_x(AttrData.offset_x)); \
107+ GE_ASSERT_SUCCESS(conv_attr->GetEnable_hf32(AttrData.enable_hf32))
108+ 
77 struct MergeBrcAxisParams {109 struct MergeBrcAxisParams {
78 const std::vector<ge::Expression> &repeats;110 const std::vector<ge::Expression> &repeats;
79 const std::vector<ge::Expression> &strides;111 const std::vector<ge::Expression> &strides;
@@ -98,8 +130,9 @@ namespace ascgen_utils {
98 bool IsEmptyTensorSence(const ascir::FusedScheduledResult& fused_schedule_result);130 bool IsEmptyTensorSence(const ascir::FusedScheduledResult& fused_schedule_result);
99 131 
100 template <typename T>132 template <typename T>
101- static std::string VectorToStr(const std::vector<T> &vec) {133+ static std::string VectorToStr(const std::vector<T> &vec, char start = '[', char end = ']') {
102- std::string result = "[";134+ std::string result;
135+ result += start;
103 for (size_t i = 0; i < vec.size(); ++i) {136 for (size_t i = 0; i < vec.size(); ++i) {
104 if constexpr (std::is_same<T, ge::Expression>::value) {137 if constexpr (std::is_same<T, ge::Expression>::value) {
105 result += (vec[i].Str().get());138 result += (vec[i].Str().get());
@@ -110,7 +143,7 @@ namespace ascgen_utils {
110 result += ", ";143 result += ", ";
111 }144 }
112 }145 }
113- result += "]";146+ result += end;
114 return result;147 return result;
115 }148 }
116 ge::Expression GetTensorSize(const ge::AscTensor &tensor);149 ge::Expression GetTensorSize(const ge::AscTensor &tensor);
@@ -186,20 +219,25 @@ namespace ascgen_utils {
186 bool HasCubeUBFusedScheduled(const ascir::FusedScheduledResult &fused_schedule_result);219 bool HasCubeUBFusedScheduled(const ascir::FusedScheduledResult &fused_schedule_result);
187 bool HasCubeCommonFusedScheduled(const ascir::FusedScheduledResult &fused_schedule_result);220 bool HasCubeCommonFusedScheduled(const ascir::FusedScheduledResult &fused_schedule_result);
188 bool IsCubeType(const ascir::ImplGraph &impl_graph);221 bool IsCubeType(const ascir::ImplGraph &impl_graph);
189- bool IsCubeTypeWithBatch(const ascir::ImplGraph &impl_graph);222+ bool IsMatMulTypeWithBatch(const ascir::ImplGraph &impl_graph);
190- bool IsCubeTypeWithBias(const ascir::ImplGraph &impl_graph);223+ bool IsMatMulTypeWithBias(const ascir::ImplGraph &impl_graph);
191- bool IsCubeTypeWithOffsetW(const ascir::ImplGraph &impl_graph);224+ bool IsMatMulTypeWithOffsetW(const ascir::ImplGraph &impl_graph);
192 ge::Status ParseMatmulAttr(const ascir::NodeView &node, MatMulAttr &mm_attr_data);225 ge::Status ParseMatmulAttr(const ascir::NodeView &node, MatMulAttr &mm_attr_data);
193 bool IsCubeGroupType(const ascir::ScheduleGroup &sched_group);226 bool IsCubeGroupType(const ascir::ScheduleGroup &sched_group);
194 bool IsSatetyResultType(const ascir::ScheduledResult &sched_result);227 bool IsSatetyResultType(const ascir::ScheduledResult &sched_result);
195- ge::Status GetMutmulOutputTypeSize(const ascir::NodeView &node, uint32_t &length);228+ ge::Status GetCubeOutputTypeSize(const ascir::NodeView &node, uint32_t &length);
196- ge::Status GetMutmulInputNum(const ascir::NodeView &node, uint32_t &num);229+ ge::Status GetCubeInputNum(const ascir::NodeView &node, uint32_t &num);
197 ge::Status CreateCVFusionResult(ascir::FusedScheduledResult &elemwise_schedule_result);230 ge::Status CreateCVFusionResult(ascir::FusedScheduledResult &elemwise_schedule_result);
198 ge::Status CreateCVFusionCommonResult(ascir::FusedScheduledResult &elemwise_schedule_result);231 ge::Status CreateCVFusionCommonResult(ascir::FusedScheduledResult &elemwise_schedule_result);
199 bool IsCVFusionUBGraph(const ascir::ImplGraph &impl_graph, ascir::CubeTemplateType cv_fusion_type);232 bool IsCVFusionUBGraph(const ascir::ImplGraph &impl_graph, ascir::CubeTemplateType cv_fusion_type);
200 ge::Status FilterCVFusionUBResult(ascir::FusedScheduledResult &ub_schedule_result);233 ge::Status FilterCVFusionUBResult(ascir::FusedScheduledResult &ub_schedule_result);
201 ge::Status FilterCVFusionCommonResult(ascir::FusedScheduledResult &common_schedule_result);234 ge::Status FilterCVFusionCommonResult(ascir::FusedScheduledResult &common_schedule_result);
202 ge::Status DtypeName(ge::DataType dtype, std::string &dtype_name);235 ge::Status DtypeName(ge::DataType dtype, std::string &dtype_name);
236+ bool IsConv2DFusedScheduled(const ascir::FusedScheduledResult &fused_schedule_result);
237+ ge::Status ParseConv2DAttr(const ascir::NodeView &node, Conv2DAttr &conv_attr_data);
238+ bool IsConv2DGraphType(const ascir::ImplGraph &impl_graph);
239+ bool IsConv2DTypeWithBias(const ascir::ImplGraph &impl_graph);
240+ bool IsConv2DTypeWithOffsetW(const ascir::ImplGraph &impl_graph);
203} // namespace ascgen_utils241} // namespace ascgen_utils
204 242 
205#endif243#endif
@@ -22,6 +22,8 @@
22#include "pyascir_types.h"22#include "pyascir_types.h"
23#include "common/common_utils.h"23#include "common/common_utils.h"
24 24 
25+using ascir::ImplGraph;
26+ 
25/** SizeExpr */27/** SizeExpr */
26namespace pyascir {28namespace pyascir {
27// 生成推导dtype的映射29// 生成推导dtype的映射
@@ -930,44 +932,105 @@ PyTypeObject ShapeInfo::type = {PyVarObject_HEAD_INIT(nullptr, 0)};
930 932 
931/** FusedScheduledResult */933/** FusedScheduledResult */
932namespace pyascir {934namespace pyascir {
935+static bool ProcessMatMulNode(const ge::AscNodePtr &node, PyObject *attr_dict) {
936+ ascgen_utils::MatMulAttr mm_attr_data;
937+ PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::ParseMatmulAttr(node, mm_attr_data));
938+ uint32_t length = 0U;
939+ PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::GetCubeOutputTypeSize(node, length));
940+ 
941+ PyDict_SetItemString(attr_dict, "has_relu", (mm_attr_data.has_relu != 0) ? Py_True : Py_False);
942+ PyDict_SetItemString(attr_dict, "is_batch", mm_attr_data.is_batch ? Py_True : Py_False);
943+ PyDict_SetItemString(attr_dict, "transpose_x1",
944+ ((mm_attr_data.transpose_x1 != 0) || (mm_attr_data.adj_x1 != 0)) ? Py_True : Py_False);
945+ PyDict_SetItemString(attr_dict, "transpose_x2",
946+ ((mm_attr_data.transpose_x2 != 0) || (mm_attr_data.adj_x2 != 0)) ? Py_True : Py_False);
947+ SET_DICT_LONG(attr_dict, "offset_x", mm_attr_data.offset_x);
948+ if (mm_attr_data.is_batch) {
949+ PyDict_SetItemString(attr_dict, "enable_hf32", mm_attr_data.enable_hf32 != 0 ? Py_True : Py_False);
950+ } else {
951+ SET_DICT_LONG(attr_dict, "enable_hf32", mm_attr_data.enable_hf32);
952+ }
953+ SET_DICT_LONG(attr_dict, "type_size", length);
954+ uint32_t mm_input_num = 0U;
955+ PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::GetCubeInputNum(node, mm_input_num));
956+ SET_DICT_LONG(attr_dict, "input_num", mm_input_num);
957+ return true;
958+}
959+ 
960+static bool ProcessConv2DNode(const ge::AscNodePtr &node, PyObject *attr_dict) {
961+ ascgen_utils::Conv2DAttr conv_attr_data;
962+ PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::ParseConv2DAttr(node, conv_attr_data));
963+ uint32_t length = 0U;
964+ PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::GetCubeOutputTypeSize(node, length));
965+ 
966+ PyObject *strides_list = PyList_New(conv_attr_data.strides.size());
967+ PY_ASSERT_NOTNULL(strides_list, "strides_list is not ready");
968+ for (size_t i = 0; i < conv_attr_data.strides.size(); ++i) {
969+ PyList_SetItem(strides_list, i, PyLong_FromLong(conv_attr_data.strides[i]));
970+ }
971+ PyDict_SetItemString(attr_dict, "strides", strides_list);
972+ Py_DECREF(strides_list);
973+ 
974+ PyObject *pads_list = PyList_New(conv_attr_data.pads.size());
975+ PY_ASSERT_NOTNULL(pads_list, "pads_list is not ready");
976+ for (size_t i = 0; i < conv_attr_data.pads.size(); ++i) {
977+ PyList_SetItem(pads_list, i, PyLong_FromLong(conv_attr_data.pads[i]));
978+ }
979+ PyDict_SetItemString(attr_dict, "pads", pads_list);
980+ Py_DECREF(pads_list);
981+ 
982+ PyObject *dilations_list = PyList_New(conv_attr_data.dilations.size());
983+ PY_ASSERT_NOTNULL(dilations_list, "dilations_list is not ready");
984+ for (size_t i = 0; i < conv_attr_data.dilations.size(); ++i) {
985+ PyList_SetItem(dilations_list, i, PyLong_FromLong(conv_attr_data.dilations[i]));
986+ }
987+ PyDict_SetItemString(attr_dict, "dilations", dilations_list);
988+ Py_DECREF(dilations_list);
989+ 
990+ SET_DICT_LONG(attr_dict, "groups", conv_attr_data.groups);
991+ PyDict_SetItemString(attr_dict, "pad_mode", PyUnicode_FromString(conv_attr_data.pad_mode.c_str()));
992+ PyDict_SetItemString(attr_dict, "data_format", PyUnicode_FromString(conv_attr_data.data_format.c_str()));
993+ SET_DICT_LONG(attr_dict, "offset_x", conv_attr_data.offset_x);
994+ PyDict_SetItemString(attr_dict, "enable_hf32", conv_attr_data.enable_hf32 ? Py_True : Py_False);
995+ PyDict_SetItemString(attr_dict, "is_bias", conv_attr_data.is_bias ? Py_True : Py_False);
996+ PyDict_SetItemString(attr_dict, "is_offset_w", conv_attr_data.is_offset_w ? Py_True : Py_False);
997+ PyDict_SetItemString(attr_dict, "output_dtype", PyUnicode_FromString(conv_attr_data.output_dtype.c_str()));
998+ PyDict_SetItemString(attr_dict, "input_dtype", PyUnicode_FromString(conv_attr_data.input_dtype.c_str()));
999+ SET_DICT_LONG(attr_dict, "type_size", length);
1000+ uint32_t conv_input_num = 0U;
1001+ PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::GetCubeInputNum(node, conv_input_num));
1002+ SET_DICT_LONG(attr_dict, "input_num", conv_input_num);
1003+ std::string npu_arch;
1004+ PY_ASSERT_SUCCESS(ge::PlatformContext::GetInstance().GetCurrentPlatformString(npu_arch),
1005+ "Failed to get npu_arch");
1006+ PyDict_SetItemString(attr_dict, "npu_arch", PyUnicode_FromString(npu_arch.c_str()));
1007+ return true;
1008+}
1009+ 
933static bool ProcessImplGraphs(PyObject *result_dict, const std::vector<ge::AscGraph> &impl_graphs) {1010static bool ProcessImplGraphs(PyObject *result_dict, const std::vector<ge::AscGraph> &impl_graphs) {
934 for (auto &impl_graph : impl_graphs) {1011 for (auto &impl_graph : impl_graphs) {
935 for (auto node : impl_graph.GetAllNodes()) {1012 for (auto node : impl_graph.GetAllNodes()) {
936 if (node->attr.api.compute_type != ge::ComputeType::kComputeCube) {1013 if (node->attr.api.compute_type != ge::ComputeType::kComputeCube) {
937 continue;1014 continue;
938 }1015 }
939- ascgen_utils::MatMulAttr mm_attr_data;
940- PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::ParseMatmulAttr(node, mm_attr_data));
941- uint32_t length = 0U;
942- PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::GetMutmulOutputTypeSize(node, length));
943 PyObject *attr_dict = PyDict_New();1016 PyObject *attr_dict = PyDict_New();
944 PY_ASSERT_NOTNULL(attr_dict, "attr_dict is not ready");1017 PY_ASSERT_NOTNULL(attr_dict, "attr_dict is not ready");
945 1018 
946- // 创建守卫,确保在发生异常时释放attr_dict
947 GE_DISMISSABLE_GUARD(attr_dict_guard, [attr_dict]() { Py_DECREF(attr_dict); });1019 GE_DISMISSABLE_GUARD(attr_dict_guard, [attr_dict]() { Py_DECREF(attr_dict); });
948 1020 
949- PyDict_SetItemString(attr_dict, "has_relu", (mm_attr_data.has_relu != 0) ? Py_True : Py_False);1021+ if (ascgen_utils::IsConv2DGraphType(impl_graph)) {
950- PyDict_SetItemString(attr_dict, "is_batch", mm_attr_data.is_batch ? Py_True : Py_False);1022+ if (!ProcessConv2DNode(node, attr_dict)) {
951- PyDict_SetItemString(attr_dict, "transpose_x1",1023+ return false;
952- ((mm_attr_data.transpose_x1 != 0) || (mm_attr_data.adj_x1 != 0)) ? Py_True : Py_False);1024+ }
953- PyDict_SetItemString(attr_dict, "transpose_x2",
954- ((mm_attr_data.transpose_x2 != 0) || (mm_attr_data.adj_x2 != 0)) ? Py_True : Py_False);
955- SET_DICT_LONG(attr_dict, "offset_x", mm_attr_data.offset_x);
956- if (mm_attr_data.is_batch) {
957- PyDict_SetItemString(attr_dict, "enable_hf32", mm_attr_data.enable_hf32 != 0 ? Py_True : Py_False);
958 } else {1025 } else {
959- SET_DICT_LONG(attr_dict, "enable_hf32", mm_attr_data.enable_hf32);1026+ if (!ProcessMatMulNode(node, attr_dict)) {
1027+ return false;
1028+ }
960 }1029 }
961- SET_DICT_LONG(attr_dict, "type_size", length);
962- uint32_t mm_input_num = 0U;
963- PY_ASSERT_GRAPH_SUCCESS(ascgen_utils::GetMutmulInputNum(node, mm_input_num));
964- SET_DICT_LONG(attr_dict, "input_num", mm_input_num);
965- // 将属性字典添加到结果中
966 PyDict_SetItemString(result_dict, "cube_attributes", attr_dict);1030 PyDict_SetItemString(result_dict, "cube_attributes", attr_dict);
967 1031 
968 GE_DISMISS_GUARD(attr_dict_guard);1032 GE_DISMISS_GUARD(attr_dict_guard);
969 Py_DECREF(attr_dict);1033 Py_DECREF(attr_dict);
970- // 如果只需要第一个cube节点,可以break,后续要处理多个cube节点时,删除这里
971 return true;1034 return true;
972 }1035 }
973 }1036 }
@@ -1011,6 +1074,18 @@ PyObject *FusedScheduledResult::GetOutputNum(PyObject *self_pyobject) {
1011 return PyLong_FromLong(output_num);1074 return PyLong_FromLong(output_num);
1012}1075}
1013 1076 
1077+PyObject *FusedScheduledResult::IsConvType(PyObject *self_pyobject) {
1078+ auto self = reinterpret_cast<FusedScheduledResult::Object *>(self_pyobject);
1079+ if (self == nullptr) {
1080+ return Py_False;
1081+ }
1082+ if (ascgen_utils::IsConv2DFusedScheduled(self->fused_schedule_result)) {
1083+ return Py_True;
1084+ }
1085+ 
1086+ return Py_False;
1087+}
1088+ 
1014PyObject *FusedScheduledResult::IsCubeType(PyObject *self_pyobject) {1089PyObject *FusedScheduledResult::IsCubeType(PyObject *self_pyobject) {
1015 auto self = reinterpret_cast<FusedScheduledResult::Object *>(self_pyobject);1090 auto self = reinterpret_cast<FusedScheduledResult::Object *>(self_pyobject);
1016 if (self == nullptr) {1091 if (self == nullptr) {
@@ -1064,6 +1139,8 @@ PyMethodDef FusedScheduledResult::methods[] = {
1064 "Check cube type"},1139 "Check cube type"},
1065 {"get_cube_attributes", reinterpret_cast<PyCFunction>(FusedScheduledResult::GetCubeAttributes), METH_NOARGS,1140 {"get_cube_attributes", reinterpret_cast<PyCFunction>(FusedScheduledResult::GetCubeAttributes), METH_NOARGS,
1066 "Get cube attributes"},1141 "Get cube attributes"},
1142+ {"is_conv_type", reinterpret_cast<PyCFunction>(FusedScheduledResult::IsConvType), METH_NOARGS,
1143+ "Check conv type"},
1067 {nullptr}};1144 {nullptr}};
1068 1145 
1069PyTypeObject FusedScheduledResult::type = {PyVarObject_HEAD_INIT(nullptr, 0)};1146PyTypeObject FusedScheduledResult::type = {PyVarObject_HEAD_INIT(nullptr, 0)};
@@ -186,6 +186,7 @@ class FusedScheduledResult {
186 static PyObject* GetName(PyObject *self_pyobject);186 static PyObject* GetName(PyObject *self_pyobject);
187 static PyObject* IsCubeType(PyObject *self_pyobject);187 static PyObject* IsCubeType(PyObject *self_pyobject);
188 static PyObject* GetCubeAttributes(PyObject *self_pyobject);188 static PyObject* GetCubeAttributes(PyObject *self_pyobject);
189+ static PyObject* IsConvType(PyObject *self_pyobject);
189};190};
190 191 
191#define SET_DICT_LONG(dict, key, value) do { \192#define SET_DICT_LONG(dict, key, value) do { \
@@ -65,6 +65,8 @@ def generate_cmake_lists(asc_graph_name, kernel_name, host_build_dir, is_last_co
65 source += f"file(GLOB ALL_CPP_SRCS\n"65 source += f"file(GLOB ALL_CPP_SRCS\n"
66 source += f" *tiling_func*.cpp\n"66 source += f" *tiling_func*.cpp\n"
67 source += f" *infershape*.cpp\n"67 source += f" *infershape*.cpp\n"
68+ if not is_static_shape and is_cube:
69+ source += f" cube_kernel_tiling_wrapper.cpp\n"
68 if is_last_compile:70 if is_last_compile:
69 source += f" *get_kernel*.cpp\n"71 source += f" *get_kernel*.cpp\n"
70 source += ")\n\n"72 source += ")\n\n"
@@ -91,7 +91,7 @@ def _build_args(args_list, input_num, output_num):
91 return _origin_inputs_, _origin_outputs_, _inputs_, _outputs_91 return _origin_inputs_, _origin_outputs_, _inputs_, _outputs_
92 92 
93 93 
94-def _join_path(options, asc_path, is_cube):94+def _join_path(options, asc_path, is_cube, is_conv):
95 options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))95 options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
96 options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))96 options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
97 options.append("-I" + os.path.join(asc_path, "impl", "utils"))97 options.append("-I" + os.path.join(asc_path, "impl", "utils"))
@@ -111,25 +111,32 @@ def _join_path(options, asc_path, is_cube):
111 options.append("-I" + os.path.join(asc_path, "..", "ascendc", "include"))111 options.append("-I" + os.path.join(asc_path, "..", "ascendc", "include"))
112 options.append("-I" + os.path.join(asc_path, "..", "asc", "include", "tiling"))112 options.append("-I" + os.path.join(asc_path, "..", "asc", "include", "tiling"))
113 if is_cube:113 if is_cube:
114- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",114+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
115- "ascendc", "common"))115+ "impl", "ascendc", "common"))
116- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",116+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
117- "ascendc", "common", "cmct"))117+ "impl", "ops_nn", "ascendc", "common"))
118- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",118+ if (is_conv):
119- "ascendc", "mat_mul_v3"))119+ # conv2d
120- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",120+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
121- "ascendc", "batch_mat_mul_v3"))121+ "impl", "ascendc", "conv2d_v2"))
122- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",122+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
123- "ops_nn", "ascendc", "common"))123+ "impl", "ops_nn", "ascendc", "conv2d_v2"))
124- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",124+ else:
125- "ops_nn", "ascendc", "common", "cmct"))125+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
126- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",126+ "impl", "ascendc", "mat_mul_v3"))
127- "ops_nn", "ascendc", "mat_mul_v3"))127+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
128- options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe", "impl",128+ "impl", "ascendc", "batch_mat_mul_v3"))
129- "ops_nn", "ascendc", "batch_mat_mul_v3"))129+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
130+ "impl", "ops_nn", "ascendc", "mat_mul_v3"))
131+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
132+ "impl", "ops_nn", "ascendc", "batch_mat_mul_v3"))
133+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
134+ "impl", "ascendc", "common", "cmct"))
135+ options.append("-I" + os.path.join(asc_path, "..", "..", "opp", "built-in", "op_impl", "ai_core", "tbe",
136+ "impl", "ops_nn", "ascendc", "common", "cmct"))
130 137 
131 138 
132-def _build_options(temp_build_dir, impl_mode, is_cube):139+def _build_options(temp_build_dir, impl_mode, is_cube, is_conv):
133 options = ["-x", "cce"]140 options = ["-x", "cce"]
134 ascend_home_path = os.environ.get('ASCEND_HOME_PATH')141 ascend_home_path = os.environ.get('ASCEND_HOME_PATH')
135 import platform142 import platform
@@ -150,7 +157,7 @@ def _build_options(temp_build_dir, impl_mode, is_cube):
150 asc_path = os.path.realpath(os.path.join(ascend_home_path, "aarch64-linux", "asc"))157 asc_path = os.path.realpath(os.path.join(ascend_home_path, "aarch64-linux", "asc"))
151 if asc_path is None:158 if asc_path is None:
152 asc_path = os.path.realpath(os.path.join(ascend_home_path, "compiler", "asc"))159 asc_path = os.path.realpath(os.path.join(ascend_home_path, "compiler", "asc"))
153- _join_path(options, asc_path, is_cube)160+ _join_path(options, asc_path, is_cube, is_conv)
154 options.append("-I" + os.path.join(temp_build_dir))161 options.append("-I" + os.path.join(temp_build_dir))
155 if impl_mode == "high_performance":162 if impl_mode == "high_performance":
156 options.append("-DHIGH_PERFORMANCE=1")163 options.append("-DHIGH_PERFORMANCE=1")
@@ -202,7 +209,8 @@ def ascbc_kernel_compile(
202 enable_parallel_compile,209 enable_parallel_compile,
203 tiling_key=-1,210 tiling_key=-1,
204 kernel_type="KERNEL_TYPE_AIV_ONLY",211 kernel_type="KERNEL_TYPE_AIV_ONLY",
205- is_cube=False212+ is_cube=False,
213+ is_conv=False
206):214):
207 graph_name = camel_to_snake(graph_name)215 graph_name = camel_to_snake(graph_name)
208 args_list = args[0]216 args_list = args[0]
@@ -218,7 +226,7 @@ def ascbc_kernel_compile(
218 226 
219 _origin_inputs_, _origin_outputs_, _inputs_, _outputs_ = \227 _origin_inputs_, _origin_outputs_, _inputs_, _outputs_ = \
220 _build_args(args_list, input_num=input_num, output_num=output_num)228 _build_args(args_list, input_num=input_num, output_num=output_num)
221- _options_ = _build_options(temp_build_dir, impl_mode, is_cube)229+ _options_ = _build_options(temp_build_dir, impl_mode, is_cube, is_conv)
222 if enable_parallel_compile:230 if enable_parallel_compile:
223 _options_ += ['--cce-long-call=true']231 _options_ += ['--cce-long-call=true']
224 os.environ['ASCENDC_PAR_COMPILE_JOB'] = '1'232 os.environ['ASCENDC_PAR_COMPILE_JOB'] = '1'
@@ -95,7 +95,6 @@ inline typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bo
95StrJoin(const std::vector<T> &vec, const std::string &sep = ", ") {95StrJoin(const std::vector<T> &vec, const std::string &sep = ", ") {
96 return StrJoin(vec, [](const T &s) { return std::to_string(s); }, sep);96 return StrJoin(vec, [](const T &s) { return std::to_string(s); }, sep);
97}97}
98- 
99} // namespace loop98} // namespace loop
100} // namespace ge99} // namespace ge
101 100 
@@ -6,6 +6,15 @@ set(ascendc_api_cube_src
6 matmul/mat_mul_pingpong_basic_cmct.h6 matmul/mat_mul_pingpong_basic_cmct.h
7 matmul/batch_matmul_include_headers.h7 matmul/batch_matmul_include_headers.h
8 batch_matmul.h8 batch_matmul.h
9+ matmul_dynamic.h
10+ matmul/mat_mul_tiling_key_dynamic.h
11+ matmul/batch_mat_mul_v3_tiling_key_dynamic.h
12+ matmul/mat_mul_pingpong_basic_cmct_dynamic.h
13+ batch_matmul_dynamic.h
14+ conv2d.h
15+ conv2d/conv2d_include_headers.h
16+ conv2d/conv2d_v2_tilingkey_cv.h
17+ conv2d/conv_pingpong_basic_atcos.h
9)18)
10 19 
11set(generated_cube_files)20set(generated_cube_files)
@@ -0,0 +1,289 @@
1+/**
2+ * Copyright (c) 2026 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+#include "autofuse_cube_tiling_data.h"
12+ 
13+using namespace AscendC;
14+using namespace matmul;
15+// 此处和act模板代码有差异,注意不要 DTYPE_BIAS
16+ 
17+#if defined(FORMAT_X1) && FORMAT_X1 == FORMAT_FRACTAL_NZ
18+constexpr CubeFormat format_x1 = CubeFormat::NZ;
19+#else
20+constexpr CubeFormat format_x1 = CubeFormat::ND;
21+#endif
22+ 
23+#if defined(FORMAT_X2) && FORMAT_X2 == FORMAT_FRACTAL_NZ
24+constexpr CubeFormat format_x2 = CubeFormat::NZ;
25+#else
26+constexpr CubeFormat format_x2 = CubeFormat::ND;
27+#endif
28+ 
29+#if defined(FORMAT_Y) && FORMAT_Y == FORMAT_FRACTAL_NZ
30+constexpr CubeFormat format_y = CubeFormat::NZ;
31+#else
32+constexpr CubeFormat format_y = CubeFormat::ND;
33+#endif
34+ 
35+#define BMMV3_IMPL_CLASS(templateClass, ...) \
36+ do { \
37+ using cType = MatmulType<AscendC::TPosition::GM, format_y, DTYPE_Y, false, LayoutMode::NORMAL>; \
38+ using biasType = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, DTYPE_BIAS, false, LayoutMode::NORMAL>; \
39+ TPipe pipe; \
40+ if (tilingData.matmulTiling.matmulRunInfo.transA == 0 && tilingData.matmulTiling.matmulRunInfo.transB == 0) { \
41+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, false, LayoutMode::NORMAL>; \
42+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, false, LayoutMode::NORMAL>; \
43+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
44+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
45+ op.Process(); \
46+ } else if ( \
47+ tilingData.matmulTiling.matmulRunInfo.transA == 1 && tilingData.matmulTiling.matmulRunInfo.transB == 0) { \
48+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, true, LayoutMode::NORMAL>; \
49+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, false, LayoutMode::NORMAL>; \
50+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
51+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
52+ op.Process(); \
53+ } else if ( \
54+ tilingData.matmulTiling.matmulRunInfo.transA == 0 && tilingData.matmulTiling.matmulRunInfo.transB == 1) { \
55+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, false, LayoutMode::NORMAL>; \
56+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, true, LayoutMode::NORMAL>; \
57+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
58+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
59+ op.Process(); \
60+ } else { \
61+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, true, LayoutMode::NORMAL>; \
62+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, true, LayoutMode::NORMAL>; \
63+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
64+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
65+ op.Process(); \
66+ } \
67+ } while (0)
68+// 此处和act模板代码有差异,注意保留GET_TILING_DATA_WITH_STRUCT
69+#define BMMV3_IMPL_CLASS_TRANS(transA, transB, templateClass, ...) \
70+ do { \
71+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3TilingData, tilingData, tilingGM); \
72+ using cType = MatmulType<AscendC::TPosition::GM, format_y, DTYPE_Y, false, LayoutMode::NORMAL>; \
73+ using biasType = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, DTYPE_BIAS, false, LayoutMode::NORMAL>; \
74+ TPipe pipe; \
75+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, transA, LayoutMode::NORMAL>; \
76+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, transB, LayoutMode::NORMAL>; \
77+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
78+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
79+ op.Process(); \
80+ } while (0)
81+ 
82+#define BMMV3_IMPL_CLASS_COMMON(templateClass, ...) \
83+ do { \
84+ using cType = MatmulType<AscendC::TPosition::GM, format_y, DTYPE_Y>; \
85+ using biasType = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, DTYPE_BIAS>; \
86+ TPipe pipe; \
87+ if (tilingData.matmulTiling.matmulRunInfo.transA == 0 && tilingData.matmulTiling.matmulRunInfo.transB == 0) { \
88+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, false>; \
89+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, false>; \
90+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
91+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
92+ op.Process(); \
93+ } else if ( \
94+ tilingData.matmulTiling.matmulRunInfo.transA == 1 && tilingData.matmulTiling.matmulRunInfo.transB == 0) { \
95+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, true>; \
96+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, false>; \
97+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
98+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
99+ op.Process(); \
100+ } else if ( \
101+ tilingData.matmulTiling.matmulRunInfo.transA == 0 && tilingData.matmulTiling.matmulRunInfo.transB == 1) { \
102+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, false>; \
103+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, true>; \
104+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
105+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
106+ op.Process(); \
107+ } else { \
108+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, true>; \
109+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, true>; \
110+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
111+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
112+ op.Process(); \
113+ } \
114+ } while (0)
115+// 此处和act模板代码有差异,注意保留GET_TILING_DATA_WITH_STRUCT
116+#define BMMV3_IMPL_CLASS_COMMON_TRNAS(transA, transB, templateClass, ...) \
117+ do { \
118+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3TilingData, tilingData, tilingGM); \
119+ using cType = MatmulType<AscendC::TPosition::GM, format_y, DTYPE_Y>; \
120+ using biasType = MatmulType<AscendC::TPosition::GM, CubeFormat::ND, DTYPE_BIAS>; \
121+ TPipe pipe; \
122+ using aType = MatmulType<AscendC::TPosition::GM, format_x1, DTYPE_X1, transA>; \
123+ using bType = MatmulType<AscendC::TPosition::GM, format_x2, DTYPE_X2, transB>; \
124+ templateClass<aType, bType, cType, biasType, __VA_ARGS__> op; \
125+ op.Init(aGM, bGM, cGM, biasGM, offsetWGM, user, &tilingData, &pipe); \
126+ op.Process(); \
127+ } while (0)
128+template <int8_t BATCH_API_LEVEL, int8_t BATCH_A_TRANS, int8_t BATCH_B_TRANS, int8_t BATCH_ITER_MODEL, int8_t BMODEL,
129+ int8_t BATCH_FULL_LOAD, int8_t BATCH_L0C2OUT_MODEL>
130+__global__ __aicore__ void batch_mat_mul_v3(
131+ GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM, GM_ADDR offsetWGM, GM_ADDR cGM, GM_ADDR workspaceGM, GM_ADDR tilingGM)
132+{
133+ __gm__ uint8_t* user = GetUserWorkspace(workspaceGM);
134+ 
135+ constexpr bool aTran = (BATCH_A_TRANS == 1);
136+ constexpr bool bTran = (BATCH_B_TRANS == 1);
137+ 
138+#if !(defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102))
139+ using aLayout = std::conditional_t<aTran, layout::ColumnMajor, layout::RowMajor>;
140+ using bLayout = std::conditional_t<bTran, layout::ColumnMajor, layout::RowMajor>;
141+#endif
142+ 
143+ REGISTER_TILING_DEFAULT(BatchMatMulV3TilingData);
144+ 
145+ if constexpr (
146+ BATCH_API_LEVEL == MAT_MUL_HIGH_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
147+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
148+ BMMV3_IMPL_CLASS_COMMON_TRNAS(
149+ aTran, bTran, BatchMatMulV3Advanced::BatchMatMulAswKernel, BatchMatMulV3Advanced::BatchMatMulAswBlock,
150+ MM_CFG_NO_PRELOAD);
151+ } else if constexpr (
152+ BATCH_API_LEVEL == MAT_MUL_HIGH_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
153+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_ITER_BATCH_SINGLE_BIAS) {
154+ BMMV3_IMPL_CLASS_TRANS(
155+ aTran, bTran, BatchMatMulV3Advanced::BatchMatMulMultiBatchKernel,
156+ BatchMatMulV3Advanced::BatchMatMulMultiBatchBaseBlock, MM_CFG_MULTI_BATCH_OUT_SING_BIAS);
157+#if !(defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102))
158+ } else if constexpr (
159+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
160+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_ITER_BATCH_SINGLE_BIAS) {
161+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3IterBatchBasicTilingData, tilingData, tilingGM);
162+ BatchMatMulActIterBatchKernel<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor>(
163+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData);
164+ } else if constexpr (
165+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
166+ BATCH_L0C2OUT_MODEL == MAT_MUL_1V2_ND_ALIG_FIXPIPE && BATCH_ITER_MODEL == MAT_MUL_ITER_BATCH_SINGLE_BIAS) {
167+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3IterBatchBasicTilingData, tilingData, tilingGM);
168+ BatchMatMulActIterBatchKernel<
169+ DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor, MatMulL0C2Out::ND_FIXPIPE_1_2>(
170+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData);
171+ } else if constexpr (
172+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
173+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_BATCH_MATMUL_TO_MUL) {
174+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulToMulBasicTilingData, tilingData, tilingGM);
175+ BatchMatMulToMulActKernel<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor>(
176+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData);
177+ }
178+ else if constexpr (
179+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
180+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
181+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3BasicTilingData, tilingData, tilingGM);
182+ MatmulV3Advanced::MatMulActKernel<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor,
183+ 0, OP_TYPE_RELU_VALUE>(
184+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData.matMulTilingData, tilingData.batchDimAll);
185+ } else if constexpr (
186+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_A_FULL_LOAD &&
187+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
188+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3BasicTilingData, tilingData, tilingGM);
189+ MatmulV3Advanced::MatMulActKernel<
190+ DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor, A_FULL_LOAD_MODE, OP_TYPE_RELU_VALUE>(
191+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData.matMulTilingData, tilingData.batchDimAll);
192+ } else if constexpr (
193+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_B_FULL_LOAD &&
194+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
195+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3BasicTilingData, tilingData, tilingGM);
196+ MatmulV3Advanced::MatMulActKernel<
197+ DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor, B_FULL_LOAD_MODE, OP_TYPE_RELU_VALUE>(
198+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData.matMulTilingData, tilingData.batchDimAll);
199+ } else if constexpr (
200+ BATCH_API_LEVEL == MAT_MUL_HIGH_LEVEL && BMODEL == MAT_MUL_K_EQUAL_ZERO && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
201+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
202+ TPipe pipe;
203+ GET_TILING_DATA_WITH_STRUCT(MatMulV3KEqZeroBasicTilingData, tilingData, tilingGM);
204+ MatmulV3Advanced::MatMulInputKEqZeroClearOutput(biasGM, cGM, tilingData);
205+#endif
206+ }
207+}
208+ 
209+template <int8_t BATCH_API_LEVEL, int8_t BATCH_A_TRANS, int8_t BATCH_B_TRANS, int8_t BATCH_ITER_MODEL, int8_t BMODEL,
210+ int8_t BATCH_FULL_LOAD, int8_t BATCH_L0C2OUT_MODEL>
211+__global__ __aicore__ void batch_mat_mul_v3_fusion(
212+ GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM, GM_ADDR offsetWGM, GM_ADDR cGM, GM_ADDR workspaceGM, GM_ADDR tilingGM,
213+ AutoFusionVector::Params *param)
214+{
215+ __gm__ uint8_t* user = GetUserWorkspace(workspaceGM);
216+ 
217+ constexpr bool aTran = (BATCH_A_TRANS == 1);
218+ constexpr bool bTran = (BATCH_B_TRANS == 1);
219+ 
220+#if !(defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102))
221+ using aLayout = std::conditional_t<aTran, layout::ColumnMajor, layout::RowMajor>;
222+ using bLayout = std::conditional_t<bTran, layout::ColumnMajor, layout::RowMajor>;
223+#endif
224+ 
225+ REGISTER_TILING_DEFAULT(BatchMatMulV3TilingData);
226+ 
227+ if constexpr (
228+ BATCH_API_LEVEL == MAT_MUL_HIGH_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
229+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
230+ BMMV3_IMPL_CLASS_COMMON_TRNAS(
231+ aTran, bTran, BatchMatMulV3Advanced::BatchMatMulAswKernel, BatchMatMulV3Advanced::BatchMatMulAswBlock,
232+ MM_CFG_NO_PRELOAD);
233+ } else if constexpr (
234+ BATCH_API_LEVEL == MAT_MUL_HIGH_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
235+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_ITER_BATCH_SINGLE_BIAS) {
236+ BMMV3_IMPL_CLASS_TRANS(
237+ aTran, bTran, BatchMatMulV3Advanced::BatchMatMulMultiBatchKernel,
238+ BatchMatMulV3Advanced::BatchMatMulMultiBatchBaseBlock, MM_CFG_MULTI_BATCH_OUT_SING_BIAS);
239+#if !(defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102))
240+ } else if constexpr (
241+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
242+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_ITER_BATCH_SINGLE_BIAS) {
243+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3IterBatchBasicTilingData, tilingData, tilingGM);
244+ BatchMatMulActIterBatchKernel<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor>(
245+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData);
246+ } else if constexpr (
247+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
248+ BATCH_L0C2OUT_MODEL == MAT_MUL_1V2_ND_ALIG_FIXPIPE && BATCH_ITER_MODEL == MAT_MUL_ITER_BATCH_SINGLE_BIAS) {
249+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3IterBatchBasicTilingData, tilingData, tilingGM);
250+ BatchMatMulActIterBatchKernel<
251+ DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor, MatMulL0C2Out::ND_FIXPIPE_1_2>(
252+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData);
253+ } else if constexpr (
254+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
255+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_BATCH_MATMUL_TO_MUL) {
256+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulToMulBasicTilingData, tilingData, tilingGM);
257+ BatchMatMulToMulActKernel<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor>(
258+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData);
259+ }
260+ else if constexpr (
261+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
262+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
263+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3BasicTilingData, tilingData, tilingGM);
264+ MatmulV3Advanced::MatMulActKernelFusion<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor,
265+ 0, OP_TYPE_RELU_VALUE>(
266+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData.matMulTilingData, param, tilingData.batchDimAll);
267+ } else if constexpr (
268+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_A_FULL_LOAD &&
269+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
270+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3BasicTilingData, tilingData, tilingGM);
271+ MatmulV3Advanced::MatMulActKernelFusion<
272+ DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor, A_FULL_LOAD_MODE, OP_TYPE_RELU_VALUE>(
273+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData.matMulTilingData, param, tilingData.batchDimAll);
274+ } else if constexpr (
275+ BATCH_API_LEVEL == MAT_MUL_BASIC_LEVEL && BMODEL == MAT_MUL_BASIC && BATCH_FULL_LOAD == MAT_MUL_B_FULL_LOAD &&
276+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
277+ GET_TILING_DATA_WITH_STRUCT(BatchMatMulV3BasicTilingData, tilingData, tilingGM);
278+ MatmulV3Advanced::MatMulActKernelFusion<
279+ DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, layout::RowMajor, B_FULL_LOAD_MODE, OP_TYPE_RELU_VALUE>(
280+ aGM, bGM, biasGM, cGM, workspaceGM, tilingData.matMulTilingData, param, tilingData.batchDimAll);
281+ } else if constexpr (
282+ BATCH_API_LEVEL == MAT_MUL_HIGH_LEVEL && BMODEL == MAT_MUL_K_EQUAL_ZERO && BATCH_FULL_LOAD == MAT_MUL_NO_FULL_LOAD &&
283+ BATCH_L0C2OUT_MODEL == MAT_MUL_ON_THE_FLY && BATCH_ITER_MODEL == MAT_MUL_FOR_BATCH) {
284+ TPipe pipe;
285+ GET_TILING_DATA_WITH_STRUCT(MatMulV3KEqZeroBasicTilingData, tilingData, tilingGM);
286+ MatmulV3Advanced::MatMulInputKEqZeroClearOutput(biasGM, cGM, tilingData);
287+#endif
288+ }
289+}
@@ -0,0 +1,47 @@
1+/**
2+ * Copyright (c) 2026 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+#include "autofuse_cube_tiling_data.h"
12+ 
13+ 
14+using namespace Atcos;
15+using namespace Atcos::Conv;
16+ 
17+#define CONV_A_FULL_LOAD_MODE 0U
18+#define A_FULL_LOAD_MODE 0UL
19+ 
20+using aLayout = Atcos::Conv::layout::NCHW;
21+using bLayout = Atcos::Conv::layout::CI1KHKWCOCI0;
22+using cLayout = Atcos::Conv::layout::NCHW;
23+using biasLayout = Atcos::Conv::layout::NCHW;
24+ 
25+ 
26+template<int8_t FmapTiling, int8_t WeightTiling, int8_t L1PingPong, int8_t L0PingPong, int8_t OutputOrder,
27+ int8_t IterOrder, int8_t GroupType, int8_t EnableSmallChannel, int8_t WeightUbTrans, int8_t FmapCopyMode,
28+ int8_t InnerBatch, int8_t DisContinuous>
29+__aicore__ void conv2d_v2(
30+#ifdef CV_UB_FUSION
31+ GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM, GM_ADDR offsetWGM, GM_ADDR cGM, GM_ADDR workspaceGM, GM_ADDR tilingGM, AutoFusionVector::Params *params
32+#else
33+ GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM, GM_ADDR offsetWGM, GM_ADDR cGM, GM_ADDR workspaceGM, GM_ADDR tilingGM
34+#endif
35+)
36+{
37+ REGISTER_TILING_DEFAULT(Conv2DTilingData);
38+ GET_TILING_DATA_WITH_STRUCT(Conv2DTilingData, tilingData, tilingGM);
39+ Conv2DV2Advanced::ConvActKernel<DTYPE_X1, DTYPE_X2, DTYPE_Y, DTYPE_BIAS, aLayout, bLayout, cLayout, biasLayout,
40+ A_FULL_LOAD_MODE>(
41+#ifdef CV_UB_FUSION
42+ aGM, bGM, biasGM, offsetWGM, cGM, workspaceGM, tilingData, params
43+#else
44+ aGM, bGM, biasGM, offsetWGM, cGM, workspaceGM, tilingData
45+#endif
46+ );
47+}
@@ -0,0 +1,16 @@
1+/**
2+ * Copyright (c) 2026 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+#ifndef CONV2D_INCLUDE_HEADERS_H
11+#define CONV2D_INCLUDE_HEADERS_H
12+// conv2d
13+#include "arch35/conv2d_v2_tiling_def.h"
14+ 
15+ 
16+#endif // CONV2D_INCLUDE_HEADERS_H
@@ -0,0 +1,108 @@
1+/**
2+ * Copyright (c) 2026 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+#ifndef CONV_PINGPONG_BASIC_ATCOS_H
11+#define CONV_PINGPONG_BASIC_ATCOS_H
12+ 
13+#include "include/conv/block/block_scheduler.h"
14+#include "include/conv/prologue/block_prologue.h"
15+ 
16+#ifdef CV_UB_FUSION
17+#include "include/conv/kernel/kernel_conv_forward_mix.h"
18+#include "include/conv/epilogue/block_epilogue_cv.h"
19+#else
20+#include "include/conv/kernel/kernel_conv_forward.h"
21+#include "include/conv/epilogue/block_epilogue_empty.h"
22+#endif
23+ 
24+namespace Conv2DV2Advanced {
25+ 
26+using namespace Atcos;
27+using namespace Atcos::Conv;
28+ 
29+template<class A_TYPE, class B_TYPE, class C_TYPE, class BIAS_TYPE, class A_LAYOUT, class B_LAYOUT, class C_LAYOUT, class BIAS_LAYOUT, uint64_t FULL_LOAD_MODE = 0>
30+__aicore__ inline void ConvActKernel(GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM, GM_ADDR offsetWGM,
31+#ifdef CV_UB_FUSION
32+ GM_ADDR cGM, GM_ADDR workspaceGM, const Conv2DTilingData& tilingData, AutoFusionVector::Params *param
33+#else
34+ GM_ADDR cGM, GM_ADDR workspaceGM, const Conv2DTilingData& tilingData
35+#endif
36+)
37+{
38+ using AType = A_TYPE;
39+ using BType = B_TYPE;
40+ using CType = C_TYPE;
41+ using BiasType = BIAS_TYPE;
42+ 
43+ using LayoutA = A_LAYOUT;
44+ using LayoutB = B_LAYOUT;
45+ using LayoutC = C_LAYOUT;
46+ using LayoutBias = BIAS_LAYOUT;
47+ 
48+ using BlockScheduler = Block::IterateMFirst;
49+ 
50+ using OutputOrder = order::OutputMMode;
51+ using BlockPrologue = Block::BlockPrologueEmpty;
52+ 
53+ using BlockConvPolicy = Atcos::Conv::Img2ColConvMModePolicy;
54+ using BlockConv = Block::BlockConv<ConvShape, BlockConvPolicy, AType, BType, CType, BiasType, LayoutA, LayoutB, LayoutC, LayoutBias>;
55+ 
56+ ConvShape shape;
57+ TilingData2ConvShape(tilingData, shape);
58+ ConvDim dimArgs;
59+ TilingData2ConvDim(tilingData, dimArgs);
60+ 
61+#ifdef CV_UB_FUSION
62+ using FusionOp = AutoFusionVector;
63+ 
64+ using BlockEpilogue = Block::BlockEpilogueCV<ConvShape, CType, CType, FusionOp>;
65+ 
66+ using ConvKernel = Kernel::KernelConv<ConvShape, BlockConv, BlockPrologue, BlockEpilogue, BlockScheduler, OutputOrder>;
67+ 
68+ typename ConvKernel::BlockConvArguments convArgs = {
69+ aGM, bGM, cGM, biasGM
70+ };
71+ 
72+ typename BlockEpilogue::Params epilogueParams;
73+ epilogueParams.fusionParams = *param;
74+ 
75+ typename ConvKernel::Params params = {
76+ shape,
77+ dimArgs,
78+ convArgs,
79+ {},
80+ epilogueParams
81+ };
82+ 
83+ ConvKernel conv;
84+ conv(params);
85+#else
86+ using BlockEpilogue = Block::BlockEpilogueEmpty;
87+ 
88+ using ConvKernel = Kernel::KernelConv<ConvShape, BlockConv, BlockPrologue, BlockEpilogue, BlockScheduler, OutputOrder>;
89+ 
90+ typename ConvKernel::BlockConvArguments convArgs = {
91+ aGM, bGM, cGM, biasGM
92+ };
93+ 
94+ typename ConvKernel::Params parmas = {
95+ shape,
96+ dimArgs,
97+ convArgs,
98+ {},
99+ {}
100+ };
101+ 
102+ ConvKernel conv;
103+ conv(parmas);
104+#endif
105+}
106+ 
107+}
108+#endif
@@ -0,0 +1,181 @@
1+/**
2+ * Copyright (c) 2026 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 batch_mat_mul_v3_tiling_key_dynamic.h
13+ * \brief
14+ */
15+ 
16+#ifndef OP_KERNEL_BATCH_MAT_MUL_V3_TILING_KEY_DYNAMIC_H
17+#define OP_KERNEL_BATCH_MAT_MUL_V3_TILING_KEY_DYNAMIC_H
18+#endif
19+ 
20+#include "arch35/mat_mul_tiling_data.h"
21+#include "mat_mul_v3_common.h"
22+#include "template_argument.h"
23+ 
24+#define MAT_MUL_BASIC_LEVEL 1 // 数据类型定义
25+#define MAT_MUL_HIGH_LEVEL 0
26+ 
27+#define MAT_MUL_NO_TRANS 0 // 数据格式定义
28+#define MAT_MUL_TRANS 1
29+ 
30+#define MAT_MUL_FOR_BATCH 0
31+#define MAT_MUL_ITER_BATCH_SINGLE_BIAS 1
32+#define MAT_MUL_BATCH_MATMUL_TO_MUL 2
33+ 
34+#define MAT_MUL_BASIC 0
35+#define MAT_MUL_STREAM_K 1
36+#define MAT_MUL_K_EQUAL_ZERO 2
37+ 
38+#define MAT_MUL_NO_FULL_LOAD 0
39+#define MAT_MUL_A_FULL_LOAD 1
40+#define MAT_MUL_B_FULL_LOAD 2
41+#define MAT_MUL_AB_FULL_LOAD 3
42+ 
43+#define MAT_MUL_ON_THE_FLY 0
44+#define MAT_MUL_1V1_ND_ALIG_FIXPIPE 1
45+#define MAT_MUL_1V2_ND_ALIG_FIXPIPE 2
46+ 
47+// 模板参数
48+ASCENDC_TPL_ARGS_DECL(
49+ AscBackend, // 算子OpType
50+ ASCENDC_TPL_UINT_DECL(BATCH_API_LEVEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL,
51+ MAT_MUL_BASIC_LEVEL),
52+ ASCENDC_TPL_UINT_DECL(BATCH_A_TRANS, ASCENDC_TPL_2_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
53+ ASCENDC_TPL_UINT_DECL(BATCH_B_TRANS, ASCENDC_TPL_2_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
54+ ASCENDC_TPL_UINT_DECL(BATCH_ITER_MODEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH,
55+ MAT_MUL_ITER_BATCH_SINGLE_BIAS, MAT_MUL_BATCH_MATMUL_TO_MUL),
56+ ASCENDC_TPL_UINT_DECL(BMODEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC, MAT_MUL_STREAM_K,
57+ MAT_MUL_K_EQUAL_ZERO),
58+ ASCENDC_TPL_UINT_DECL(BATCH_FULL_LOAD, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD,
59+ MAT_MUL_A_FULL_LOAD, MAT_MUL_B_FULL_LOAD, MAT_MUL_AB_FULL_LOAD),
60+ ASCENDC_TPL_UINT_DECL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY,
61+ MAT_MUL_1V1_ND_ALIG_FIXPIPE, MAT_MUL_1V2_ND_ALIG_FIXPIPE));
62+ 
63+// 模板参数组合
64+// 用于调用GET_TPL_TILING_KEY获取TilingKey时,接口内部校验TilingKey是否合法
65+ASCENDC_TPL_SEL(
66+#if (defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102))
67+ ASCENDC_TPL_ARGS_SEL(
68+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
69+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
70+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
71+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
72+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
73+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
74+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
75+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
76+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3TilingData)),
77+ ASCENDC_TPL_ARGS_SEL(
78+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
79+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
80+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
81+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
82+ ASCENDC_TPL_UINT_SEL(
83+ BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ITER_BATCH_SINGLE_BIAS),
84+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
85+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
86+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
87+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3TilingData))
88+#else
89+ ASCENDC_TPL_ARGS_SEL(
90+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
91+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
92+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
93+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
94+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
95+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
96+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
97+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
98+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3TilingData)),
99+ ASCENDC_TPL_ARGS_SEL(
100+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
101+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
102+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
103+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
104+ ASCENDC_TPL_UINT_SEL(
105+ BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ITER_BATCH_SINGLE_BIAS),
106+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
107+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
108+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
109+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3TilingData)),
110+ ASCENDC_TPL_ARGS_SEL(
111+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
112+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
113+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
114+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
115+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
116+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
117+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
118+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
119+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3BasicTilingData)),
120+ ASCENDC_TPL_ARGS_SEL(
121+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
122+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
123+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
124+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
125+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ITER_BATCH_SINGLE_BIAS),
126+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
127+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
128+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
129+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3IterBatchBasicTilingData)),
130+ ASCENDC_TPL_ARGS_SEL(
131+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
132+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
133+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
134+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
135+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ITER_BATCH_SINGLE_BIAS),
136+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
137+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
138+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_1V2_ND_ALIG_FIXPIPE),
139+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3IterBatchBasicTilingData)),
140+ ASCENDC_TPL_ARGS_SEL(
141+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
142+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
143+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
144+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
145+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
146+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
147+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_B_FULL_LOAD),
148+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
149+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3BasicTilingData)),
150+ ASCENDC_TPL_ARGS_SEL(
151+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
152+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
153+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
154+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
155+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
156+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
157+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_A_FULL_LOAD),
158+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
159+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3BasicTilingData)),
160+ ASCENDC_TPL_ARGS_SEL(
161+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_AIV_ONLY),
162+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
163+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS),
164+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS),
165+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BATCH_MATMUL_TO_MUL),
166+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
167+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
168+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
169+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulToMulBasicTilingData)),
170+ ASCENDC_TPL_ARGS_SEL(
171+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_AIV_ONLY),
172+ ASCENDC_TPL_UINT_SEL(BATCH_API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
173+ ASCENDC_TPL_UINT_SEL(BATCH_A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS),
174+ ASCENDC_TPL_UINT_SEL(BATCH_B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS),
175+ ASCENDC_TPL_UINT_SEL(BATCH_ITER_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
176+ ASCENDC_TPL_UINT_SEL(BMODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_K_EQUAL_ZERO),
177+ ASCENDC_TPL_UINT_SEL(BATCH_FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
178+ ASCENDC_TPL_UINT_SEL(BATCH_L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
179+ ASCENDC_TPL_TILING_STRUCT_SEL(BatchMatMulV3TilingData))
180+#endif
181+); // OP_KERNEL_BATCH_MAT_MUL_V3_TILING_KEY_DYNAMIC_H
@@ -0,0 +1,127 @@
1+/**
2+ * Copyright (c) 2026 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 mat_mul_pingpong_basic_cmct_dynamic.h
13+ * \brief
14+ */
15+#ifndef MAT_MUL_PINGPONG_BASIC_CMCT_DYNAMIC_H
16+#define MAT_MUL_PINGPONG_BASIC_CMCT_DYNAMIC_H
17+ 
18+#include "cmct/block/block_scheduler_policy.h"
19+#include "cmct/block/block_scheduler_utils.h"
20+#include "cmct/kernel/kernel_matmul_without_que.h"
21+#ifdef CV_UB_FUSION
22+#include "cmct/kernel/kernel_matmul_mix_without_que.h"
23+#include "cmct/epilogue/block_epilogue_cv.h"
24+#endif
25+namespace MatmulV3Advanced {
26+using namespace Cmct;
27+using namespace Cmct::Gemm;
28+template <class A_TYPE, class B_TYPE, class C_TYPE, class BIAS_TYPE, class A_LAYOUT,
29+ class B_LAYOUT, class C_LAYOUT, uint64_t FULL_LOAD_MODE = 0, uint64_t FUSED_OP_TYPE = 0>
30+__aicore__ inline void MatMulActKernel(GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM,
31+ GM_ADDR cGM, GM_ADDR workspaceGM, const MatMulV3BasicTilingData& tilingData, int64_t batch = 0)
32+{
33+ // 定义L1和L0的TileShape
34+ using L1TileShape = AscendC::Shape<_0, _0, _0>;
35+ using L0TileShape = AscendC::Shape<_0, _0, _0>;
36+ 
37+ // 定义矩阵的类型和布局
38+ using AType = A_TYPE;
39+ using BType = B_TYPE;
40+ using BiasType = BIAS_TYPE;
41+ using OutType = C_TYPE;
42+ 
43+ using LayoutA = A_LAYOUT;
44+ using LayoutB = B_LAYOUT;
45+ using LayoutC = C_LAYOUT;
46+ 
47+ // 定义scheduler类型 来自block_scheduler_policy.h
48+ using BlockScheduler = BuiltInAswtScheduler<FULL_LOAD_MODE>;
49+ 
50+ // 定义MMAD类型
51+ using DispatchPolicy = MatmulMultiBlockWithOutQue<AscendC::Shape<_0, _0, _0, _0>, FULL_LOAD_MODE, FUSED_OP_TYPE>;
52+ using BlockMmad = Block::BlockMmadBuilder<
53+ AType, LayoutA, BType, LayoutB, OutType, LayoutC, BiasType, LayoutC, L1TileShape, L0TileShape, BlockScheduler,
54+ DispatchPolicy>;
55+ 
56+ // 定义Fusion类型
57+ using FusionOp = Block::DefaultFusion<OutType, OutType>;
58+ 
59+ // 定义BlockEpilogue类型
60+ using BlockEpilogue = Block::BlockEpilogueEmpty;
61+ 
62+ // 定义shape的形状,tuple保存 m n k batch
63+ using ProblemShape = MatmulShape;
64+ 
65+ // 定义Kernel类型
66+ using MatmulKernel = Kernel::KernelMatmulWithoutQue<ProblemShape, BlockMmad, BlockEpilogue, BlockScheduler>;
67+ using Params = typename MatmulKernel::Params;
68+ Params params = {
69+ {tilingData.m, tilingData.n, tilingData.k, batch}, // shape
70+ {aGM, bGM, cGM, biasGM}, // gm addr
71+ {}, // epilogue args
72+ {&tilingData}};
73+ MatmulKernel mm;
74+ mm(params);
75+}
76+ 
77+template <class A_TYPE, class B_TYPE, class C_TYPE, class BIAS_TYPE, class A_LAYOUT,
78+ class B_LAYOUT, class C_LAYOUT, uint64_t FULL_LOAD_MODE = 0, uint64_t FUSED_OP_TYPE = 0>
79+__aicore__ inline void MatMulActKernelFusion(GM_ADDR aGM, GM_ADDR bGM, GM_ADDR biasGM,
80+ GM_ADDR cGM, GM_ADDR workspaceGM, const MatMulV3BasicTilingData& tilingData,
81+ AutoFusionVector::Params *param, int64_t batch = 0)
82+{
83+ // 定义L1和L0的TileShape
84+ using L1TileShape = AscendC::Shape<_0, _0, _0>;
85+ using L0TileShape = AscendC::Shape<_0, _0, _0>;
86+ 
87+ // 定义矩阵的类型和布局
88+ using AType = A_TYPE;
89+ using BType = B_TYPE;
90+ using BiasType = BIAS_TYPE;
91+ using OutType = C_TYPE;
92+ 
93+ using LayoutA = A_LAYOUT;
94+ using LayoutB = B_LAYOUT;
95+ using LayoutC = C_LAYOUT;
96+ 
97+ // 定义scheduler类型 来自block_scheduler_policy.h
98+ using BlockScheduler = BuiltInAswtScheduler<FULL_LOAD_MODE>;
99+ 
100+ // 定义MMAD类型
101+ using DispatchPolicy = MatmulMultiBlockWithOutQue<AscendC::Shape<_0, _0, _0, _0>, FULL_LOAD_MODE, FUSED_OP_TYPE>;
102+ using BlockMmad = Block::BlockMmadBuilder<
103+ AType, LayoutA, BType, LayoutB, OutType, LayoutC, BiasType, LayoutC, L1TileShape, L0TileShape, BlockScheduler,
104+ DispatchPolicy>;
105+ 
106+ // 定义Fusion类型
107+ using FusionOp = AutoFusionVector;
108+ 
109+ // 定义BlockEpilogue类型
110+ using BlockEpilogue = Block::BlockEpilogueCV<L0TileShape, OutType, OutType, FusionOp>;
111+ 
112+ // 定义shape的形状,tuple保存 m n k batch
113+ using ProblemShape = MatmulShape;
114+ 
115+ // 定义Kernel类型
116+ using MatmulKernel = Kernel::KernelMatmulMixWithoutQue<ProblemShape, BlockMmad, BlockEpilogue, BlockScheduler>;
117+ using Params = typename MatmulKernel::Params;
118+ Params params = {
119+ {tilingData.m, tilingData.n, tilingData.k, batch}, // shape
120+ {aGM, bGM, cGM, biasGM}, // gm addr
121+ {cGM, *param}, // epilogue args
122+ {&tilingData}};
123+ MatmulKernel mm;
124+ mm(params);
125+}
126+}
127+#endif
@@ -0,0 +1,168 @@
1+/**
2+ * Copyright (c) 2026 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 mat_mul_tiling_key_dynamic.h
13+ * \brief
14+ */
15+ 
16+#ifndef __OP_KERNEL_MAT_MUL_TILING_KEY_DYNAMIC_H__
17+#define __OP_KERNEL_MAT_MUL_TILING_KEY_DYNAMIC_H__
18+#endif
19+ 
20+#include "arch35/mat_mul_v3_tiling_key_public.h"
21+#include "template_argument.h"
22+ 
23+// 模板参数
24+ASCENDC_TPL_ARGS_DECL(
25+ AscBackend, // 算子OpType
26+ ASCENDC_TPL_UINT_DECL(API_LEVEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL, MAT_MUL_BASIC_LEVEL),
27+ ASCENDC_TPL_UINT_DECL(A_TRANS, ASCENDC_TPL_2_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
28+ ASCENDC_TPL_UINT_DECL(B_TRANS, ASCENDC_TPL_2_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
29+ ASCENDC_TPL_UINT_DECL(BATCH_MODEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH,
30+ MAT_MUL_ITER_BATCH_SINGLE_BIAS),
31+ ASCENDC_TPL_UINT_DECL(MODEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC, MAT_MUL_STREAM_K,
32+ MAT_MUL_K_EQUAL_ZERO),
33+ ASCENDC_TPL_UINT_DECL(FULL_LOAD, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD, MAT_MUL_A_FULL_LOAD,
34+ MAT_MUL_B_FULL_LOAD, MAT_MUL_AB_FULL_LOAD),
35+ ASCENDC_TPL_UINT_DECL(L0C2OUT_MODEL, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY,
36+ MAT_MUL_1V1_ND_ALIG_FIXPIPE, MAT_MUL_1V2_ND_ALIG_FIXPIPE));
37+ 
38+// 模板参数组合
39+// 用于调用GET_TPL_TILING_KEY获取TilingKey时,接口内部校验TilingKey是否合法
40+ASCENDC_TPL_SEL(
41+#if (defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102))
42+ ASCENDC_TPL_ARGS_SEL(
43+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
44+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
45+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
46+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
47+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
48+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
49+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
50+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
51+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3TilingDataCopy))
52+#else
53+ ASCENDC_TPL_ARGS_SEL(
54+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
55+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
56+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
57+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
58+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
59+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
60+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD, MAT_MUL_B_FULL_LOAD),
61+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
62+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3BasicTilingData)),
63+ ASCENDC_TPL_ARGS_SEL(
64+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
65+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
66+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
67+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
68+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
69+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
70+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD, MAT_MUL_B_FULL_LOAD),
71+ ASCENDC_TPL_UINT_SEL(
72+ L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_1V1_ND_ALIG_FIXPIPE, MAT_MUL_1V2_ND_ALIG_FIXPIPE),
73+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3BasicTilingData)),
74+ ASCENDC_TPL_ARGS_SEL(
75+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
76+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
77+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
78+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
79+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
80+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
81+ ASCENDC_TPL_UINT_SEL(
82+ FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD, MAT_MUL_A_FULL_LOAD, MAT_MUL_B_FULL_LOAD),
83+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
84+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3TilingDataCopy)),
85+ ASCENDC_TPL_ARGS_SEL(
86+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
87+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
88+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
89+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
90+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
91+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_STREAM_K),
92+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
93+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
94+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3TilingDataCopy)),
95+ ASCENDC_TPL_ARGS_SEL(
96+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
97+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
98+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
99+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
100+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
101+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_STREAM_K),
102+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
103+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_1V2_ND_ALIG_FIXPIPE),
104+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3TilingDataCopy)),
105+ ASCENDC_TPL_ARGS_SEL(
106+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
107+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
108+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
109+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
110+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
111+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
112+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
113+ ASCENDC_TPL_UINT_SEL(
114+ L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_1V1_ND_ALIG_FIXPIPE, MAT_MUL_1V2_ND_ALIG_FIXPIPE),
115+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3TilingDataCopy)),
116+ ASCENDC_TPL_ARGS_SEL(
117+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
118+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
119+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
120+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
121+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
122+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
123+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_AB_FULL_LOAD),
124+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
125+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3TilingDataCopy)),
126+ ASCENDC_TPL_ARGS_SEL(
127+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
128+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
129+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
130+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
131+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
132+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_STREAM_K),
133+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
134+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY, MAT_MUL_1V2_ND_ALIG_FIXPIPE),
135+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3BasicTilingData)),
136+ ASCENDC_TPL_ARGS_SEL(
137+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
138+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
139+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
140+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
141+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
142+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
143+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_A_FULL_LOAD),
144+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
145+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3BasicTilingData)),
146+ ASCENDC_TPL_ARGS_SEL(
147+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIC_1_2),
148+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC_LEVEL),
149+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
150+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
151+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
152+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_BASIC),
153+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_A_FULL_LOAD),
154+ ASCENDC_TPL_UINT_SEL(
155+ L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_1V1_ND_ALIG_FIXPIPE, MAT_MUL_1V2_ND_ALIG_FIXPIPE),
156+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3BasicTilingData)),
157+ ASCENDC_TPL_ARGS_SEL(
158+ ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_AIV_ONLY),
159+ ASCENDC_TPL_UINT_SEL(API_LEVEL, ASCENDC_TPL_UI_LIST, MAT_MUL_HIGH_LEVEL),
160+ ASCENDC_TPL_UINT_SEL(A_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
161+ ASCENDC_TPL_UINT_SEL(B_TRANS, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_TRANS, MAT_MUL_TRANS),
162+ ASCENDC_TPL_UINT_SEL(BATCH_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_FOR_BATCH),
163+ ASCENDC_TPL_UINT_SEL(MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_K_EQUAL_ZERO),
164+ ASCENDC_TPL_UINT_SEL(FULL_LOAD, ASCENDC_TPL_UI_LIST, MAT_MUL_NO_FULL_LOAD),
165+ ASCENDC_TPL_UINT_SEL(L0C2OUT_MODEL, ASCENDC_TPL_UI_LIST, MAT_MUL_ON_THE_FLY),
166+ ASCENDC_TPL_TILING_STRUCT_SEL(MatMulV3KEqZeroBasicTilingData))
167+#endif
168+);