Merged
MC2 A2/A3 错误码首报与失败传播整改 #15178
ZZYuanAdd on 26 days ago
MC2 A2/A3 错误码首报与失败传播整改 #15178
Merged
Total: 81 files changed+5177-1141
| @@ -13,6 +13,7 @@ | |||
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | #include "mc2_log.h" | 15 | #include "mc2_log.h" |
| 16 | +#include "mc2_infer_failure_report.h" | ||
| 16 | #include "context_util.h" | 17 | #include "context_util.h" |
| 17 | #include "register/op_impl_registry.h" | 18 | #include "register/op_impl_registry.h" |
| 18 | #include "mc2_hcom_topo_info.h" | 19 | #include "mc2_hcom_topo_info.h" |
| @@ -22,8 +23,12 @@ using namespace ge; | |||
| 22 | namespace ops { | 23 | namespace ops { |
| 23 | static ge::graphStatus InferShapeAllGatherMatmul(gert::InferShapeContext* context) | 24 | static ge::graphStatus InferShapeAllGatherMatmul(gert::InferShapeContext* context) |
| 24 | { | 25 | { |
| 25 | - OP_LOGE_IF(AllGatherMatmulCommonInferShape(context, GATHER_OUT_V1) != GRAPH_SUCCESS, GRAPH_FAILED, | 26 | + OP_CHECK_IF(context == nullptr, |
| 26 | - context->GetNodeName(), "infer shape execute failed."); | 27 | + Mc2Error::ReportInferFailure("AllGatherMatmul", |
| 28 | + "InferShape entry: context actual=null; expected materialized context"), | ||
| 29 | + return ge::GRAPH_FAILED); | ||
| 30 | + OP_CHECK_IF(AllGatherMatmulCommonInferShape(context, GATHER_OUT_V1) != GRAPH_SUCCESS, | ||
| 31 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "infer shape execute failed."), return GRAPH_FAILED); | ||
| 27 | return ge::GRAPH_SUCCESS; | 32 | return ge::GRAPH_SUCCESS; |
| 28 | } | 33 | } |
| 29 | 34 | ||
| @@ -12,6 +12,10 @@ | |||
| 12 | * \file all_gather_matmul_tiling.cc | 12 | * \file all_gather_matmul_tiling.cc |
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | +#include <cstdlib> | ||
| 16 | +#include <cstring> | ||
| 17 | +#include <string> | ||
| 18 | +#include <vector> | ||
| 15 | #include "all_gather_matmul_tiling_base.h" | 19 | #include "all_gather_matmul_tiling_base.h" |
| 16 | #include "ops_utils.h" | 20 | #include "ops_utils.h" |
| 17 | 21 | ||
| @@ -99,7 +103,6 @@ static void PrintTilingData(Mc2Tiling::TileL2Tiling& tileL2Tiling) | |||
| 99 | } // namespace | 103 | } // namespace |
| 100 | 104 | ||
| 101 | namespace optiling { | 105 | namespace optiling { |
| 102 | - | ||
| 103 | static ge::graphStatus CalcMatmulTiling(mc2tiling::TilingArgs& args, ::TCubeTiling& cubeTiling, | 106 | static ge::graphStatus CalcMatmulTiling(mc2tiling::TilingArgs& args, ::TCubeTiling& cubeTiling, |
| 104 | Mc2Tiling::TileL2Tiling& l2Tiling); | 107 | Mc2Tiling::TileL2Tiling& l2Tiling); |
| 105 | 108 | ||
| @@ -128,7 +131,7 @@ static bool CheckOutputParamDim0(const gert::TilingContext* context) | |||
| 128 | static ge::graphStatus AllGatherParamsCheck(const gert::TilingContext* context) | 131 | static ge::graphStatus AllGatherParamsCheck(const gert::TilingContext* context) |
| 129 | { | 132 | { |
| 130 | OP_TILING_CHECK(mc2tiling::Mc2TilingUtils::CommonParamCheck(context) != ge::GRAPH_SUCCESS, | 133 | OP_TILING_CHECK(mc2tiling::Mc2TilingUtils::CommonParamCheck(context) != ge::GRAPH_SUCCESS, |
| 131 | - OP_LOGE(context->GetNodeName(), "common check failed"), return ge::GRAPH_FAILED); | 134 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "common check failed"), return ge::GRAPH_FAILED); |
| 132 | 135 | ||
| 133 | const gert::StorageShape* aShape = context->GetInputShape(INPUT_X1_IDX); | 136 | const gert::StorageShape* aShape = context->GetInputShape(INPUT_X1_IDX); |
| 134 | uint64_t valueOne = aShape->GetStorageShape().GetDim(DIM0_IDX); | 137 | uint64_t valueOne = aShape->GetStorageShape().GetDim(DIM0_IDX); |
| @@ -143,8 +146,7 @@ static ge::graphStatus AllGatherParamsCheck(const gert::TilingContext* context) | |||
| 143 | return ge::GRAPH_FAILED); | 146 | return ge::GRAPH_FAILED); |
| 144 | 147 | ||
| 145 | if (!CheckOutputParamDim0(context)) { | 148 | if (!CheckOutputParamDim0(context)) { |
| 146 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context->GetNodeName(), "output", "output_dim0_mismatch", | 149 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "output dim0 check failed"); |
| 147 | - "output dim0 check failed"); | ||
| 148 | return ge::GRAPH_FAILED; | 150 | return ge::GRAPH_FAILED; |
| 149 | } | 151 | } |
| 150 | 152 | ||
| @@ -197,7 +199,9 @@ ge::graphStatus AllGatherMatmulTilingBase::GetAllGatherFormulateTileCnt( | |||
| 197 | CutResult mCutGather = GetCutResult(tilingData, args); | 199 | CutResult mCutGather = GetCutResult(tilingData, args); |
| 198 | tilingData.param.tileCnt = mCutGather.numLongTile; | 200 | tilingData.param.tileCnt = mCutGather.numLongTile; |
| 199 | args.mValue = mCutGather.longTileLen; | 201 | args.mValue = mCutGather.longTileLen; |
| 200 | - CalcMatmulTiling(args, tilingData.tileTiling, tilingData.tileL2Tiling); | 202 | + if (CalcMatmulTiling(args, tilingData.tileTiling, tilingData.tileL2Tiling) != ge::GRAPH_SUCCESS) { |
| 203 | + return ge::GRAPH_FAILED; | ||
| 204 | + } | ||
| 201 | args.baseMLimit = mCutGather.longTileLen; | 205 | args.baseMLimit = mCutGather.longTileLen; |
| 202 | args.mValue = mCutGather.longTileLen * args.rankTileNum; | 206 | args.mValue = mCutGather.longTileLen * args.rankTileNum; |
| 203 | tilingData.param.tailM = mCutGather.shortTileLen; | 207 | tilingData.param.tailM = mCutGather.shortTileLen; |
| @@ -206,7 +210,9 @@ ge::graphStatus AllGatherMatmulTilingBase::GetAllGatherFormulateTileCnt( | |||
| 206 | args.mValue = mCutGather.shortTileLen; | 210 | args.mValue = mCutGather.shortTileLen; |
| 207 | tilingData.param.tailM = args.mValue; | 211 | tilingData.param.tailM = args.mValue; |
| 208 | tilingData.param.tailCnt = mCutGather.numShortTile; | 212 | tilingData.param.tailCnt = mCutGather.numShortTile; |
| 209 | - CalcMatmulTiling(args, tilingData.tailTiling, tilingData.tailL2Tiling); | 213 | + if (CalcMatmulTiling(args, tilingData.tailTiling, tilingData.tailL2Tiling) != ge::GRAPH_SUCCESS) { |
| 214 | + return ge::GRAPH_FAILED; | ||
| 215 | + } | ||
| 210 | args.baseMLimit = mCutGather.shortTileLen; | 216 | args.baseMLimit = mCutGather.shortTileLen; |
| 211 | args.mValue = mCutGather.shortTileLen * args.rankTileNum; | 217 | args.mValue = mCutGather.shortTileLen * args.rankTileNum; |
| 212 | } | 218 | } |
| @@ -226,7 +232,9 @@ ge::graphStatus AllGatherMatmulTilingBase::MCSpliteM(gert::TilingContext* ctx, | |||
| 226 | tilingData.param.tailCnt = 0; | 232 | tilingData.param.tailCnt = 0; |
| 227 | tilingData.param.tailM = 0; | 233 | tilingData.param.tailM = 0; |
| 228 | 234 | ||
| 229 | - CalcMatmulTiling(args, tilingData.tileTiling, tilingData.tileL2Tiling); | 235 | + if (CalcMatmulTiling(args, tilingData.tileTiling, tilingData.tileL2Tiling) != ge::GRAPH_SUCCESS) { |
| 236 | + return ge::GRAPH_FAILED; | ||
| 237 | + } | ||
| 230 | } else if (args.commTurn != 0) { | 238 | } else if (args.commTurn != 0) { |
| 231 | uint64_t splite = mc2tiling::SplitMValueByCommTurn(args.mValue, args.commTurn, args.inputDtypeSize); | 239 | uint64_t splite = mc2tiling::SplitMValueByCommTurn(args.mValue, args.commTurn, args.inputDtypeSize); |
| 232 | 240 | ||
| @@ -237,18 +245,26 @@ ge::graphStatus AllGatherMatmulTilingBase::MCSpliteM(gert::TilingContext* ctx, | |||
| 237 | tilingData.param.tileCnt = tileCnt; | 245 | tilingData.param.tileCnt = tileCnt; |
| 238 | args.mValue = splite; | 246 | args.mValue = splite; |
| 239 | tilingData.param.tailCnt = 0; | 247 | tilingData.param.tailCnt = 0; |
| 240 | - CalcMatmulTiling(args, tilingData.tileTiling, tilingData.tileL2Tiling); | 248 | + if (CalcMatmulTiling(args, tilingData.tileTiling, tilingData.tileL2Tiling) != ge::GRAPH_SUCCESS) { |
| 249 | + return ge::GRAPH_FAILED; | ||
| 250 | + } | ||
| 241 | tilingData.param.tailM = tileTail; | 251 | tilingData.param.tailM = tileTail; |
| 242 | if (tileTail != 0) { | 252 | if (tileTail != 0) { |
| 243 | args.mValue = tileTail; | 253 | args.mValue = tileTail; |
| 244 | tilingData.param.tailCnt = 1; | 254 | tilingData.param.tailCnt = 1; |
| 245 | - CalcMatmulTiling(args, tilingData.tailTiling, tilingData.tailL2Tiling); | 255 | + if (CalcMatmulTiling(args, tilingData.tailTiling, tilingData.tailL2Tiling) != ge::GRAPH_SUCCESS) { |
| 256 | + return ge::GRAPH_FAILED; | ||
| 257 | + } | ||
| 246 | } | 258 | } |
| 247 | args.mValue = splite; | 259 | args.mValue = splite; |
| 248 | } else { | 260 | } else { |
| 249 | - GetAllGatherFormulateTileCnt(ctx, tilingData, args); | 261 | + if (GetAllGatherFormulateTileCnt(ctx, tilingData, args) != ge::GRAPH_SUCCESS) { |
| 262 | + return ge::GRAPH_FAILED; | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | + if (MC2SetWorkspace(ctx, tilingData, args) != ge::GRAPH_SUCCESS) { | ||
| 266 | + return ge::GRAPH_FAILED; | ||
| 250 | } | 267 | } |
| 251 | - MC2SetWorkspace(ctx, tilingData, args); | ||
| 252 | 268 | ||
| 253 | return ge::GRAPH_SUCCESS; | 269 | return ge::GRAPH_SUCCESS; |
| 254 | } | 270 | } |
| @@ -355,7 +371,9 @@ ge::graphStatus AllGatherMatmulTilingBase::SetMatmulTilingAllGatherMatmul( | |||
| 355 | // 先计算出自己的Tiling | 371 | // 先计算出自己的Tiling |
| 356 | args.rankTileNum = 1; // 1: local matrix not tile | 372 | args.rankTileNum = 1; // 1: local matrix not tile |
| 357 | args.isLocal = true; | 373 | args.isLocal = true; |
| 358 | - CalcMatmulTiling(args, tilingData.localTiling, tilingData.localL2Tiling); | 374 | + if (CalcMatmulTiling(args, tilingData.localTiling, tilingData.localL2Tiling) != ge::GRAPH_SUCCESS) { |
| 375 | + return ge::GRAPH_FAILED; | ||
| 376 | + } | ||
| 359 | if (tilingData.param.rankID == 0) { | 377 | if (tilingData.param.rankID == 0) { |
| 360 | PrintTilingData(tilingData.localTiling); | 378 | PrintTilingData(tilingData.localTiling); |
| 361 | PrintTilingData(tilingData.localL2Tiling); | 379 | PrintTilingData(tilingData.localL2Tiling); |
| @@ -374,7 +392,9 @@ ge::graphStatus AllGatherMatmulTilingBase::SetMatmulTilingAllGatherMatmul( | |||
| 374 | 392 | ||
| 375 | args.isLocal = false; | 393 | args.isLocal = false; |
| 376 | 394 | ||
| 377 | - MCSpliteM(context, tilingData, args); | 395 | + if (MCSpliteM(context, tilingData, args) != ge::GRAPH_SUCCESS) { |
| 396 | + return ge::GRAPH_FAILED; | ||
| 397 | + } | ||
| 378 | uint64_t tilingKey = 0U; | 398 | uint64_t tilingKey = 0U; |
| 379 | // 当前GetTilingKey函数中使用了Mc2Msg结构体,因而无法归一化,此处使用自己的tilingkey计算函数,确保计算逻辑与旧的key保持一致 | 399 | // 当前GetTilingKey函数中使用了Mc2Msg结构体,因而无法归一化,此处使用自己的tilingkey计算函数,确保计算逻辑与旧的key保持一致 |
| 380 | UpdateTilingKey(tilingKey, tilingData, isBias); | 400 | UpdateTilingKey(tilingKey, tilingData, isBias); |
| @@ -413,8 +433,11 @@ static ge::graphStatus CalcMatmulTiling(mc2tiling::TilingArgs& args, ::TCubeTili | |||
| 413 | cubeTiling.Kb = kValue; | 433 | cubeTiling.Kb = kValue; |
| 414 | } else { | 434 | } else { |
| 415 | if (mm.GetTiling(cubeTiling) == -1) { | 435 | if (mm.GetTiling(cubeTiling) == -1) { |
| 416 | - OP_LOGE("AllGatherMatmul", "mValue %lu, nValue %lu, kValue %lu, aicCoreNum %lu", mValue, nValue, kValue, | 436 | + const std::string detail = "MultiCoreMatmulTiling::GetTiling returned -1; M=" + std::to_string(mValue) + |
| 417 | - args.aicCoreNum); | 437 | + ", N=" + std::to_string(nValue) + ", K=" + std::to_string(kValue) + |
| 438 | + ", AIC cores=" + std::to_string(args.aicCoreNum) + | ||
| 439 | + "; check the selected matmul tiling configuration and platform resources"; | ||
| 440 | + OP_LOGE("AllGatherMatmul", "%s", detail.c_str()); | ||
| 418 | return ge::GRAPH_FAILED; | 441 | return ge::GRAPH_FAILED; |
| 419 | } | 442 | } |
| 420 | } | 443 | } |
| @@ -486,8 +509,13 @@ static ge::graphStatus MC2SetWorkspace(gert::TilingContext* context, Mc2Tiling:: | |||
| 486 | mc2tiling::TilingArgs& args) | 509 | mc2tiling::TilingArgs& args) |
| 487 | { | 510 | { |
| 488 | size_t* workspaces = context->GetWorkspaceSizes(1); | 511 | size_t* workspaces = context->GetWorkspaceSizes(1); |
| 489 | - OP_TILING_CHECK(workspaces == nullptr, OP_LOGE(context->GetNodeName(), "get workspace failed"), | 512 | + OP_TILING_CHECK( |
| 490 | - return ge::GRAPH_FAILED); | 513 | + workspaces == nullptr, |
| 514 | + OP_LOGE(context->GetNodeName(), | ||
| 515 | + "MC2SetWorkspace: missing workspace holder; required workspace count=1; rebuild the tiling context " | ||
| 516 | + "with the required metadata; actual workspace count=%s", | ||
| 517 | + std::to_string(context->GetWorkspaceNum()).c_str()), | ||
| 518 | + return ge::GRAPH_FAILED); | ||
| 491 | uint64_t storageA = GetStorage_a(tilingData, args); | 519 | uint64_t storageA = GetStorage_a(tilingData, args); |
| 492 | 520 | ||
| 493 | int biasLen = 0; | 521 | int biasLen = 0; |
| @@ -538,18 +566,34 @@ ge::graphStatus AllGatherMatmulTilingBase::InitHcclParam(const gert::TilingConte | |||
| 538 | Mc2Tiling::AllGatherMatmulTilingData* tilingData, | 566 | Mc2Tiling::AllGatherMatmulTilingData* tilingData, |
| 539 | const char* group, mc2tiling::TilingArgs& args) | 567 | const char* group, mc2tiling::TilingArgs& args) |
| 540 | { | 568 | { |
| 569 | + // The 9.1 Mc2CcTiling group buffer includes the terminating zero in its 128 bytes. | ||
| 570 | + constexpr size_t groupBufferBytes = 128; | ||
| 571 | + if (group == nullptr || std::strlen(group) >= groupBufferBytes) { | ||
| 572 | + const std::string reason = group == nullptr ? | ||
| 573 | + "required group attribute is absent" : | ||
| 574 | + "group name length=" + std::to_string(std::strlen(group)) + | ||
| 575 | + "; expected fewer than " + std::to_string(groupBufferBytes) + " bytes"; | ||
| 576 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "group", reason.c_str()); | ||
| 577 | + return ge::GRAPH_FAILED; | ||
| 578 | + } | ||
| 541 | std::string algConfig = GetAlgConfig(tilingData, args); | 579 | std::string algConfig = GetAlgConfig(tilingData, args); |
| 542 | Mc2CcTilingConfig mc2CcTilingConfig(group, tilingData->param.commtype, algConfig); | 580 | Mc2CcTilingConfig mc2CcTilingConfig(group, tilingData->param.commtype, algConfig); |
| 543 | uint8_t skipBufferWindowCopy = (tilingData->param.gatherLen == 0) ? | 581 | uint8_t skipBufferWindowCopy = (tilingData->param.gatherLen == 0) ? |
| 544 | static_cast<uint8_t>(mc2tiling::MC2_BUFFER_TYPE::MC2_BUFFER_TYPE_DEFAULT) : | 582 | static_cast<uint8_t>(mc2tiling::MC2_BUFFER_TYPE::MC2_BUFFER_TYPE_DEFAULT) : |
| 545 | static_cast<uint8_t>(mc2tiling::MC2_BUFFER_TYPE::MC2_BUFFER_TYPE_OUTPUT); | 583 | static_cast<uint8_t>(mc2tiling::MC2_BUFFER_TYPE::MC2_BUFFER_TYPE_OUTPUT); |
| 546 | mc2CcTilingConfig.SetSkipBufferWindowCopy(skipBufferWindowCopy); | 584 | mc2CcTilingConfig.SetSkipBufferWindowCopy(skipBufferWindowCopy); |
| 547 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tilingData->mc2InitTiling) != 0, | 585 | + const auto initRet = mc2CcTilingConfig.GetTiling(tilingData->mc2InitTiling); |
| 548 | - OP_LOGE(context->GetNodeName(), "mc2CcTilingConfig mc2tiling GetTiling mc2InitTiling failed"), | 586 | + if (initRet != 0) { |
| 549 | - return ge::GRAPH_FAILED); | 587 | + OP_LOGE(context->GetNodeName(), "MC2 tiling initialization failed: GetTiling(init) returned %u", initRet); |
| 550 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tilingData->mc2CcTiling) != 0, | 588 | + return ge::GRAPH_FAILED; |
| 551 | - OP_LOGE(context->GetNodeName(), "mc2CcTilingConfig mc2tiling GetTiling mc2CcTiling failed"), | 589 | + } |
| 552 | - return ge::GRAPH_FAILED); | 590 | + const auto commRet = mc2CcTilingConfig.GetTiling(tilingData->mc2CcTiling); |
| 591 | + if (commRet != 0) { | ||
| 592 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), | ||
| 593 | + "Mc2CcTiling invariant failed after initialization and group length validation; rc=%u", | ||
| 594 | + commRet); | ||
| 595 | + return ge::GRAPH_FAILED; | ||
| 596 | + } | ||
| 553 | return ge::GRAPH_SUCCESS; | 597 | return ge::GRAPH_SUCCESS; |
| 554 | } | 598 | } |
| 555 | 599 | ||
| @@ -563,7 +607,10 @@ ge::graphStatus AllGatherMatmulTilingBase::InitAllGatherCommParams(gert::TilingC | |||
| 563 | auto isTransB = attrs->GetAttrPointer<bool>(index++); | 607 | auto isTransB = attrs->GetAttrPointer<bool>(index++); |
| 564 | auto gatherIndex = attrs->GetAttrPointer<int64_t>(index++); | 608 | auto gatherIndex = attrs->GetAttrPointer<int64_t>(index++); |
| 565 | auto commTurnPtr = attrs->GetAttrPointer<int64_t>(index++); | 609 | auto commTurnPtr = attrs->GetAttrPointer<int64_t>(index++); |
| 566 | - OP_TILING_CHECK(commTurnPtr == nullptr, OP_LOGE(context->GetNodeName(), "commTurn is nullptr"), | 610 | + OP_TILING_CHECK(commTurnPtr == nullptr, |
| 611 | + OP_LOGE(context->GetNodeName(), | ||
| 612 | + "InitAllGatherCommParams: defaulted comm_turn attribute is absent from RuntimeAttrs; " | ||
| 613 | + "rebuild the tiling context with the required metadata"), | ||
| 567 | return ge::GRAPH_FAILED); | 614 | return ge::GRAPH_FAILED); |
| 568 | auto commTurn = *commTurnPtr; | 615 | auto commTurn = *commTurnPtr; |
| 569 | 616 | ||
| @@ -624,16 +671,19 @@ ge::graphStatus AllGatherMatmulTilingBase::AllGatherMatmulTilingFunc(gert::Tilin | |||
| 624 | OP_TILING_CHECK(group_ == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "group"), | 671 | OP_TILING_CHECK(group_ == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "group"), |
| 625 | return ge::GRAPH_FAILED); | 672 | return ge::GRAPH_FAILED); |
| 626 | if (AllGatherParamsCheck(context) != ge::GRAPH_SUCCESS) { | 673 | if (AllGatherParamsCheck(context) != ge::GRAPH_SUCCESS) { |
| 627 | - OP_LOGE(context->GetNodeName(), "AllGatherParamsCheck failed"); | 674 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "AllGatherParamsCheck failed"); |
| 628 | return ge::GRAPH_FAILED; | 675 | return ge::GRAPH_FAILED; |
| 629 | } | 676 | } |
| 630 | if (InitAllGatherCommParams(context, tilingData, args) != ge::GRAPH_SUCCESS) { | 677 | if (InitAllGatherCommParams(context, tilingData, args) != ge::GRAPH_SUCCESS) { |
| 631 | return ge::GRAPH_FAILED; | 678 | return ge::GRAPH_FAILED; |
| 632 | } | 679 | } |
| 633 | 680 | ||
| 634 | - SetMatmulTilingAllGatherMatmul(context, *tilingData, args); | 681 | + if (SetMatmulTilingAllGatherMatmul(context, *tilingData, args) != ge::GRAPH_SUCCESS) { |
| 682 | + return ge::GRAPH_FAILED; | ||
| 683 | + } | ||
| 635 | OP_TILING_CHECK(InitHcclParam(context, tilingData, group_, args) != ge::GRAPH_SUCCESS, | 684 | OP_TILING_CHECK(InitHcclParam(context, tilingData, group_, args) != ge::GRAPH_SUCCESS, |
| 636 | - OP_LOGE(context->GetNodeName(), "Tiling InitHcclParam failed."), return ge::GRAPH_FAILED); | 685 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "Tiling InitHcclParam failed."), |
| 686 | + return ge::GRAPH_FAILED); | ||
| 637 | return ge::GRAPH_SUCCESS; | 687 | return ge::GRAPH_SUCCESS; |
| 638 | } | 688 | } |
| 639 | } // namespace optiling | 689 | } // namespace optiling |
| @@ -8,6 +8,7 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | +#include "mc2/common/op_api/mc2_api_error.h" | ||
| 11 | #include "aclnn_all_gather_matmul_v2.h" | 12 | #include "aclnn_all_gather_matmul_v2.h" |
| 12 | #include "securec.h" | 13 | #include "securec.h" |
| 13 | #include "acl/acl.h" | 14 | #include "acl/acl.h" |
| @@ -696,7 +697,7 @@ aclnnStatus aclnnAllGatherMatmulV2GetWorkspaceSize(const aclTensor* x1, const ac | |||
| 696 | { | 697 | { |
| 697 | aclnnStatus ret = ACLNN_SUCCESS; | 698 | aclnnStatus ret = ACLNN_SUCCESS; |
| 698 | if (commMode == nullptr) { | 699 | if (commMode == nullptr) { |
| 699 | - OP_LOGE_LIBOPAPI_REPORT("aclnnAllGatherMatmulV2", "CommMode is null."); | 700 | + Mc2Aclnn::ReportRequiredApiPointer(__func__, "commMode"); |
| 700 | return ACLNN_ERR_INNER_NULLPTR; | 701 | return ACLNN_ERR_INNER_NULLPTR; |
| 701 | } | 702 | } |
| 702 | if (GetCurrentPlatformInfo().GetCurNpuArch() == Ops::Base::DAV_3510) { | 703 | if (GetCurrentPlatformInfo().GetCurNpuArch() == Ops::Base::DAV_3510) { |
| @@ -729,7 +730,7 @@ aclnnStatus aclnnAllGatherMatmulV2(void* workspace, uint64_t workspaceSize, aclO | |||
| 729 | } | 730 | } |
| 730 | 731 | ||
| 731 | if (executor == nullptr) { | 732 | if (executor == nullptr) { |
| 732 | - OP_LOGE_LIBOPAPI_REPORT("aclnnAllGatherMatmulV2", "executor is null."); | 733 | + Mc2Aclnn::ReportRequiredApiPointer(__func__, "executor"); |
| 733 | return ACLNN_ERR_INNER_NULLPTR; | 734 | return ACLNN_ERR_INNER_NULLPTR; |
| 734 | } | 735 | } |
| 735 | if (NnopbaseSetHcclServerType) { | 736 | if (NnopbaseSetHcclServerType) { |
| @@ -13,6 +13,7 @@ | |||
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | #include "mc2_log.h" | 15 | #include "mc2_log.h" |
| 16 | +#include "mc2_infer_failure_report.h" | ||
| 16 | #include "register/op_impl_registry.h" | 17 | #include "register/op_impl_registry.h" |
| 17 | #include "mc2_hcom_topo_info.h" | 18 | #include "mc2_hcom_topo_info.h" |
| 18 | #include "op_host/mc2_common_infershape.h" | 19 | #include "op_host/mc2_common_infershape.h" |
| @@ -30,14 +31,30 @@ const size_t INDEX_GATHER_OUT = 1; | |||
| 30 | 31 | ||
| 31 | static ge::graphStatus InferShapeAllGatherMatmulV2(gert::InferShapeContext* context) | 32 | static ge::graphStatus InferShapeAllGatherMatmulV2(gert::InferShapeContext* context) |
| 32 | { | 33 | { |
| 33 | - OP_LOGE_IF(AllGatherMatmulCommonInferShape(context, GATHER_OUT_V2) != GRAPH_SUCCESS, GRAPH_FAILED, | 34 | + OP_CHECK_IF(context == nullptr, |
| 34 | - context->GetNodeName(), "infer shape execute failed."); | 35 | + Mc2Error::ReportInferFailure("AllGatherMatmulV2", |
| 36 | + "InferShape entry: context actual=null; expected materialized context"), | ||
| 37 | + return ge::GRAPH_FAILED); | ||
| 38 | + OP_CHECK_IF(AllGatherMatmulCommonInferShape(context, GATHER_OUT_V2) != GRAPH_SUCCESS, | ||
| 39 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "infer shape execute failed."), return GRAPH_FAILED); | ||
| 35 | auto attrs = context->GetAttrs(); | 40 | auto attrs = context->GetAttrs(); |
| 36 | - OPS_CHECK_NULL_WITH_CONTEXT(context, attrs); | 41 | + OP_CHECK_IF(attrs == nullptr, |
| 42 | + Mc2Error::ReportInferFailure( | ||
| 43 | + context->GetNodeName(), | ||
| 44 | + "InferShapeAllGatherMatmulV2: GetAttrs actual=null; expected schema attribute metadata"), | ||
| 45 | + return ge::GRAPH_FAILED); | ||
| 37 | const bool* isAmaxOut = attrs->GetAttrPointer<bool>(AG_IS_AMAX_OUT); | 46 | const bool* isAmaxOut = attrs->GetAttrPointer<bool>(AG_IS_AMAX_OUT); |
| 38 | - OPS_CHECK_NULL_WITH_CONTEXT(context, isAmaxOut); | 47 | + OP_CHECK_IF(isAmaxOut == nullptr, |
| 48 | + Mc2Error::ReportInferFailure(context->GetNodeName(), | ||
| 49 | + "InferShapeAllGatherMatmulV2: is_amax_out pointer actual=null; expected " | ||
| 50 | + "materialized schema-defaulted attribute"), | ||
| 51 | + return ge::GRAPH_FAILED); | ||
| 39 | gert::Shape* amaxOutShape = context->GetOutputShape(2); | 52 | gert::Shape* amaxOutShape = context->GetOutputShape(2); |
| 40 | - OPS_CHECK_NULL_WITH_CONTEXT(context, amaxOutShape); | 53 | + OP_CHECK_IF( |
| 54 | + amaxOutShape == nullptr, | ||
| 55 | + Mc2Error::ReportInferFailure(context->GetNodeName(), "InferShapeAllGatherMatmulV2: Output amax_out shape " | ||
| 56 | + "holder actual=null; expected materialized output holder"), | ||
| 57 | + return ge::GRAPH_FAILED); | ||
| 41 | if (*isAmaxOut) { | 58 | if (*isAmaxOut) { |
| 42 | amaxOutShape->SetDimNum(1); | 59 | amaxOutShape->SetDimNum(1); |
| 43 | amaxOutShape->SetDim(0, 1); | 60 | amaxOutShape->SetDim(0, 1); |
| @@ -50,8 +67,8 @@ static ge::graphStatus InferShapeAllGatherMatmulV2(gert::InferShapeContext* cont | |||
| 50 | 67 | ||
| 51 | static ge::graphStatus InferDataTypeAllGatherMatmulV2(gert::InferDataTypeContext* context) | 68 | static ge::graphStatus InferDataTypeAllGatherMatmulV2(gert::InferDataTypeContext* context) |
| 52 | { | 69 | { |
| 53 | - OP_LOGE_IF(InferMatmulOutputDataType(context, INDEX_IN_X1, INDEX_ATTR_Y_DTYPE, INDEX_OUT) != GRAPH_SUCCESS, | 70 | + OP_CHECK_IF(InferMatmulOutputDataType(context, INDEX_IN_X1, INDEX_ATTR_Y_DTYPE, INDEX_OUT) != GRAPH_SUCCESS, |
| 54 | - GRAPH_FAILED, context->GetNodeName(), "Infer output dtype failed."); | 71 | + OP_LOGE_LIBOPAPI_REPORT(context->GetNodeName(), "Infer output dtype failed."), return GRAPH_FAILED); |
| 55 | const auto x1Dtype = context->GetInputDataType(INDEX_IN_X1); | 72 | const auto x1Dtype = context->GetInputDataType(INDEX_IN_X1); |
| 56 | context->SetOutputDataType(INDEX_GATHER_OUT, x1Dtype); | 73 | context->SetOutputDataType(INDEX_GATHER_OUT, x1Dtype); |
| 57 | return GRAPH_SUCCESS; | 74 | return GRAPH_SUCCESS; |
| @@ -14,6 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include "vector" | 16 | #include "vector" |
| 17 | +#include "mc2/common/utils/mc2_hccl_tiling_report.h" | ||
| 17 | #include "platform/platform_infos_def.h" | 18 | #include "platform/platform_infos_def.h" |
| 18 | #include "register/tilingdata_base.h" | 19 | #include "register/tilingdata_base.h" |
| 19 | #include "tiling/tiling_api.h" | 20 | #include "tiling/tiling_api.h" |
| @@ -269,20 +270,29 @@ static ge::graphStatus AllGatherMatmulAIVModeCheckAttrAndSetTiling(const gert::T | |||
| 269 | AllGatherMatmulAIVModeInfo& info) | 270 | AllGatherMatmulAIVModeInfo& info) |
| 270 | { | 271 | { |
| 271 | auto attrs = context->GetAttrs(); | 272 | auto attrs = context->GetAttrs(); |
| 272 | - OP_CHECK_NULL_WITH_CONTEXT(context, attrs); | 273 | + OP_TILING_CHECK(attrs == nullptr, |
| 274 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "RuntimeAttrs holder is absent"), | ||
| 275 | + return ge::GRAPH_FAILED); | ||
| 273 | 276 | ||
| 274 | // Attr相关tilingdata的设置、校验、打印 | 277 | // Attr相关tilingdata的设置、校验、打印 |
| 275 | auto groupPtr = attrs->GetAttrPointer<char>(static_cast<int>(ATTR_GROUP_INDEX)); | 278 | auto groupPtr = attrs->GetAttrPointer<char>(static_cast<int>(ATTR_GROUP_INDEX)); |
| 276 | auto isTransposeX1 = attrs->GetAttrPointer<bool>(ATTR_IS_TRANS_X1); | 279 | auto isTransposeX1 = attrs->GetAttrPointer<bool>(ATTR_IS_TRANS_X1); |
| 277 | auto isTransposeX2 = attrs->GetAttrPointer<bool>(ATTR_IS_TRANS_X2); | 280 | auto isTransposeX2 = attrs->GetAttrPointer<bool>(ATTR_IS_TRANS_X2); |
| 278 | - OP_TILING_CHECK(groupPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "group"), | 281 | + OP_TILING_CHECK( |
| 279 | - return ge::GRAPH_FAILED); | 282 | + groupPtr == nullptr, |
| 280 | - if (strlen(groupPtr) == 0) { | 283 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "group", "Required group is absent"), |
| 281 | - OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "group", "empty string", "non-empty communication group"); | 284 | + return ge::GRAPH_FAILED); |
| 285 | + if (strlen(groupPtr) == 0 || strlen(groupPtr) >= 128) { | ||
| 286 | + OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "group", std::to_string(strlen(groupPtr)).c_str(), | ||
| 287 | + "communication group length in [1, 127]"); | ||
| 282 | return GRAPH_FAILED; | 288 | return GRAPH_FAILED; |
| 283 | } | 289 | } |
| 284 | - OP_CHECK_NULL_WITH_CONTEXT(context, isTransposeX2); | 290 | + OP_TILING_CHECK(isTransposeX2 == nullptr, |
| 285 | - OP_CHECK_NULL_WITH_CONTEXT(context, isTransposeX1); | 291 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "Default is_trans_b attribute is absent"), |
| 292 | + return ge::GRAPH_FAILED); | ||
| 293 | + OP_TILING_CHECK(isTransposeX1 == nullptr, | ||
| 294 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "Default is_trans_a attribute is absent"), | ||
| 295 | + return ge::GRAPH_FAILED); | ||
| 286 | 296 | ||
| 287 | info.isTransposeX1 = *isTransposeX1 ? *isTransposeX1 : false; | 297 | info.isTransposeX1 = *isTransposeX1 ? *isTransposeX1 : false; |
| 288 | info.isTransposeX2 = *isTransposeX2 ? *isTransposeX2 : false; | 298 | info.isTransposeX2 = *isTransposeX2 ? *isTransposeX2 : false; |
| @@ -501,17 +511,28 @@ void SetTilingData(CoCTiling& cocTilingData, AllGatherMatmulAIVModeInfo& info, i | |||
| 501 | 511 | ||
| 502 | ge::graphStatus AllGatherMatmulTilingAIVModeFunc(gert::TilingContext* context) | 512 | ge::graphStatus AllGatherMatmulTilingAIVModeFunc(gert::TilingContext* context) |
| 503 | { | 513 | { |
| 514 | + OP_TILING_CHECK(context == nullptr, Mc2Error::ReportTilingFailure("AllGatherMatmulV2", "Tiling context is null"), | ||
| 515 | + return ge::GRAPH_FAILED); | ||
| 516 | + OP_TILING_CHECK(context->GetPlatformInfo() == nullptr, | ||
| 517 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "Platform resource metadata is absent"), | ||
| 518 | + return ge::GRAPH_FAILED); | ||
| 504 | const char* nodeName = context->GetNodeName(); | 519 | const char* nodeName = context->GetNodeName(); |
| 505 | OP_LOGI("Enter AllGatherMatmulAIVMode tiling func."); | 520 | OP_LOGI("Enter AllGatherMatmulAIVMode tiling func."); |
| 506 | 521 | ||
| 507 | // 涉及SyncAll,设置batch mode模式,所有核同时启动 | 522 | // 涉及SyncAll,设置batch mode模式,所有核同时启动 |
| 508 | uint32_t batchMode = 1U; | 523 | uint32_t batchMode = 1U; |
| 509 | auto ret = context->SetScheduleMode(batchMode); | 524 | auto ret = context->SetScheduleMode(batchMode); |
| 510 | - MC2_CHECK_LOG_RET(nodeName, ret); | 525 | + OP_TILING_CHECK(ret != ge::GRAPH_SUCCESS, |
| 526 | + Mc2Error::ReportTilingFailure(nodeName, "Schedule mode output slot is absent"), | ||
| 527 | + return ge::GRAPH_FAILED); | ||
| 511 | 528 | ||
| 512 | // 1. tilingData | 529 | // 1. tilingData |
| 513 | AllGatherMatmulAIVModeTilingData* tilingData = context->GetTilingData<AllGatherMatmulAIVModeTilingData>(); | 530 | AllGatherMatmulAIVModeTilingData* tilingData = context->GetTilingData<AllGatherMatmulAIVModeTilingData>(); |
| 514 | - OP_TILING_CHECK(tilingData == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "tilingData"), return ge::GRAPH_FAILED); | 531 | + OP_TILING_CHECK(tilingData == nullptr, |
| 532 | + Mc2Error::ReportTilingFailure( | ||
| 533 | + nodeName, "Typed tiling buffer is absent or too small; required " + | ||
| 534 | + std::to_string(sizeof(AllGatherMatmulAIVModeTilingData)) + " bytes"), | ||
| 535 | + return ge::GRAPH_FAILED); | ||
| 515 | OP_LOGI(nodeName, "AllGatherMatmulAIVMode get tilingData."); | 536 | OP_LOGI(nodeName, "AllGatherMatmulAIVMode get tilingData."); |
| 516 | AllGatherMatmulAIVModeInfo& info = tilingData->allGatherMatmulInfo; | 537 | AllGatherMatmulAIVModeInfo& info = tilingData->allGatherMatmulInfo; |
| 517 | OP_LOGI(nodeName, "AllGatherMatmulAIVMode get tilingData info."); | 538 | OP_LOGI(nodeName, "AllGatherMatmulAIVMode get tilingData info."); |
| @@ -533,9 +554,10 @@ ge::graphStatus AllGatherMatmulTilingAIVModeFunc(gert::TilingContext* context) | |||
| 533 | const char* opName = context->GetNodeName(); | 554 | const char* opName = context->GetNodeName(); |
| 534 | OP_TILING_CHECK(mc2tiling::CheckHcclBuffSize(context, ATTR_GROUP_INDEX, static_cast<int32_t>(CCL_BUFFER_MIN_BYTES), | 555 | OP_TILING_CHECK(mc2tiling::CheckHcclBuffSize(context, ATTR_GROUP_INDEX, static_cast<int32_t>(CCL_BUFFER_MIN_BYTES), |
| 535 | opName) != ge::GRAPH_SUCCESS, | 556 | opName) != ge::GRAPH_SUCCESS, |
| 536 | - OP_LOGE(opName, "Check CCL buffer size failed"), return ge::GRAPH_FAILED); | 557 | + OP_LOGE_WITHOUT_REPORT(opName, "Check CCL buffer size failed"), return ge::GRAPH_FAILED); |
| 537 | int64_t rankSize = 0; | 558 | int64_t rankSize = 0; |
| 538 | - mc2tiling::GetRankSize(opName, group, rankSize); | 559 | + OP_TILING_CHECK(!mc2tiling::GetRankSize(opName, group, rankSize), |
| 560 | + OP_LOGE_WITHOUT_REPORT(opName, "Communication group size query failed"), return ge::GRAPH_FAILED); | ||
| 539 | coctiling.rankSize = rankSize; | 561 | coctiling.rankSize = rankSize; |
| 540 | OP_TILING_CHECK( | 562 | OP_TILING_CHECK( |
| 541 | rankSize != 2 && rankSize != 4 && rankSize != 8, | 563 | rankSize != 2 && rankSize != 4 && rankSize != 8, |
| @@ -548,7 +570,16 @@ ge::graphStatus AllGatherMatmulTilingAIVModeFunc(gert::TilingContext* context) | |||
| 548 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | 570 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); |
| 549 | auto aicNum = ascendcPlatform.GetCoreNumAic(); | 571 | auto aicNum = ascendcPlatform.GetCoreNumAic(); |
| 550 | auto aivNum = ascendcPlatform.GetCoreNumAiv(); | 572 | auto aivNum = ascendcPlatform.GetCoreNumAiv(); |
| 573 | + OP_TILING_CHECK(aivNum == 0 || info.totalUbSize == 0, | ||
| 574 | + Mc2Error::ReportTilingFailure(nodeName, "Available AIV=" + std::to_string(aivNum) + | ||
| 575 | + ", UB bytes=" + std::to_string(info.totalUbSize) + | ||
| 576 | + "; positive AIV and UB resources are required"), | ||
| 577 | + return ge::GRAPH_FAILED); | ||
| 551 | numBlocks = ascendcPlatform.CalcTschBlockDim(aivNum, aicNum, aivNum); | 578 | numBlocks = ascendcPlatform.CalcTschBlockDim(aivNum, aicNum, aivNum); |
| 579 | + OP_TILING_CHECK( | ||
| 580 | + numBlocks == 0, | ||
| 581 | + Mc2Error::ReportTilingFailure(nodeName, "Calculated launch block count=0; check platform scheduling resources"), | ||
| 582 | + return ge::GRAPH_FAILED); | ||
| 552 | context->SetBlockDim(numBlocks); | 583 | context->SetBlockDim(numBlocks); |
| 553 | coctiling.numBlocks = numBlocks; | 584 | coctiling.numBlocks = numBlocks; |
| 554 | 585 | ||
| @@ -578,7 +609,9 @@ ge::graphStatus AllGatherMatmulTilingAIVModeFunc(gert::TilingContext* context) | |||
| 578 | 609 | ||
| 579 | // 4. workspace | 610 | // 4. workspace |
| 580 | size_t* workSpaces = context->GetWorkspaceSizes(1); | 611 | size_t* workSpaces = context->GetWorkspaceSizes(1); |
| 581 | - OP_TILING_CHECK(workSpaces == nullptr, OP_LOGE(nodeName, "workSpaces is nullptr."), return ge::GRAPH_FAILED); | 612 | + OP_TILING_CHECK(workSpaces == nullptr, |
| 613 | + Mc2Error::ReportTilingFailure(nodeName, "Workspace size holder is absent; required one slot"), | ||
| 614 | + return ge::GRAPH_FAILED); | ||
| 582 | 615 | ||
| 583 | info.is910C = false; | 616 | info.is910C = false; |
| 584 | fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo(); | 617 | fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo(); |
| @@ -612,22 +645,18 @@ ge::graphStatus AllGatherMatmulTilingAIVModeFunc(gert::TilingContext* context) | |||
| 612 | uint32_t opType = 6; | 645 | uint32_t opType = 6; |
| 613 | std::string algConfig = "AllGather=level0:fullmesh"; | 646 | std::string algConfig = "AllGather=level0:fullmesh"; |
| 614 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType, algConfig); | 647 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType, algConfig); |
| 615 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tilingData->mc2InitTiling) != 0, | 648 | + if (Mc2Error::GetValidatedHcclTiling(mc2CcTilingConfig, tilingData->mc2InitTiling, tilingData->mc2CcTiling, |
| 616 | - OP_LOGE(nodeName, "mc2CcTilingConfig mc2tiling GetTiling mc2InitTiling failed"), | 649 | + nodeName) != ge::GRAPH_SUCCESS) { |
| 617 | - return ge::GRAPH_FAILED); | 650 | + return ge::GRAPH_FAILED; |
| 618 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tilingData->mc2CcTiling) != 0, | 651 | + } |
| 619 | - OP_LOGE(nodeName, "mc2CcTilingConfig mc2tiling GetTiling mc2CcTiling failed"), | ||
| 620 | - return ge::GRAPH_FAILED); | ||
| 621 | } else { | 652 | } else { |
| 622 | uint32_t opType = 18; | 653 | uint32_t opType = 18; |
| 623 | std::string algConfig = "MultiPut=level0:fullmesh"; | 654 | std::string algConfig = "MultiPut=level0:fullmesh"; |
| 624 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType, algConfig); | 655 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType, algConfig); |
| 625 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tilingData->mc2InitTiling) != 0, | 656 | + if (Mc2Error::GetValidatedHcclTiling(mc2CcTilingConfig, tilingData->mc2InitTiling, tilingData->mc2CcTiling, |
| 626 | - OP_LOGE(nodeName, "mc2CcTilingConfig mc2tiling GetTiling mc2InitTiling failed"), | 657 | + nodeName) != ge::GRAPH_SUCCESS) { |
| 627 | - return ge::GRAPH_FAILED); | 658 | + return ge::GRAPH_FAILED; |
| 628 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tilingData->mc2CcTiling) != 0, | 659 | + } |
| 629 | - OP_LOGE(nodeName, "mc2CcTilingConfig mc2tiling GetTiling mc2CcTiling failed"), | ||
| 630 | - return ge::GRAPH_FAILED); | ||
| 631 | } | 660 | } |
| 632 | 661 | ||
| 633 | PrintfTilingData(info, coctiling); | 662 | PrintfTilingData(info, coctiling); |
| @@ -0,0 +1,39 @@ | |||
| 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 <gtest/gtest.h> | ||
| 12 | +#include "../../../op_api/aclnn_all_gather_matmul_v2.h" | ||
| 13 | +#include "../../../../common/tests/ut/api_pointer_error_assertions.h" | ||
| 14 | + | ||
| 15 | +TEST(AllGatherMatmulV2PointerErrors, MissingCommModeReportsOnce) | ||
| 16 | +{ | ||
| 17 | + Mc2ErrorCodeUT::ExcelErrorReportScope errors; | ||
| 18 | + uint64_t size = 0; | ||
| 19 | + aclOpExecutor* executor = nullptr; | ||
| 20 | + EXPECT_EQ(aclnnAllGatherMatmulV2GetWorkspaceSize(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, "group", | ||
| 21 | + 0, 1, 0, 8, nullptr, nullptr, nullptr, nullptr, &size, &executor), | ||
| 22 | + ACLNN_ERR_INNER_NULLPTR); | ||
| 23 | + Mc2ErrorCodeUT::ExpectRequiredApiPointerError("aclnnAllGatherMatmulV2GetWorkspaceSize", "commMode"); | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +TEST(AllGatherMatmulV2PointerErrors, NonemptyLaunchMissingExecutorReportsOnce) | ||
| 27 | +{ | ||
| 28 | + Mc2ErrorCodeUT::ExcelErrorReportScope errors; | ||
| 29 | + uint64_t workspace = 0; | ||
| 30 | + EXPECT_EQ(aclnnAllGatherMatmulV2(&workspace, sizeof(workspace), nullptr, nullptr), ACLNN_ERR_INNER_NULLPTR); | ||
| 31 | + Mc2ErrorCodeUT::ExpectRequiredApiPointerError("aclnnAllGatherMatmulV2", "executor"); | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +TEST(AllGatherMatmulV2PointerErrors, EmptyLaunchKeepsSuccessWithoutFormalError) | ||
| 35 | +{ | ||
| 36 | + Mc2ErrorCodeUT::ExcelErrorReportScope errors; | ||
| 37 | + EXPECT_EQ(aclnnAllGatherMatmulV2(nullptr, 0, nullptr, nullptr), ACLNN_SUCCESS); | ||
| 38 | + EXPECT_TRUE(ErrorManager::GetInstance().GetRawErrorMessages().empty()); | ||
| 39 | +} | ||
| @@ -11,3 +11,7 @@ | |||
| 11 | if(UT_TEST_ALL OR OP_HOST_UT) | 11 | if(UT_TEST_ALL OR OP_HOST_UT) |
| 12 | add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) | 12 | add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 13 | endif() | 13 | endif() |
| 14 | + | ||
| 15 | +if((UT_TEST_ALL OR OP_HOST_UT) AND TARGET ${OP_TILING_MODULE_NAME}_cases_obj) | ||
| 16 | + target_link_libraries(${OP_TILING_MODULE_NAME}_cases_obj PRIVATE error_manager) | ||
| 17 | +endif() | ||
| @@ -0,0 +1,93 @@ | |||
| 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 <gtest/gtest-spi.h> | ||
| 12 | +#include <gtest/gtest.h> | ||
| 13 | +#include <map> | ||
| 14 | +#include <string> | ||
| 15 | +#include "mc2/common/tests/ut/formal_error_assertions.h" | ||
| 16 | + | ||
| 17 | +namespace { | ||
| 18 | +using Mc2ErrorCodeUT::ExcelErrorReportScope; | ||
| 19 | +using Mc2ErrorCodeUT::ExpectExcelFormalError; | ||
| 20 | + | ||
| 21 | +void ReportSingleValue(const char* actual) | ||
| 22 | +{ | ||
| 23 | + ASSERT_EQ(ErrorManager::GetInstance().ReportErrMessage("EZ0024", {{"op_name", "ExactFieldsUT"}, | ||
| 24 | + {"param_name", "world_size"}, | ||
| 25 | + {"incorrect_value", actual}, | ||
| 26 | + {"correct_value", "8"}}), | ||
| 27 | + 0); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +void ReportRankRelation(const char* actual) | ||
| 31 | +{ | ||
| 32 | + ASSERT_EQ(ErrorManager::GetInstance().ReportErrMessage("EZ0027", | ||
| 33 | + {{"op_name", "ExactFieldsUT"}, | ||
| 34 | + {"param_names", "ep_rank_id, ep_world_size"}, | ||
| 35 | + {"incorrect_values", actual}, | ||
| 36 | + {"reason", "ep_rank_id must be in [0, ep_world_size)"}}), | ||
| 37 | + 0); | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +TEST(FormalErrorAssertionTest, RejectsValueContainingExpectedDigits) | ||
| 41 | +{ | ||
| 42 | + ExcelErrorReportScope scope; | ||
| 43 | + ReportSingleValue("10"); | ||
| 44 | + EXPECT_NONFATAL_FAILURE(ExpectExcelFormalError("EZ0024", "world_size", "0"), "fields.at(valueKey)"); | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +TEST(FormalErrorAssertionTest, RejectsSwappedRelationValues) | ||
| 48 | +{ | ||
| 49 | + ExcelErrorReportScope scope; | ||
| 50 | + ReportRankRelation("ep_rank_id=0, ep_world_size=288"); | ||
| 51 | + EXPECT_NONFATAL_FAILURE( | ||
| 52 | + ExpectExcelFormalError("EZ0027", "ep_rank_id, ep_world_size", "ep_rank_id=288, ep_world_size=288"), | ||
| 53 | + "fields.at(valueKey)"); | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +TEST(FormalErrorAssertionTest, RejectsWrongCorrectValue) | ||
| 57 | +{ | ||
| 58 | + ExcelErrorReportScope scope; | ||
| 59 | + ReportSingleValue("0"); | ||
| 60 | + EXPECT_NONFATAL_FAILURE( | ||
| 61 | + ExpectExcelFormalError("EZ0024", "world_size", "0", nullptr, nullptr, {{"correct_value", "16"}}), | ||
| 62 | + "expected.second"); | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +TEST(FormalErrorAssertionTest, RejectsWrongOperatorName) | ||
| 66 | +{ | ||
| 67 | + ExcelErrorReportScope scope; | ||
| 68 | + ReportSingleValue("0"); | ||
| 69 | + EXPECT_NONFATAL_FAILURE( | ||
| 70 | + ExpectExcelFormalError("EZ0024", "world_size", "0", nullptr, nullptr, {{"op_name", "WrongOperator"}}), | ||
| 71 | + "expected.second"); | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +TEST(FormalErrorAssertionTest, RejectsPartialReason) | ||
| 75 | +{ | ||
| 76 | + ExcelErrorReportScope scope; | ||
| 77 | + ReportRankRelation("ep_rank_id=288, ep_world_size=288"); | ||
| 78 | + EXPECT_NONFATAL_FAILURE(ExpectExcelFormalError("EZ0027", "ep_rank_id, ep_world_size", | ||
| 79 | + "ep_rank_id=288, ep_world_size=288", "ep_rank_id"), | ||
| 80 | + "expectedReason"); | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +TEST(FormalErrorAssertionTest, AcceptsCompleteSingleAndRelationFields) | ||
| 84 | +{ | ||
| 85 | + ExcelErrorReportScope scope; | ||
| 86 | + ReportSingleValue("0"); | ||
| 87 | + ExpectExcelFormalError("EZ0024", "world_size", "0", nullptr, nullptr, | ||
| 88 | + {{"correct_value", "8"}, {"op_name", "ExactFieldsUT"}}); | ||
| 89 | + ReportRankRelation("ep_rank_id=288, ep_world_size=288"); | ||
| 90 | + ExpectExcelFormalError("EZ0027", "ep_rank_id, ep_world_size", "ep_rank_id=288, ep_world_size=288", | ||
| 91 | + "ep_rank_id must be in [0, ep_world_size)", nullptr, {{"op_name", "ExactFieldsUT"}}); | ||
| 92 | +} | ||
| 93 | +} // namespace | ||
| @@ -8,9 +8,12 @@ | |||
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | +#include <algorithm> | ||
| 12 | +#include "mc2/common/tests/ut/formal_error_assertions.h" | ||
| 11 | #include <string> | 13 | #include <string> |
| 12 | #include <vector> | 14 | #include <vector> |
| 13 | #include <gtest/gtest.h> | 15 | #include <gtest/gtest.h> |
| 16 | +#include "mc2/common/tests/ut/internal_fallback_assertions.h" | ||
| 14 | #include "../all_gather_matmul_v2_host_ut_param.h" | 17 | #include "../all_gather_matmul_v2_host_ut_param.h" |
| 15 | #include "mc2_tiling_case_executor.h" | 18 | #include "mc2_tiling_case_executor.h" |
| 16 | #include "../../../../op_host/op_tiling/arch22/tiling_func.h" | 19 | #include "../../../../op_host/op_tiling/arch22/tiling_func.h" |
| @@ -85,4 +88,59 @@ TEST(AllGatherMatmulV2TilingFuncTest, CeilDevZeroDivisor) | |||
| 85 | EXPECT_EQ(CeilDev(10, 0), 0); | 88 | EXPECT_EQ(CeilDev(10, 0), 0); |
| 86 | } | 89 | } |
| 87 | 90 | ||
| 91 | +TEST(AllGatherMatmulV2OwnerResourceContract, AivAndUbZeroReportSingleRootInternalFallback) | ||
| 92 | +{ | ||
| 93 | + auto cases = GetCasesFromCsv<AllGatherMatmulV2TilingUtParam>(ReplaceFileExtension2Csv(__FILE__)); | ||
| 94 | + auto found = std::find_if(cases.begin(), cases.end(), | ||
| 95 | + [](const AllGatherMatmulV2TilingUtParam& p) { return p.case_name == "fp16_rank8_910b"; }); | ||
| 96 | + ASSERT_NE(found, cases.end()); | ||
| 97 | + for (int variant : {0, 1}) { | ||
| 98 | + Mc2ErrorCodeUT::ExcelErrorReportScope reports; | ||
| 99 | + auto param = *found; | ||
| 100 | + param.coreNum = variant == 0 ? 0 : 30; | ||
| 101 | + param.ubsize = variant == 1 ? 256 : 262144; // SDK 910B subtracts 256 bytes of reserved UB. | ||
| 102 | + struct AllGatherMatmulV2CompileInfo {}; | ||
| 103 | + AllGatherMatmulV2CompileInfo compileInfo; | ||
| 104 | + gert::TilingContextPara tilingContextPara( | ||
| 105 | + "AllGatherMatmulV2", | ||
| 106 | + { | ||
| 107 | + param.x1, | ||
| 108 | + param.x2, | ||
| 109 | + param.bias, | ||
| 110 | + param.x1_scale, | ||
| 111 | + param.x2_scale, | ||
| 112 | + param.quant_scale, | ||
| 113 | + }, | ||
| 114 | + { | ||
| 115 | + param.y, | ||
| 116 | + param.gather_out, | ||
| 117 | + param.amax_out, | ||
| 118 | + }, | ||
| 119 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>(param.group)}, | ||
| 120 | + {"is_trans_a", Ops::Transformer::AnyValue::CreateFrom<bool>(param.is_trans_a)}, | ||
| 121 | + {"is_trans_b", Ops::Transformer::AnyValue::CreateFrom<bool>(param.is_trans_b)}, | ||
| 122 | + {"gather_index", Ops::Transformer::AnyValue::CreateFrom<int64_t>(param.gather_index)}, | ||
| 123 | + {"comm_turn", Ops::Transformer::AnyValue::CreateFrom<int64_t>(param.comm_turn)}, | ||
| 124 | + {"rank_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(param.rank_size)}, | ||
| 125 | + {"block_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(param.block_size)}, | ||
| 126 | + {"group_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(param.group_size)}, | ||
| 127 | + {"is_gather_out", Ops::Transformer::AnyValue::CreateFrom<bool>(param.is_gather_out)}, | ||
| 128 | + {"is_amax_out", Ops::Transformer::AnyValue::CreateFrom<bool>(param.is_amax_out)}, | ||
| 129 | + {"y_dtype", Ops::Transformer::AnyValue::CreateFrom<int64_t>(param.y_dtype)}, | ||
| 130 | + {"comm_mode", Ops::Transformer::AnyValue::CreateFrom<std::string>(param.comm_mode)}}, | ||
| 131 | + param.inputInstance, param.outputInstance, &compileInfo, param.soc, param.coreNum, param.ubsize); | ||
| 132 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", param.rank_size}}; | ||
| 133 | + | ||
| 134 | + tilingContextPara.socInfoString_ = | ||
| 135 | + std::string(R"({"hardware_info":{"CORE_NUM":30,"cube_core_cnt":30,"vector_core_cnt":)") + | ||
| 136 | + std::to_string(variant == 0 ? 0 : 60) + ",\"UB_SIZE\":" + std::to_string(param.ubsize) + | ||
| 137 | + R"(,"L1_SIZE":524288,"L0A_SIZE":65536,"L0B_SIZE":65536,"L0C_SIZE":131072}})"; | ||
| 138 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, 0); | ||
| 139 | + const std::string reason = "Available AIV=" + std::to_string(variant == 0 ? 0 : 60) + | ||
| 140 | + ", UB bytes=" + std::to_string(param.ubsize - 256) + | ||
| 141 | + "; positive AIV and UB resources are required"; | ||
| 142 | + Mc2ErrorCodeUT::ExpectInternalFallbackReport(reason.c_str()); | ||
| 143 | + } | ||
| 144 | +} | ||
| 145 | + | ||
| 88 | } // namespace all_gather_matmul_v2_ut | 146 | } // namespace all_gather_matmul_v2_ut |
| @@ -10,10 +10,14 @@ | |||
| 10 | 10 | ||
| 11 | #include <iostream> | 11 | #include <iostream> |
| 12 | #include <gtest/gtest.h> | 12 | #include <gtest/gtest.h> |
| 13 | +#include "../../../../common/tests/ut/formal_error_assertions.h" | ||
| 13 | #include "mc2_infer_shape_case_executor.h" | 14 | #include "mc2_infer_shape_case_executor.h" |
| 14 | #include "infer_datatype_context_faker.h" | 15 | #include "infer_datatype_context_faker.h" |
| 15 | #include "base/registry/op_impl_space_registry_v2.h" | 16 | #include "base/registry/op_impl_space_registry_v2.h" |
| 16 | 17 | ||
| 18 | +using Mc2ErrorCodeUT::ExcelErrorReportScope; | ||
| 19 | +using Mc2ErrorCodeUT::ExpectExcelFormalError; | ||
| 20 | + | ||
| 17 | namespace { | 21 | namespace { |
| 18 | 22 | ||
| 19 | // inferShape用例 ====================================================================================================== | 23 | // inferShape用例 ====================================================================================================== |
| @@ -358,4 +362,108 @@ TEST_F(AllGatherMatmulV2InferDTypeTest, HIFLOAT8) | |||
| 358 | EXPECT_EQ(contextHolder.GetContext<gert::InferDataTypeContext>()->GetOutputDataType(1), x1Type); | 362 | EXPECT_EQ(contextHolder.GetContext<gert::InferDataTypeContext>()->GetOutputDataType(1), x1Type); |
| 359 | } | 363 | } |
| 360 | 364 | ||
| 365 | +TEST_F(AllGatherMatmulV2InferDTypeTest, UndefinedYDtypeReportsSingleFormalError) | ||
| 366 | +{ | ||
| 367 | + ExcelErrorReportScope reportScope; | ||
| 368 | + ge::DataType x1Type = ge::DT_INT8; | ||
| 369 | + | ||
| 370 | + auto contextHolder = | ||
| 371 | + gert::InferDataTypeContextFaker() | ||
| 372 | + .NodeIoNum(1, 2) | ||
| 373 | + .InputDataTypes({&x1Type}) | ||
| 374 | + .NodeOutputTd(0, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 375 | + .NodeOutputTd(1, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 376 | + .NodeAttrs( | ||
| 377 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("hcclCom")}, | ||
| 378 | + {"is_trans_a", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 379 | + {"is_trans_b", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 380 | + {"gather_index", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 381 | + {"comm_turn", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 382 | + {"rank_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 383 | + {"block_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 384 | + {"group_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 385 | + {"is_gather_out", Ops::Transformer::AnyValue::CreateFrom<bool>(true)}, | ||
| 386 | + {"is_amax_out", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 387 | + {"y_dtype", Ops::Transformer::AnyValue::CreateFrom<int64_t>(static_cast<int>(ge::DT_UNDEFINED))}}) | ||
| 388 | + .Build(); | ||
| 389 | + | ||
| 390 | + auto spaceRegistry = gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(); | ||
| 391 | + auto inferDataTypeFunc = spaceRegistry->GetOpImpl("AllGatherMatmulV2")->infer_datatype; | ||
| 392 | + ASSERT_EQ(inferDataTypeFunc(contextHolder.GetContext<gert::InferDataTypeContext>()), ge::GRAPH_FAILED); | ||
| 393 | + ExpectExcelFormalError("EZ0026", "y_dtype", "DT_UNDEFINED"); | ||
| 394 | +} | ||
| 395 | + | ||
| 396 | +TEST_F(AllGatherMatmulV2InferDTypeTest, MissingYDtypeReportsSingleFormalError) | ||
| 397 | +{ | ||
| 398 | + ExcelErrorReportScope reportScope; | ||
| 399 | + ge::DataType x1Type = ge::DT_INT8; | ||
| 400 | + | ||
| 401 | + auto contextHolder = gert::InferDataTypeContextFaker() | ||
| 402 | + .NodeIoNum(1, 2) | ||
| 403 | + .InputDataTypes({&x1Type}) | ||
| 404 | + .NodeOutputTd(0, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 405 | + .NodeOutputTd(1, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 406 | + .NodeAttrs({{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("hcclCom")}, | ||
| 407 | + {"is_trans_a", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 408 | + {"is_trans_b", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 409 | + {"gather_index", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 410 | + {"comm_turn", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 411 | + {"rank_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 412 | + {"block_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 413 | + {"group_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 414 | + {"is_gather_out", Ops::Transformer::AnyValue::CreateFrom<bool>(true)}, | ||
| 415 | + {"is_amax_out", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}}) | ||
| 416 | + .Build(); | ||
| 417 | + | ||
| 418 | + auto spaceRegistry = gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(); | ||
| 419 | + auto inferDataTypeFunc = spaceRegistry->GetOpImpl("AllGatherMatmulV2")->infer_datatype; | ||
| 420 | + ASSERT_EQ(inferDataTypeFunc(contextHolder.GetContext<gert::InferDataTypeContext>()), ge::GRAPH_FAILED); | ||
| 421 | + ExpectExcelFormalError("EZ0026", "y_dtype", "null"); | ||
| 422 | +} | ||
| 423 | + | ||
| 424 | +TEST_F(AllGatherMatmulV2InferDTypeTest, InputTypeAndYDtypeStateContractMatrix) | ||
| 425 | +{ | ||
| 426 | + for (ge::DataType input : {ge::DT_FLOAT16, ge::DT_BF16, ge::DT_INT8}) { | ||
| 427 | + for (int state : {0, 1, 2, 3, 4}) { | ||
| 428 | + SCOPED_TRACE(std::to_string(input) + ":" + std::to_string(state)); | ||
| 429 | + ExcelErrorReportScope errors; | ||
| 430 | + std::vector<std::pair<std::string, Ops::Transformer::AnyValue>> attrs = { | ||
| 431 | + {"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("hcclCom")}, | ||
| 432 | + {"is_trans_a", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 433 | + {"is_trans_b", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 434 | + {"gather_index", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 435 | + {"comm_turn", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 436 | + {"rank_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 437 | + {"block_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 438 | + {"group_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 439 | + {"is_gather_out", Ops::Transformer::AnyValue::CreateFrom<bool>(true)}, | ||
| 440 | + {"is_amax_out", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}}; | ||
| 441 | + const ge::DataType outputs[] = {ge::DT_UNDEFINED, ge::DT_UNDEFINED, ge::DT_FLOAT16, ge::DT_BF16, | ||
| 442 | + ge::DT_FLOAT}; | ||
| 443 | + if (state != 0) | ||
| 444 | + attrs.emplace_back("y_dtype", Ops::Transformer::AnyValue::CreateFrom<int64_t>(outputs[state])); | ||
| 445 | + auto holder = gert::InferDataTypeContextFaker() | ||
| 446 | + .NodeIoNum(1, 2) | ||
| 447 | + .InputDataTypes({&input}) | ||
| 448 | + .NodeOutputTd(0, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 449 | + .NodeOutputTd(1, ge::FORMAT_ND, ge::FORMAT_ND) | ||
| 450 | + .NodeAttrs(attrs) | ||
| 451 | + .Build(); | ||
| 452 | + auto* context = holder.GetContext<gert::InferDataTypeContext>(); | ||
| 453 | + ASSERT_NE(context, nullptr); | ||
| 454 | + auto registry = gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(); | ||
| 455 | + const bool invalid = input == ge::DT_INT8 && state < 2; | ||
| 456 | + EXPECT_EQ(registry->GetOpImpl("AllGatherMatmulV2")->infer_datatype(context), | ||
| 457 | + invalid ? ge::GRAPH_FAILED : ge::GRAPH_SUCCESS); | ||
| 458 | + if (invalid) { | ||
| 459 | + ExpectExcelFormalError("EZ0026", "y_dtype", state == 0 ? "null" : "DT_UNDEFINED", | ||
| 460 | + "Set y_dtype to a defined data type when the input is not FLOAT16 or BF16"); | ||
| 461 | + } else { | ||
| 462 | + EXPECT_EQ(context->GetOutputDataType(0), input == ge::DT_INT8 ? outputs[state] : input); | ||
| 463 | + EXPECT_EQ(context->GetOutputDataType(1), input); | ||
| 464 | + EXPECT_TRUE(ErrorManager::GetInstance().GetRawErrorMessages().empty()); | ||
| 465 | + } | ||
| 466 | + } | ||
| 467 | + } | ||
| 468 | +} | ||
| 361 | } // namespace | 469 | } // namespace |
| @@ -16,6 +16,8 @@ | |||
| 16 | 16 | ||
| 17 | #include "mc2_log.h" | 17 | #include "mc2_log.h" |
| 18 | 18 | ||
| 19 | +#include "mc2/matmul_allto_all/op_host/op_tiling/common/matmul_allto_all_error.h" | ||
| 20 | + | ||
| 19 | using namespace AscendC; | 21 | using namespace AscendC; |
| 20 | using namespace ge; | 22 | using namespace ge; |
| 21 | using namespace Mc2Tiling; | 23 | using namespace Mc2Tiling; |
| @@ -42,6 +44,25 @@ static bool IsContain(const std::vector<uint32_t>& list, uint32_t value) | |||
| 42 | ge::graphStatus AllToAllMatmulTilingBase::GetShapeAttrsInfo() | 44 | ge::graphStatus AllToAllMatmulTilingBase::GetShapeAttrsInfo() |
| 43 | { | 45 | { |
| 44 | opName_ = context_->GetNodeName(); | 46 | opName_ = context_->GetNodeName(); |
| 47 | + OP_TILING_CHECK( | ||
| 48 | + context_->GetRawTilingData() == nullptr, | ||
| 49 | + ReportMatmulAlltoAllTilingFailure(opName_, "Raw tiling data holder is absent; rebuild the tiling context"), | ||
| 50 | + return ge::GRAPH_FAILED); | ||
| 51 | + OP_TILING_CHECK( | ||
| 52 | + context_->GetAttrs() == nullptr, | ||
| 53 | + ReportMatmulAlltoAllTilingFailure(opName_, "RuntimeAttrs holder is absent; rebuild the tiling context"), | ||
| 54 | + return ge::GRAPH_FAILED); | ||
| 55 | + for (size_t index = 0; index < 2; ++index) { | ||
| 56 | + const char* inputName = index == 0 ? "x1" : "x2"; | ||
| 57 | + OP_TILING_CHECK(context_->GetInputShape(index) == nullptr, OP_LOGE_WITH_INVALID_INPUT(opName_, inputName), | ||
| 58 | + return ge::GRAPH_FAILED); | ||
| 59 | + OP_TILING_CHECK( | ||
| 60 | + context_->GetInputDesc(index) == nullptr, | ||
| 61 | + ReportMatmulAlltoAllTilingFailure( | ||
| 62 | + opName_, std::string(inputName) + | ||
| 63 | + " descriptor is absent while its shape is present; rebuild the tiling context"), | ||
| 64 | + return ge::GRAPH_FAILED); | ||
| 65 | + } | ||
| 45 | return ge::GRAPH_SUCCESS; | 66 | return ge::GRAPH_SUCCESS; |
| 46 | }; | 67 | }; |
| 47 | 68 | ||
| @@ -53,9 +74,16 @@ ge::graphStatus AllToAllMatmulTilingBase::GetShapeAttrsInfo() | |||
| 53 | ge::graphStatus AllToAllMatmulTilingBase::GetPlatformInfo() | 74 | ge::graphStatus AllToAllMatmulTilingBase::GetPlatformInfo() |
| 54 | { | 75 | { |
| 55 | fe::PlatFormInfos* platformInfo = context_->GetPlatformInfo(); | 76 | fe::PlatFormInfos* platformInfo = context_->GetPlatformInfo(); |
| 56 | - OP_TILING_CHECK(platformInfo == nullptr, OP_LOGE(opName_, "Fail to get platform info"), return ge::GRAPH_FAILED); | 77 | + OP_TILING_CHECK(platformInfo == nullptr, |
| 78 | + ReportMatmulAlltoAllTilingFailure( | ||
| 79 | + opName_, "GetPlatformInfo returned null; initialize platform resource metadata before tiling"), | ||
| 80 | + return ge::GRAPH_FAILED); | ||
| 57 | platform_ascendc::PlatformAscendC ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); | 81 | platform_ascendc::PlatformAscendC ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); |
| 58 | contextInfo_.args_.aicCoreNum = ascendcPlatform.GetCoreNumAic(); | 82 | contextInfo_.args_.aicCoreNum = ascendcPlatform.GetCoreNumAic(); |
| 83 | + OP_TILING_CHECK(contextInfo_.args_.aicCoreNum == 0, | ||
| 84 | + ReportMatmulAlltoAllTilingFailure( | ||
| 85 | + opName_, "Available AIC core count=0; required at least 1; check platform resource metadata"), | ||
| 86 | + return ge::GRAPH_FAILED); | ||
| 59 | const uint32_t aivCoreNum = ascendcPlatform.GetCoreNumAiv(); | 87 | const uint32_t aivCoreNum = ascendcPlatform.GetCoreNumAiv(); |
| 60 | cvRatio_ = 1U; | 88 | cvRatio_ = 1U; |
| 61 | if (contextInfo_.args_.aicCoreNum != 0U) { | 89 | if (contextInfo_.args_.aicCoreNum != 0U) { |
| @@ -748,6 +748,12 @@ ge::graphStatus AlltoAllvGmmTiling::setNumBlocks(gert::TilingContext* context) | |||
| 748 | uint64_t aicNum = ascendcPlatform.GetCoreNumAic(); | 748 | uint64_t aicNum = ascendcPlatform.GetCoreNumAic(); |
| 749 | uint64_t aivNum = ascendcPlatform.GetCoreNumAiv(); | 749 | uint64_t aivNum = ascendcPlatform.GetCoreNumAiv(); |
| 750 | uint64_t numBlocks = mc2tiling::GetNumBlocks(aicNum, aivNum, context_->GetNodeName()); | 750 | uint64_t numBlocks = mc2tiling::GetNumBlocks(aicNum, aivNum, context_->GetNodeName()); |
| 751 | + if (numBlocks == 0U) { | ||
| 752 | + OP_LOGE_LIBOPAPI_REPORT(context_->GetNodeName(), | ||
| 753 | + "GetNumBlocks returned 0 for AIC=%lu and AIV=%lu; see the core pairing diagnostic", | ||
| 754 | + aicNum, aivNum); | ||
| 755 | + return ge::GRAPH_FAILED; | ||
| 756 | + } | ||
| 751 | 757 | ||
| 752 | tilingData->taskTilingInfo.ubSize = ubSize_; | 758 | tilingData->taskTilingInfo.ubSize = ubSize_; |
| 753 | context->SetBlockDim(static_cast<uint32_t>(numBlocks)); | 759 | context->SetBlockDim(static_cast<uint32_t>(numBlocks)); |
Mmc2/allto_allv_grouped_mat_mul/tests/ut/op_host/arch22/test_allto_allv_grouped_mat_mul_tiling.cpp+115-0
| @@ -16,12 +16,14 @@ | |||
| 16 | 16 | ||
| 17 | #include <iostream> | 17 | #include <iostream> |
| 18 | #include <gtest/gtest.h> | 18 | #include <gtest/gtest.h> |
| 19 | +#include "mc2/common/tests/ut/internal_fallback_assertions.h" | ||
| 19 | #include <initializer_list> | 20 | #include <initializer_list> |
| 20 | #include <string> | 21 | #include <string> |
| 21 | #include <utility> | 22 | #include <utility> |
| 22 | #include "experiment/metadef/common/util/error_manager/error_manager.h" | 23 | #include "experiment/metadef/common/util/error_manager/error_manager.h" |
| 23 | 24 | ||
| 24 | #include "mc2_tiling_case_executor.h" | 25 | #include "mc2_tiling_case_executor.h" |
| 26 | +#include "mc2/common/op_host/op_tiling/mc2_calc_num_blocks.h" | ||
| 25 | 27 | ||
| 26 | using namespace std; | 28 | using namespace std; |
| 27 | 29 | ||
| @@ -1386,6 +1388,115 @@ TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, TransMmWeight1) | |||
| 1386 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | 1388 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; |
| 1387 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); | 1389 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); |
| 1388 | } | 1390 | } |
| 1391 | +TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, ZeroPlatformCoresReportInternalFallback) | ||
| 1392 | +{ | ||
| 1393 | + TestParam testParam{ | ||
| 1394 | + "OwnerPlatformCore", {{"permuteOutFlag", "true"}, {"isNeedMM", "false"}}, {}, {}, ge::GRAPH_FAILED}; | ||
| 1395 | + | ||
| 1396 | + struct AlltoAllvGroupedMatMulCompileInfo {}; | ||
| 1397 | + AlltoAllvGroupedMatMulCompileInfo compileInfo; | ||
| 1398 | + | ||
| 1399 | + std::string socVersion = "Ascend910_93"; | ||
| 1400 | + uint64_t coreNum = 0; | ||
| 1401 | + uint64_t ubSize = 196608; | ||
| 1402 | + uint64_t tilingDataSize = sizeof(AlltoAllvGmmAivTilingData); | ||
| 1403 | + | ||
| 1404 | + TilingParams tilingParams; | ||
| 1405 | + InitializeTilingParams(testParam, tilingParams); | ||
| 1406 | + | ||
| 1407 | + std::vector<std::string> targets = {"BS", "H2", "mmWeightDim0", "N2"}; | ||
| 1408 | + | ||
| 1409 | + auto mmXShape = CreateTensorShape({{tilingParams.BS, tilingParams.H2}, {tilingParams.BS, tilingParams.H2}}, | ||
| 1410 | + ge::DT_FLOAT16, ge::FORMAT_ND); | ||
| 1411 | + auto mmWeightShape = | ||
| 1412 | + CreateTensorShape({{tilingParams.mmWeightDim0, tilingParams.N2}, {tilingParams.mmWeightDim0, tilingParams.N2}}, | ||
| 1413 | + ge::DT_FLOAT16, ge::FORMAT_ND); | ||
| 1414 | + auto mmYShape = CreateTensorShape({{tilingParams.BS, tilingParams.N2}, {tilingParams.BS, tilingParams.N2}}, | ||
| 1415 | + ge::DT_FLOAT16, ge::FORMAT_ND); | ||
| 1416 | + | ||
| 1417 | + if (!(has_any_target_key(testParam.tilingParamsStrPair, targets) || tilingParams.isNeedMM == false)) { | ||
| 1418 | + mmXShape->shape_ = {}; | ||
| 1419 | + mmWeightShape->shape_ = {}; | ||
| 1420 | + } | ||
| 1421 | + | ||
| 1422 | + gert::TilingContextPara tilingContextPara( | ||
| 1423 | + "AlltoAllvGroupedMatMul", CreateInputTensors(tilingParams, mmXShape, mmWeightShape), | ||
| 1424 | + CreateOutputTensors(tilingParams, mmYShape), | ||
| 1425 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>(tilingParams.group)}, | ||
| 1426 | + {"epWorldSize", Ops::Transformer::AnyValue::CreateFrom<int64_t>(tilingParams.epWorldSize)}, | ||
| 1427 | + {"sendCounts", Ops::Transformer::AnyValue::CreateFrom<vector<int64_t>>(tilingParams.sendCounts)}, | ||
| 1428 | + {"recvCounts", Ops::Transformer::AnyValue::CreateFrom<vector<int64_t>>(tilingParams.recvCounts)}, | ||
| 1429 | + {"transGmmWeight", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 1430 | + {"transMmWeight", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 1431 | + {"permuteOutFlag", Ops::Transformer::AnyValue::CreateFrom<bool>(tilingParams.permuteOutFlag)}, | ||
| 1432 | + {"commMode", Ops::Transformer::AnyValue::CreateFrom<std::string>("ai_cpu")}}, | ||
| 1433 | + &compileInfo, socVersion, coreNum, ubSize, tilingDataSize); | ||
| 1434 | + | ||
| 1435 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1436 | + if (testParam.status == ge::GRAPH_FAILED) { | ||
| 1437 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); | ||
| 1438 | + } else { | ||
| 1439 | + uint64_t expectTilingKey = 4UL; | ||
| 1440 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_SUCCESS, expectTilingKey); | ||
| 1441 | + } | ||
| 1442 | + Mc2ErrorCodeUT::ExpectInternalFallbackReport( | ||
| 1443 | + "CheckCommonPlatformInfo: aic num actual=0; required positive platform resource"); | ||
| 1444 | +} | ||
| 1445 | + | ||
| 1446 | +TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, ValidPlatformCoresControl) | ||
| 1447 | +{ | ||
| 1448 | + TestParam testParam{ | ||
| 1449 | + "OwnerPlatformCore", {{"permuteOutFlag", "true"}, {"isNeedMM", "false"}}, {}, {}, ge::GRAPH_SUCCESS}; | ||
| 1450 | + | ||
| 1451 | + struct AlltoAllvGroupedMatMulCompileInfo {}; | ||
| 1452 | + AlltoAllvGroupedMatMulCompileInfo compileInfo; | ||
| 1453 | + | ||
| 1454 | + std::string socVersion = "Ascend910_93"; | ||
| 1455 | + uint64_t coreNum = 20; | ||
| 1456 | + uint64_t ubSize = 196608; | ||
| 1457 | + uint64_t tilingDataSize = sizeof(AlltoAllvGmmAivTilingData); | ||
| 1458 | + | ||
| 1459 | + TilingParams tilingParams; | ||
| 1460 | + InitializeTilingParams(testParam, tilingParams); | ||
| 1461 | + | ||
| 1462 | + std::vector<std::string> targets = {"BS", "H2", "mmWeightDim0", "N2"}; | ||
| 1463 | + | ||
| 1464 | + auto mmXShape = CreateTensorShape({{tilingParams.BS, tilingParams.H2}, {tilingParams.BS, tilingParams.H2}}, | ||
| 1465 | + ge::DT_FLOAT16, ge::FORMAT_ND); | ||
| 1466 | + auto mmWeightShape = | ||
| 1467 | + CreateTensorShape({{tilingParams.mmWeightDim0, tilingParams.N2}, {tilingParams.mmWeightDim0, tilingParams.N2}}, | ||
| 1468 | + ge::DT_FLOAT16, ge::FORMAT_ND); | ||
| 1469 | + auto mmYShape = CreateTensorShape({{tilingParams.BS, tilingParams.N2}, {tilingParams.BS, tilingParams.N2}}, | ||
| 1470 | + ge::DT_FLOAT16, ge::FORMAT_ND); | ||
| 1471 | + | ||
| 1472 | + if (!(has_any_target_key(testParam.tilingParamsStrPair, targets) || tilingParams.isNeedMM == false)) { | ||
| 1473 | + mmXShape->shape_ = {}; | ||
| 1474 | + mmWeightShape->shape_ = {}; | ||
| 1475 | + } | ||
| 1476 | + | ||
| 1477 | + gert::TilingContextPara tilingContextPara( | ||
| 1478 | + "AlltoAllvGroupedMatMul", CreateInputTensors(tilingParams, mmXShape, mmWeightShape), | ||
| 1479 | + CreateOutputTensors(tilingParams, mmYShape), | ||
| 1480 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>(tilingParams.group)}, | ||
| 1481 | + {"epWorldSize", Ops::Transformer::AnyValue::CreateFrom<int64_t>(tilingParams.epWorldSize)}, | ||
| 1482 | + {"sendCounts", Ops::Transformer::AnyValue::CreateFrom<vector<int64_t>>(tilingParams.sendCounts)}, | ||
| 1483 | + {"recvCounts", Ops::Transformer::AnyValue::CreateFrom<vector<int64_t>>(tilingParams.recvCounts)}, | ||
| 1484 | + {"transGmmWeight", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 1485 | + {"transMmWeight", Ops::Transformer::AnyValue::CreateFrom<bool>(false)}, | ||
| 1486 | + {"permuteOutFlag", Ops::Transformer::AnyValue::CreateFrom<bool>(tilingParams.permuteOutFlag)}, | ||
| 1487 | + {"commMode", Ops::Transformer::AnyValue::CreateFrom<std::string>("ai_cpu")}}, | ||
| 1488 | + &compileInfo, socVersion, coreNum, ubSize, tilingDataSize); | ||
| 1489 | + | ||
| 1490 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1491 | + if (testParam.status == ge::GRAPH_FAILED) { | ||
| 1492 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); | ||
| 1493 | + } else { | ||
| 1494 | + uint64_t expectTilingKey = 4UL; | ||
| 1495 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_SUCCESS, expectTilingKey); | ||
| 1496 | + } | ||
| 1497 | + EXPECT_TRUE(ErrorManager::GetInstance().GetRawErrorMessages().empty()); | ||
| 1498 | +} | ||
| 1499 | + | ||
| 1389 | } // namespace AlltoAllvGroupedMatMulUT | 1500 | } // namespace AlltoAllvGroupedMatMulUT |
| 1390 | namespace AlltoAllvGroupedMatMulUT { | 1501 | namespace AlltoAllvGroupedMatMulUT { |
| 1391 | TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, AivBf16TilingContract) | 1502 | TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, AivBf16TilingContract) |
| @@ -1438,6 +1549,7 @@ TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, AivBf16TilingContract) | |||
| 1438 | EXPECT_EQ(tiling->is910C, 1U); | 1549 | EXPECT_EQ(tiling->is910C, 1U); |
| 1439 | EXPECT_EQ(tilingInfo.tilingKey, 8); | 1550 | EXPECT_EQ(tilingInfo.tilingKey, 8); |
| 1440 | } | 1551 | } |
| 1552 | + | ||
| 1441 | } // namespace AlltoAllvGroupedMatMulUT | 1553 | } // namespace AlltoAllvGroupedMatMulUT |
| 1442 | 1554 | ||
| 1443 | namespace AlltoAllvGroupedMatMulUT { | 1555 | namespace AlltoAllvGroupedMatMulUT { |
| @@ -1702,6 +1814,7 @@ TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, AivRejectsCountEntryAboveTokenCap | |||
| 1702 | TilingInfo tilingInfo; | 1814 | TilingInfo tilingInfo; |
| 1703 | EXPECT_FALSE(ExecuteAivHostCase(ge::DT_BF16, 4, sendCounts, recvCounts, false, false, false, tilingInfo)); | 1815 | EXPECT_FALSE(ExecuteAivHostCase(ge::DT_BF16, 4, sendCounts, recvCounts, false, false, false, tilingInfo)); |
| 1704 | } | 1816 | } |
| 1817 | + | ||
| 1705 | } // namespace AlltoAllvGroupedMatMulUT | 1818 | } // namespace AlltoAllvGroupedMatMulUT |
| 1706 | 1819 | ||
| 1707 | namespace AlltoAllvGroupedMatMulUT { | 1820 | namespace AlltoAllvGroupedMatMulUT { |
| @@ -1806,6 +1919,7 @@ TEST_F(AlltoAllvGroupedMatMulArch22TilingTest, AivPublishesInt32PrefixesFor1024G | |||
| 1806 | EXPECT_EQ(tiling->recvPrefix[1023], 1024); | 1919 | EXPECT_EQ(tiling->recvPrefix[1023], 1024); |
| 1807 | EXPECT_EQ(tiling->countBytes, 4096U); | 1920 | EXPECT_EQ(tiling->countBytes, 4096U); |
| 1808 | } | 1921 | } |
| 1922 | + | ||
| 1809 | } // namespace AlltoAllvGroupedMatMulUT | 1923 | } // namespace AlltoAllvGroupedMatMulUT |
| 1810 | 1924 | ||
| 1811 | namespace AlltoAllvGroupedMatMulUT { | 1925 | namespace AlltoAllvGroupedMatMulUT { |
| @@ -1875,6 +1989,7 @@ TEST(AlltoAllvGroupedMatMulAivCommTest, KeepsPeerControlOffsetStableAcrossExpert | |||
| 1875 | EXPECT_EQ(controlE2.peerControlBytes, controlE16.peerControlBytes); | 1989 | EXPECT_EQ(controlE2.peerControlBytes, controlE16.peerControlBytes); |
| 1876 | EXPECT_EQ(layoutE2.controlOffset, layoutE16.controlOffset); | 1990 | EXPECT_EQ(layoutE2.controlOffset, layoutE16.controlOffset); |
| 1877 | } | 1991 | } |
| 1992 | + | ||
| 1878 | } // namespace AlltoAllvGroupedMatMulUT | 1993 | } // namespace AlltoAllvGroupedMatMulUT |
| 1879 | 1994 | ||
| 1880 | namespace AlltoAllvGroupedMatMulUT { | 1995 | namespace AlltoAllvGroupedMatMulUT { |
| @@ -14,6 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | #include "allto_allv_quant_grouped_mat_mul_tiling_base.h" | 15 | #include "allto_allv_quant_grouped_mat_mul_tiling_base.h" |
| 16 | #include <numeric> | 16 | #include <numeric> |
| 17 | +#include "mc2_tiling_failure_report.h" | ||
| 17 | 18 | ||
| 18 | using namespace ge; | 19 | using namespace ge; |
| 19 | using namespace AscendC; | 20 | using namespace AscendC; |
| @@ -42,25 +43,39 @@ ge::graphStatus AlltoAllvQuantGmmTilingBase::GetCommonPlatformInfo() | |||
| 42 | ge::graphStatus AlltoAllvQuantGmmTilingBase::CheckCommonPlatformInfo() | 43 | ge::graphStatus AlltoAllvQuantGmmTilingBase::CheckCommonPlatformInfo() |
| 43 | { | 44 | { |
| 44 | OP_TILING_CHECK((aicCoreNum_ == 0U), | 45 | OP_TILING_CHECK((aicCoreNum_ == 0U), |
| 45 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, aic num can not be 0."), | 46 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), "CheckCommonPlatformInfo: aic num actual=" + |
| 47 | + std::to_string(aicCoreNum_) + | ||
| 48 | + "; required positive platform resource"), | ||
| 46 | return ge::GRAPH_FAILED); | 49 | return ge::GRAPH_FAILED); |
| 47 | OP_TILING_CHECK((aivCoreNum_ == 0U), | 50 | OP_TILING_CHECK((aivCoreNum_ == 0U), |
| 48 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, aiv num can not be 0."), | 51 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), "CheckCommonPlatformInfo: aiv num actual=" + |
| 52 | + std::to_string(aivCoreNum_) + | ||
| 53 | + "; required positive platform resource"), | ||
| 49 | return ge::GRAPH_FAILED); | 54 | return ge::GRAPH_FAILED); |
| 50 | OP_TILING_CHECK((l0aSize_ == 0U), | 55 | OP_TILING_CHECK((l0aSize_ == 0U), |
| 51 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, l0a size can not be 0."), | 56 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), "CheckCommonPlatformInfo: l0a size actual=" + |
| 57 | + std::to_string(l0aSize_) + | ||
| 58 | + "; required positive platform resource"), | ||
| 52 | return ge::GRAPH_FAILED); | 59 | return ge::GRAPH_FAILED); |
| 53 | OP_TILING_CHECK((l0bSize_ == 0U), | 60 | OP_TILING_CHECK((l0bSize_ == 0U), |
| 54 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, l0b size can not be 0."), | 61 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), "CheckCommonPlatformInfo: l0b size actual=" + |
| 62 | + std::to_string(l0bSize_) + | ||
| 63 | + "; required positive platform resource"), | ||
| 55 | return ge::GRAPH_FAILED); | 64 | return ge::GRAPH_FAILED); |
| 56 | OP_TILING_CHECK((l0cSize_ == 0U), | 65 | OP_TILING_CHECK((l0cSize_ == 0U), |
| 57 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, l0c size can not be 0."), | 66 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), "CheckCommonPlatformInfo: l0c size actual=" + |
| 67 | + std::to_string(l0cSize_) + | ||
| 68 | + "; required positive platform resource"), | ||
| 58 | return ge::GRAPH_FAILED); | 69 | return ge::GRAPH_FAILED); |
| 59 | OP_TILING_CHECK((l1Size_ == 0U), | 70 | OP_TILING_CHECK((l1Size_ == 0U), |
| 60 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, l1 size can not be 0."), | 71 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), |
| 72 | + "CheckCommonPlatformInfo: l1 size actual=" + std::to_string(l1Size_) + | ||
| 73 | + "; required positive platform resource"), | ||
| 61 | return ge::GRAPH_FAILED); | 74 | return ge::GRAPH_FAILED); |
| 62 | OP_TILING_CHECK((ubSize_ == 0U), | 75 | OP_TILING_CHECK((ubSize_ == 0U), |
| 63 | - OP_LOGE(context_->GetNodeName(), "platform info is invalid, ub size can not be 0."), | 76 | + Mc2Error::ReportTilingFailure(context_->GetNodeName(), |
| 77 | + "CheckCommonPlatformInfo: ub size actual=" + std::to_string(ubSize_) + | ||
| 78 | + "; required positive platform resource"), | ||
| 64 | return ge::GRAPH_FAILED); | 79 | return ge::GRAPH_FAILED); |
| 65 | return ge::GRAPH_SUCCESS; | 80 | return ge::GRAPH_SUCCESS; |
| 66 | } | 81 | } |
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <fcntl.h> | 19 | #include <fcntl.h> |
| 20 | #include <cstdio> | 20 | #include <cstdio> |
| 21 | #include <cstdlib> | 21 | #include <cstdlib> |
| 22 | +#include <cstring> | ||
| 22 | #include <sys/types.h> | 23 | #include <sys/types.h> |
| 23 | #include <unistd.h> | 24 | #include <unistd.h> |
| 24 | #include <cmath> | 25 | #include <cmath> |
| @@ -29,11 +30,13 @@ | |||
| 29 | #include "register/tilingdata_base.h" | 30 | #include "register/tilingdata_base.h" |
| 30 | #include "tiling/tiling_api.h" | 31 | #include "tiling/tiling_api.h" |
| 31 | #include "mc2_log.h" | 32 | #include "mc2_log.h" |
| 33 | +#include "mc2_tiling_failure_report.h" | ||
| 32 | #include "graph/utils/type_utils.h" | 34 | #include "graph/utils/type_utils.h" |
| 33 | #include "register/op_def_registry.h" | 35 | #include "register/op_def_registry.h" |
| 34 | #include "platform/platform_infos_def.h" | 36 | #include "platform/platform_infos_def.h" |
| 35 | #include "mc2_hcom_topo_info.h" | 37 | #include "mc2_hcom_topo_info.h" |
| 36 | #include "attention_to_ffn_tiling_base.h" | 38 | #include "attention_to_ffn_tiling_base.h" |
| 39 | +#include "attention_to_ffn_tiling_checks.h" | ||
| 37 | #include "../../op_kernel/attention_to_ffn_tiling.h" | 40 | #include "../../op_kernel/attention_to_ffn_tiling.h" |
| 38 | #include "../../op_kernel/attention_to_ffn_tiling_key.h" | 41 | #include "../../op_kernel/attention_to_ffn_tiling_key.h" |
| 39 | 42 | ||
| @@ -63,32 +66,13 @@ constexpr uint32_t DIM3 = 3; | |||
| 63 | constexpr uint32_t DIM5 = 5; | 66 | constexpr uint32_t DIM5 = 5; |
| 64 | 67 | ||
| 65 | constexpr uint32_t SYNC_MODE = 1; | 68 | constexpr uint32_t SYNC_MODE = 1; |
| 66 | -constexpr uint32_t UNQUANT_MODE = 0; | ||
| 67 | constexpr uint32_t STATIC_QUANT_MODE = 1; | 69 | constexpr uint32_t STATIC_QUANT_MODE = 1; |
| 68 | -constexpr uint32_t DYNAMIC_QUANT_MODE = 2; | ||
| 69 | -constexpr uint32_t NO_SCALES = 0; | ||
| 70 | constexpr uint32_t STATIC_SCALES = 1; | 70 | constexpr uint32_t STATIC_SCALES = 1; |
| 71 | -constexpr uint32_t DYNAMIC_SCALES = 2; | ||
| 72 | -constexpr int64_t MOE_EXPERT_MAX_NUM = 1024; | ||
| 73 | constexpr int64_t SHARED_EXPERT_MAX_NUM = 4; | 71 | constexpr int64_t SHARED_EXPERT_MAX_NUM = 4; |
| 74 | constexpr int64_t BS_MAX = 512; | 72 | constexpr int64_t BS_MAX = 512; |
| 75 | constexpr int64_t H_MIN = 1024; | 73 | constexpr int64_t H_MIN = 1024; |
| 76 | constexpr int64_t H_MAX = 8192; | 74 | constexpr int64_t H_MAX = 8192; |
| 77 | constexpr int64_t K_MAX = 16; | 75 | constexpr int64_t K_MAX = 16; |
| 78 | -constexpr int64_t MIN_WORLD_SIZE = 2; | ||
| 79 | - | ||
| 80 | -constexpr uint32_t USER_QUANT_MODE_MX_E5M2 = 3U; | ||
| 81 | -constexpr uint32_t USER_QUANT_MODE_MX_E4M3 = 4U; | ||
| 82 | -constexpr uint32_t USER_QUANT_MODE_MX_E2M1 = 5U; | ||
| 83 | -constexpr uint32_t USER_QUANT_MODE_MX_CLIP_E5M2 = 6U; | ||
| 84 | -constexpr uint32_t USER_QUANT_MODE_MX_CLIP_E4M3 = 7U; | ||
| 85 | - | ||
| 86 | -static bool IsMxQuantMode(uint32_t quantMode) | ||
| 87 | -{ | ||
| 88 | - return quantMode == USER_QUANT_MODE_MX_E5M2 || quantMode == USER_QUANT_MODE_MX_E4M3 || | ||
| 89 | - quantMode == USER_QUANT_MODE_MX_E2M1 || quantMode == USER_QUANT_MODE_MX_CLIP_E5M2 || | ||
| 90 | - quantMode == USER_QUANT_MODE_MX_CLIP_E4M3; | ||
| 91 | -} | ||
| 92 | 76 | ||
| 93 | static void PrintTilingDataInfo(AttentionToFFNTilingData& tilingData) | 77 | static void PrintTilingDataInfo(AttentionToFFNTilingData& tilingData) |
| 94 | { | 78 | { |
| @@ -179,7 +163,7 @@ static bool CheckAndSetShapeAttrs(const gert::TilingContext* context, const char | |||
| 179 | AttentionToFFNTilingData& tilingData, const AttentionToFFNTilingConfig& config) | 163 | AttentionToFFNTilingData& tilingData, const AttentionToFFNTilingConfig& config) |
| 180 | { | 164 | { |
| 181 | auto attrs = context->GetAttrs(); | 165 | auto attrs = context->GetAttrs(); |
| 182 | - auto worldSizePtr = attrs->GetAttrPointer<int>(config.attrWorldSizeIndex); | 166 | + auto worldSizePtr = attrs->GetAttrPointer<int64_t>(config.attrWorldSizeIndex); |
| 183 | auto ffnTokenInfoTableDimNum = attrs->GetListInt(config.attrFfnTokenInfoTableShapeIndex)->GetSize(); | 167 | auto ffnTokenInfoTableDimNum = attrs->GetListInt(config.attrFfnTokenInfoTableShapeIndex)->GetSize(); |
| 184 | auto ffnTokenDataDimNum = attrs->GetListInt(config.attrFfnTokenDataShapeIndex)->GetSize(); | 168 | auto ffnTokenDataDimNum = attrs->GetListInt(config.attrFfnTokenDataShapeIndex)->GetSize(); |
| 185 | auto attnTokenDataDimNum = attrs->GetListInt(config.attrAttnTokenInfoTableShapeIndex)->GetSize(); | 169 | auto attnTokenDataDimNum = attrs->GetListInt(config.attrAttnTokenInfoTableShapeIndex)->GetSize(); |
| @@ -210,74 +194,73 @@ static bool CheckAndSetShapeAttrs(const gert::TilingContext* context, const char | |||
| 210 | return true; | 194 | return true; |
| 211 | } | 195 | } |
| 212 | 196 | ||
| 213 | -static bool CheckAttrValues(const char* nodeName, const uint32_t moeExpertNum, const uint32_t worldSize, | ||
| 214 | - const int worldSizeRaw, const int quantMode, const int syncFlag, const int ffnStartRankId, | ||
| 215 | - const bool allowMxQuantMode, const int64_t maxWorldSize) | ||
| 216 | -{ | ||
| 217 | - OP_TILING_CHECK( | ||
| 218 | - (moeExpertNum <= 0) || (moeExpertNum > MOE_EXPERT_MAX_NUM), | ||
| 219 | - OP_LOGE_FOR_INVALID_VALUE(ATTN_FFN_INNER_DEBUG, "moe_expert_num", std::to_string(moeExpertNum).c_str(), | ||
| 220 | - (std::string("(0, ") + std::to_string(MOE_EXPERT_MAX_NUM) + "]").c_str()), | ||
| 221 | - return false); | ||
| 222 | - if (allowMxQuantMode) { | ||
| 223 | - OP_TILING_CHECK(quantMode != UNQUANT_MODE && quantMode != DYNAMIC_QUANT_MODE && | ||
| 224 | - !IsMxQuantMode(static_cast<uint32_t>(quantMode)), | ||
| 225 | - OP_LOGE_FOR_INVALID_VALUE(ATTN_FFN_INNER_DEBUG, "quant_mode", std::to_string(quantMode).c_str(), | ||
| 226 | - "0, 2, 3, 4, 5, 6 or 7"), | ||
| 227 | - return false); | ||
| 228 | - } else { | ||
| 229 | - OP_TILING_CHECK( | ||
| 230 | - (quantMode < static_cast<int64_t>(NO_SCALES)) || (quantMode > static_cast<int64_t>(DYNAMIC_SCALES)), | ||
| 231 | - OP_LOGE_FOR_INVALID_VALUE(ATTN_FFN_INNER_DEBUG, "quant_mode", std::to_string(quantMode).c_str(), | ||
| 232 | - (std::string("[0, ") + std::to_string(DYNAMIC_SCALES) + "]").c_str()), | ||
| 233 | - return false); | ||
| 234 | - } | ||
| 235 | - OP_TILING_CHECK((syncFlag != 0) && (syncFlag != 1), | ||
| 236 | - OP_LOGE_FOR_INVALID_VALUE(nodeName, "sync_flag", std::to_string(syncFlag).c_str(), "0 or 1"), | ||
| 237 | - return false); | ||
| 238 | - OP_TILING_CHECK( | ||
| 239 | - (ffnStartRankId >= worldSizeRaw) || (ffnStartRankId < 0), | ||
| 240 | - OP_LOGE_FOR_INVALID_VALUE(ATTN_FFN_INNER_DEBUG, "ffn_start_rank_id", std::to_string(ffnStartRankId).c_str(), | ||
| 241 | - (std::string("[0, ") + std::to_string(worldSizeRaw) + ")").c_str()), | ||
| 242 | - return false); | ||
| 243 | - OP_TILING_CHECK( | ||
| 244 | - (worldSize < MIN_WORLD_SIZE) || (static_cast<int64_t>(worldSize) > maxWorldSize), | ||
| 245 | - OP_LOGE_FOR_INVALID_VALUE( | ||
| 246 | - nodeName, "world_size", std::to_string(worldSize).c_str(), | ||
| 247 | - (std::string("[") + std::to_string(MIN_WORLD_SIZE) + ", " + std::to_string(maxWorldSize) + "]").c_str()), | ||
| 248 | - return false); | ||
| 249 | - return true; | ||
| 250 | -} | ||
| 251 | - | ||
| 252 | static bool CheckAndSetAttrs(gert::TilingContext* context, const char* nodeName, AttentionToFFNTilingData& tilingData, | 197 | static bool CheckAndSetAttrs(gert::TilingContext* context, const char* nodeName, AttentionToFFNTilingData& tilingData, |
| 253 | std::string& group, const AttentionToFFNTilingConfig& config) | 198 | std::string& group, const AttentionToFFNTilingConfig& config) |
| 254 | { | 199 | { |
| 255 | auto attrs = context->GetAttrs(); | 200 | auto attrs = context->GetAttrs(); |
| 256 | - OP_TILING_CHECK(attrs == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "attrs"), return false); | 201 | + OP_TILING_CHECK( |
| 202 | + attrs == nullptr, | ||
| 203 | + Mc2Error::ReportTilingFailure(nodeName, "Attribute container actual=null; expected schema metadata"), | ||
| 204 | + return false); | ||
| 257 | 205 | ||
| 258 | auto groupPtr = attrs->GetAttrPointer<char>(config.attrGroupIndex); | 206 | auto groupPtr = attrs->GetAttrPointer<char>(config.attrGroupIndex); |
| 259 | - auto worldSizePtr = attrs->GetAttrPointer<int>(config.attrWorldSizeIndex); | 207 | + auto worldSizePtr = attrs->GetAttrPointer<int64_t>(config.attrWorldSizeIndex); |
| 260 | - auto quantModePtr = attrs->GetAttrPointer<int>(config.attrQuantModeIndex); | 208 | + auto quantModePtr = attrs->GetAttrPointer<int64_t>(config.attrQuantModeIndex); |
| 261 | - auto syncFlagPtr = attrs->GetAttrPointer<int>(config.attrSyncFlagIndex); | 209 | + auto syncFlagPtr = attrs->GetAttrPointer<int64_t>(config.attrSyncFlagIndex); |
| 262 | - auto ffnStartRankIdPtr = attrs->GetAttrPointer<int>(config.attrFfnStartRankIdIndex); | 210 | + auto ffnStartRankIdPtr = attrs->GetAttrPointer<int64_t>(config.attrFfnStartRankIdIndex); |
| 263 | - auto moeExpertNumPtr = attrs->GetAttrPointer<int>(config.attrMoeExpertNumIndex); | 211 | + auto moeExpertNumPtr = attrs->GetAttrPointer<int64_t>(config.attrMoeExpertNumIndex); |
| 264 | 212 | ||
| 265 | - OP_TILING_CHECK(groupPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "group"), return false); | 213 | + OP_TILING_CHECK(groupPtr == nullptr, |
| 266 | - OP_TILING_CHECK(worldSizePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "worldSize"), return false); | 214 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( |
| 267 | - OP_TILING_CHECK(moeExpertNumPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "moeExpertNum"), return false); | 215 | + nodeName, "group", "Required attribute group is missing; provide this attribute"), |
| 268 | - OP_TILING_CHECK(quantModePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "quantMode"), return false); | 216 | + return false); |
| 269 | - OP_TILING_CHECK(syncFlagPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "syncFlag"), return false); | 217 | + OP_TILING_CHECK(worldSizePtr == nullptr, |
| 270 | - OP_TILING_CHECK(ffnStartRankIdPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "ffnStartRankId"), return false); | 218 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( |
| 219 | + nodeName, "world_size", "Required attribute world_size is missing; provide this attribute"), | ||
| 220 | + return false); | ||
| 221 | + OP_TILING_CHECK( | ||
| 222 | + moeExpertNumPtr == nullptr, | ||
| 223 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 224 | + nodeName, "moe_expert_num", "Required attribute moe_expert_num is missing; provide this attribute"), | ||
| 225 | + return false); | ||
| 226 | + OP_TILING_CHECK(quantModePtr == nullptr, | ||
| 227 | + Mc2Error::ReportTilingFailure( | ||
| 228 | + nodeName, "Schema-defaulted quant_mode pointer actual=null; expected attribute metadata"), | ||
| 229 | + return false); | ||
| 230 | + OP_TILING_CHECK(syncFlagPtr == nullptr, | ||
| 231 | + Mc2Error::ReportTilingFailure( | ||
| 232 | + nodeName, "Schema-defaulted sync_flag pointer actual=null; expected attribute metadata"), | ||
| 233 | + return false); | ||
| 234 | + OP_TILING_CHECK( | ||
| 235 | + ffnStartRankIdPtr == nullptr, | ||
| 236 | + Mc2Error::ReportTilingFailure( | ||
| 237 | + nodeName, "Schema-defaulted ffn_start_rank_id pointer actual=null; expected attribute metadata"), | ||
| 238 | + return false); | ||
| 271 | 239 | ||
| 272 | - uint32_t moeExpertNum = *moeExpertNumPtr; | 240 | + OP_TILING_CHECK(attrs->GetListInt(config.attrFfnTokenInfoTableShapeIndex) == nullptr, |
| 273 | - uint32_t worldSize = *worldSizePtr; | 241 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( |
| 242 | + nodeName, "ffn_token_info_table_shape", | ||
| 243 | + "Required list attribute is missing; provide ffn_token_info_table_shape"), | ||
| 244 | + return false); | ||
| 245 | + OP_TILING_CHECK( | ||
| 246 | + attrs->GetListInt(config.attrFfnTokenDataShapeIndex) == nullptr, | ||
| 247 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(nodeName, "ffn_token_data_shape", | ||
| 248 | + "Required list attribute is missing; provide ffn_token_data_shape"), | ||
| 249 | + return false); | ||
| 250 | + OP_TILING_CHECK(attrs->GetListInt(config.attrAttnTokenInfoTableShapeIndex) == nullptr, | ||
| 251 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 252 | + nodeName, "attn_token_info_table_shape", | ||
| 253 | + "Required list attribute is missing; provide attn_token_info_table_shape"), | ||
| 254 | + return false); | ||
| 255 | + const int64_t moeExpertNum = *moeExpertNumPtr; | ||
| 256 | + const int64_t worldSize = *worldSizePtr; | ||
| 274 | 257 | ||
| 275 | - OP_TILING_CHECK(!CheckAttrValues(nodeName, moeExpertNum, worldSize, *worldSizePtr, *quantModePtr, *syncFlagPtr, | 258 | + OP_TILING_CHECK(!CheckAttrValues(nodeName, moeExpertNum, worldSize, *quantModePtr, *syncFlagPtr, *ffnStartRankIdPtr, |
| 276 | - *ffnStartRankIdPtr, config.allowMxQuantMode, config.maxWorldSize), | 259 | + config.allowMxQuantMode, config.maxWorldSize), |
| 277 | static_cast<void>(0), return false); | 260 | static_cast<void>(0), return false); |
| 278 | 261 | ||
| 279 | OP_TILING_CHECK(!CheckAndSetShapeAttrs(context, nodeName, tilingData, config), | 262 | OP_TILING_CHECK(!CheckAndSetShapeAttrs(context, nodeName, tilingData, config), |
| 280 | - OP_LOGE(nodeName, "Check and set shape list attrs failed!"), return false); | 263 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check and set shape list attrs failed!"), return false); |
| 281 | 264 | ||
| 282 | tilingData.attentionToFFNInfo.moeExpertNum = static_cast<uint32_t>(moeExpertNum); | 265 | tilingData.attentionToFFNInfo.moeExpertNum = static_cast<uint32_t>(moeExpertNum); |
| 283 | tilingData.attentionToFFNInfo.quantMode = static_cast<uint32_t>(*quantModePtr); | 266 | tilingData.attentionToFFNInfo.quantMode = static_cast<uint32_t>(*quantModePtr); |
| @@ -785,21 +768,21 @@ static bool CheckTensorShapeAndSetTinglingData(const gert::TilingContext* contex | |||
| 785 | 768 | ||
| 786 | OP_TILING_CHECK(!CheckXAndExpertIdShapes(nodeName, xDim0, xDim1, xDim2, sessionIdDim0, microBatchIdDim0, | 769 | OP_TILING_CHECK(!CheckXAndExpertIdShapes(nodeName, xDim0, xDim1, xDim2, sessionIdDim0, microBatchIdDim0, |
| 787 | layerIdDim0, expertIdsDim0, expertIdsDim1, expertIdsDim2, moeExpertNum), | 770 | layerIdDim0, expertIdsDim0, expertIdsDim1, expertIdsDim2, moeExpertNum), |
| 788 | - OP_LOGE(nodeName, "Check x and expertId shape failed!"), return false); | 771 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check x and expertId shape failed!"), return false); |
| 789 | OP_TILING_CHECK(!CheckExpertRankTableShape(nodeName, expertRankTableDim0, expertRankTableDim1, expertRankTableDim2, | 772 | OP_TILING_CHECK(!CheckExpertRankTableShape(nodeName, expertRankTableDim0, expertRankTableDim1, expertRankTableDim2, |
| 790 | moeExpertNum, config), | 773 | moeExpertNum, config), |
| 791 | - OP_LOGE(nodeName, "Check expertRankTable shape failed!"), return false); | 774 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check expertRankTable shape failed!"), return false); |
| 792 | 775 | ||
| 793 | if (isScales) { | 776 | if (isScales) { |
| 794 | const gert::StorageShape* scalesStorageShape = context->GetOptionalInputShape(config.scalesIndex); | 777 | const gert::StorageShape* scalesStorageShape = context->GetOptionalInputShape(config.scalesIndex); |
| 795 | OP_TILING_CHECK(!CheckInputForScales(scalesStorageShape, expertRankTableDim0, expertRankTableDim1, xDim2), | 778 | OP_TILING_CHECK(!CheckInputForScales(scalesStorageShape, expertRankTableDim0, expertRankTableDim1, xDim2), |
| 796 | - OP_LOGE(nodeName, "Check input for scales shape failed!"), return false); | 779 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check input for scales shape failed!"), return false); |
| 797 | } | 780 | } |
| 798 | 781 | ||
| 799 | if (isActiveMask) { | 782 | if (isActiveMask) { |
| 800 | const gert::StorageShape* activeMaskStorageShape = context->GetOptionalInputShape(config.activeMaskIndex); | 783 | const gert::StorageShape* activeMaskStorageShape = context->GetOptionalInputShape(config.activeMaskIndex); |
| 801 | OP_TILING_CHECK(!CheckInputForActiveMask(activeMaskStorageShape, xDim0, xDim1), | 784 | OP_TILING_CHECK(!CheckInputForActiveMask(activeMaskStorageShape, xDim0, xDim1), |
| 802 | - OP_LOGE(nodeName, "Check input for activeMask shape failed!"), return false); | 785 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check input for activeMask shape failed!"), return false); |
| 803 | } | 786 | } |
| 804 | InitTilingDataByXDim(tilingData, xDim0, xDim1, xDim2); | 787 | InitTilingDataByXDim(tilingData, xDim0, xDim1, xDim2); |
| 805 | InitTilingDataByExpert(tilingData, expertIdsDim2, expertRankTableDim0, expertRankTableDim1, expertRankTableDim2); | 788 | InitTilingDataByExpert(tilingData, expertIdsDim2, expertRankTableDim0, expertRankTableDim1, expertRankTableDim2); |
| @@ -837,15 +820,15 @@ static bool CheckInputAndSetTilingData(gert::TilingContext* context, const char* | |||
| 837 | 820 | ||
| 838 | // 校验输入数据dim、format、dataType | 821 | // 校验输入数据dim、format、dataType |
| 839 | OP_TILING_CHECK(!CheckTensorDim(context, nodeName, isScales, isActiveMask, config), | 822 | OP_TILING_CHECK(!CheckTensorDim(context, nodeName, isScales, isActiveMask, config), |
| 840 | - OP_LOGE(nodeName, "input tensor dim is invalid."), return false); | 823 | + OP_LOGE_WITHOUT_REPORT(nodeName, "input tensor dim is invalid."), return false); |
| 841 | OP_TILING_CHECK(!CheckTensorDataType(context, nodeName, isScales, isActiveMask, config), | 824 | OP_TILING_CHECK(!CheckTensorDataType(context, nodeName, isScales, isActiveMask, config), |
| 842 | - OP_LOGE(nodeName, "input tensor dataType is invalid."), return false); | 825 | + OP_LOGE_WITHOUT_REPORT(nodeName, "input tensor dataType is invalid."), return false); |
| 843 | OP_TILING_CHECK(!CheckTensorFormat(context, nodeName, isScales, isActiveMask, config), | 826 | OP_TILING_CHECK(!CheckTensorFormat(context, nodeName, isScales, isActiveMask, config), |
| 844 | - OP_LOGE(nodeName, "input tensor format is invalid."), return false); | 827 | + OP_LOGE_WITHOUT_REPORT(nodeName, "input tensor format is invalid."), return false); |
| 845 | 828 | ||
| 846 | // 校验输入数据维度值 | 829 | // 校验输入数据维度值 |
| 847 | OP_TILING_CHECK(!CheckTensorShapeAndSetTinglingData(context, nodeName, tilingData, isScales, isActiveMask, config), | 830 | OP_TILING_CHECK(!CheckTensorShapeAndSetTinglingData(context, nodeName, tilingData, isScales, isActiveMask, config), |
| 848 | - OP_LOGE(nodeName, "input tensor format is invalid."), return false); | 831 | + OP_LOGE_WITHOUT_REPORT(nodeName, "input tensor format is invalid."), return false); |
| 849 | 832 | ||
| 850 | tilingData.attentionToFFNInfo.isScales = isScales; | 833 | tilingData.attentionToFFNInfo.isScales = isScales; |
| 851 | tilingData.attentionToFFNInfo.isActiveMask = isActiveMask; | 834 | tilingData.attentionToFFNInfo.isActiveMask = isActiveMask; |
| @@ -878,7 +861,10 @@ static ge::graphStatus SetWorkSpace(gert::TilingContext* context, const char* no | |||
| 878 | const AttentionToFFNTilingData* tilingData) | 861 | const AttentionToFFNTilingData* tilingData) |
| 879 | { | 862 | { |
| 880 | size_t* workSpaces = context->GetWorkspaceSizes(1); | 863 | size_t* workSpaces = context->GetWorkspaceSizes(1); |
| 881 | - OP_TILING_CHECK(workSpaces == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "workSpaces"), return ge::GRAPH_FAILED); | 864 | + OP_TILING_CHECK( |
| 865 | + workSpaces == nullptr, | ||
| 866 | + Mc2Error::ReportTilingFailure(nodeName, "SetWorkSpace: workspace holder actual=null; expected one size slot"), | ||
| 867 | + return ge::GRAPH_FAILED); | ||
| 882 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | 868 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); |
| 883 | uint32_t aivNum = ascendcPlatform.GetCoreNumAiv(); | 869 | uint32_t aivNum = ascendcPlatform.GetCoreNumAiv(); |
| 884 | uint32_t ffnNum = tilingData->attentionToFFNInfo.worldSize - tilingData->attentionToFFNInfo.attentionWorkerNum; | 870 | uint32_t ffnNum = tilingData->attentionToFFNInfo.worldSize - tilingData->attentionToFFNInfo.attentionWorkerNum; |
| @@ -922,15 +908,39 @@ static void CalWinSize(AttentionToFFNTilingData& tilingData, const uint32_t quan | |||
| 922 | return; | 908 | return; |
| 923 | } | 909 | } |
| 924 | 910 | ||
| 925 | -static ge::graphStatus SetHcommCfg(AttentionToFFNTilingData& tilingData, const std::string group) | 911 | +static ge::graphStatus SetHcommCfg(const gert::TilingContext* context, AttentionToFFNTilingData& tilingData, |
| 912 | + const std::string group) | ||
| 926 | { | 913 | { |
| 927 | OP_LOGD(ATTN_FFN_INNER_DEBUG, "attentionToFFN group = %s", group.c_str()); | 914 | OP_LOGD(ATTN_FFN_INNER_DEBUG, "attentionToFFN group = %s", group.c_str()); |
| 928 | uint32_t opType1 = OP_TYPE_ALL_TO_ALL; | 915 | uint32_t opType1 = OP_TYPE_ALL_TO_ALL; |
| 929 | std::string algConfigAllToAllStr = "AlltoAll=level0:fullmesh;level1:pairwise"; | 916 | std::string algConfigAllToAllStr = "AlltoAll=level0:fullmesh;level1:pairwise"; |
| 917 | + OP_TILING_CHECK( | ||
| 918 | + group.size() >= 128U, | ||
| 919 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 920 | + context->GetNodeName(), "group", | ||
| 921 | + ("Group length actual=" + std::to_string(group.size()) + "; expected fewer than 128 bytes").c_str()), | ||
| 922 | + return ge::GRAPH_FAILED); | ||
| 923 | + const char* ascendHome = std::getenv("ASCEND_HOME_PATH"); | ||
| 924 | + if (ascendHome == nullptr || ascendHome[0] == '\0') { | ||
| 925 | + OP_LOGE(context->GetNodeName(), | ||
| 926 | + "SetHcommCfg failed: required environment variable ASCEND_HOME_PATH is absent or empty"); | ||
| 927 | + return ge::GRAPH_FAILED; | ||
| 928 | + } | ||
| 930 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType1, algConfigAllToAllStr); | 929 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType1, algConfigAllToAllStr); |
| 931 | 930 | ||
| 932 | - mc2CcTilingConfig.GetTiling(tilingData.mc2InitTiling); | 931 | + const auto initStatus = mc2CcTilingConfig.GetTiling(tilingData.mc2InitTiling); |
| 933 | - mc2CcTilingConfig.GetTiling(tilingData.mc2CcTiling1); | 932 | + OP_TILING_CHECK(initStatus != 0, |
| 933 | + Mc2Error::ReportTilingFailure( | ||
| 934 | + context->GetNodeName(), | ||
| 935 | + "SetHcommCfg: GetTiling(init) failed obtaining required rtGetSocVersion from " + | ||
| 936 | + std::string(ascendHome) + "/lib64/libruntime.so; actual rc=" + std::to_string(initStatus) + | ||
| 937 | + ", expected 0 for validated group and fixed AlltoAll algorithm"), | ||
| 938 | + return ge::GRAPH_FAILED); | ||
| 939 | + const auto ccStatus = mc2CcTilingConfig.GetTiling(tilingData.mc2CcTiling1); | ||
| 940 | + OP_TILING_CHECK(ccStatus != 0, | ||
| 941 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "SetHcommCfg: GetTiling(CC) invariant failed, rc=%u", | ||
| 942 | + static_cast<unsigned>(ccStatus)), | ||
| 943 | + return ge::GRAPH_FAILED); | ||
| 934 | 944 | ||
| 935 | return ge::GRAPH_SUCCESS; | 945 | return ge::GRAPH_SUCCESS; |
| 936 | } | 946 | } |
| @@ -939,7 +949,7 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 939 | const AttentionToFFNTilingConfig& config) | 949 | const AttentionToFFNTilingConfig& config) |
| 940 | { | 950 | { |
| 941 | const gert::StorageShape* contextStorageShape = context->GetInputShape(config.contextIndex); | 951 | const gert::StorageShape* contextStorageShape = context->GetInputShape(config.contextIndex); |
| 942 | - OP_TILING_CHECK(contextStorageShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "contextShape"), | 952 | + OP_TILING_CHECK(contextStorageShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "context"), |
| 943 | return ge::GRAPH_FAILED); | 953 | return ge::GRAPH_FAILED); |
| 944 | OP_TILING_CHECK(contextStorageShape->GetStorageShape().GetDimNum() != ONE_DIM, | 954 | OP_TILING_CHECK(contextStorageShape->GetStorageShape().GetDimNum() != ONE_DIM, |
| 945 | OP_LOGE_FOR_INVALID_SHAPEDIM( | 955 | OP_LOGE_FOR_INVALID_SHAPEDIM( |
| @@ -948,7 +958,9 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 948 | return ge::GRAPH_FAILED); | 958 | return ge::GRAPH_FAILED); |
| 949 | 959 | ||
| 950 | auto contextDesc = context->GetInputDesc(config.contextIndex); | 960 | auto contextDesc = context->GetInputDesc(config.contextIndex); |
| 951 | - OP_TILING_CHECK(contextDesc == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "contextDesc"), | 961 | + OP_TILING_CHECK(contextDesc == nullptr, |
| 962 | + Mc2Error::ReportTilingFailure(nodeName, "CheckMc2Context: context descriptor actual=null after " | ||
| 963 | + "required shape was present; expected descriptor metadata"), | ||
| 952 | return ge::GRAPH_FAILED); | 964 | return ge::GRAPH_FAILED); |
| 953 | OP_TILING_CHECK(contextDesc->GetDataType() != ge::DT_INT32, | 965 | OP_TILING_CHECK(contextDesc->GetDataType() != ge::DT_INT32, |
| 954 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "context", | 966 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "context", |
| @@ -970,10 +982,16 @@ static ge::graphStatus CheckAttentionCclBufferSize(const gert::TilingContext* co | |||
| 970 | { | 982 | { |
| 971 | if (attrIndex != UINT32_MAX) { | 983 | if (attrIndex != UINT32_MAX) { |
| 972 | auto attrsPtr = context->GetAttrs(); | 984 | auto attrsPtr = context->GetAttrs(); |
| 973 | - OP_TILING_CHECK(attrsPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "attrs"), return ge::GRAPH_FAILED); | 985 | + OP_TILING_CHECK( |
| 986 | + attrsPtr == nullptr, | ||
| 987 | + Mc2Error::ReportTilingFailure(nodeName, "Attribute container actual=null; expected schema metadata"), | ||
| 988 | + return ge::GRAPH_FAILED); | ||
| 974 | auto cclBufferSizePtr = attrsPtr->GetAttrPointer<int64_t>(attrIndex); | 989 | auto cclBufferSizePtr = attrsPtr->GetAttrPointer<int64_t>(attrIndex); |
| 975 | - OP_TILING_CHECK(cclBufferSizePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "ccl_buffer_size"), | 990 | + OP_TILING_CHECK( |
| 976 | - return ge::GRAPH_FAILED); | 991 | + cclBufferSizePtr == nullptr, |
| 992 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 993 | + nodeName, "ccl_buffer_size", "Required attribute ccl_buffer_size is missing; provide this attribute"), | ||
| 994 | + return ge::GRAPH_FAILED); | ||
| 977 | OP_TILING_CHECK(*cclBufferSizePtr <= 0, | 995 | OP_TILING_CHECK(*cclBufferSizePtr <= 0, |
| 978 | OP_LOGE_FOR_INVALID_VALUE(nodeName, "ccl_buffer_size", | 996 | OP_LOGE_FOR_INVALID_VALUE(nodeName, "ccl_buffer_size", |
| 979 | std::to_string(*cclBufferSizePtr).c_str(), "greater than 0"), | 997 | std::to_string(*cclBufferSizePtr).c_str(), "greater than 0"), |
| @@ -1038,34 +1056,68 @@ static ge::graphStatus CheckAttentionFFNRankRange(const char* nodeName, const At | |||
| 1038 | uint32_t ffnNum = tilingData->attentionToFFNInfo.worldSize - tilingData->attentionToFFNInfo.attentionWorkerNum; | 1056 | uint32_t ffnNum = tilingData->attentionToFFNInfo.worldSize - tilingData->attentionToFFNInfo.attentionWorkerNum; |
| 1039 | OP_TILING_CHECK( | 1057 | OP_TILING_CHECK( |
| 1040 | tilingData->attentionToFFNInfo.ffnStartRankId + ffnNum > tilingData->attentionToFFNInfo.worldSize, | 1058 | tilingData->attentionToFFNInfo.ffnStartRankId + ffnNum > tilingData->attentionToFFNInfo.worldSize, |
| 1041 | - OP_LOGE_FOR_INVALID_VALUE( | 1059 | + OP_LOGE_FOR_INVALID_VALUES_WITH_REASON( |
| 1042 | - nodeName, "ffn_start_rank_id", std::to_string(tilingData->attentionToFFNInfo.ffnStartRankId).c_str(), | 1060 | + nodeName, "ffn_start_rank_id, ffn_num, world_size", |
| 1043 | - (std::string("[0, ") + std::to_string(tilingData->attentionToFFNInfo.attentionWorkerNum) + | 1061 | + (std::string("ffn_start_rank_id=") + std::to_string(tilingData->attentionToFFNInfo.ffnStartRankId) + ", " + |
| 1044 | - "] (ffn_start_rank_id + ffn_num must not exceed world_size)") | 1062 | + std::string("ffn_num=") + std::to_string(ffnNum) + ", " + std::string("world_size=") + |
| 1045 | - .c_str()), | 1063 | + std::to_string(tilingData->attentionToFFNInfo.worldSize)) |
| 1064 | + .c_str(), | ||
| 1065 | + "ffn_start_rank_id + ffn_num must not exceed world_size"), | ||
| 1046 | return ge::GRAPH_FAILED); | 1066 | return ge::GRAPH_FAILED); |
| 1047 | return ge::GRAPH_SUCCESS; | 1067 | return ge::GRAPH_SUCCESS; |
| 1048 | } | 1068 | } |
| 1049 | 1069 | ||
| 1050 | ge::graphStatus AttentionToFFNTilingFuncBase(gert::TilingContext* context, const AttentionToFFNTilingConfig& config) | 1070 | ge::graphStatus AttentionToFFNTilingFuncBase(gert::TilingContext* context, const AttentionToFFNTilingConfig& config) |
| 1051 | { | 1071 | { |
| 1072 | + OP_TILING_CHECK(context == nullptr, | ||
| 1073 | + Mc2Error::ReportTilingFailure( | ||
| 1074 | + "AttentionToFFN", | ||
| 1075 | + "AttentionToFFNTilingFuncBase: context actual=null; expected materialized tiling context"), | ||
| 1076 | + return ge::GRAPH_FAILED); | ||
| 1077 | + OP_TILING_CHECK( | ||
| 1078 | + context->GetPlatformInfo() == nullptr, | ||
| 1079 | + Mc2Error::ReportTilingFailure( | ||
| 1080 | + context->GetNodeName(), | ||
| 1081 | + "AttentionToFFNTilingFuncBase: platform metadata actual=null; expected CANN platform information"), | ||
| 1082 | + return ge::GRAPH_FAILED); | ||
| 1083 | + auto entryPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | ||
| 1084 | + const uint32_t entryAivNum = entryPlatform.GetCoreNumAiv(); | ||
| 1085 | + OP_TILING_CHECK( | ||
| 1086 | + entryAivNum == 0U, | ||
| 1087 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), | ||
| 1088 | + "AttentionToFFNTilingFuncBase: AIV core count actual=0; expected positive"), | ||
| 1089 | + return ge::GRAPH_FAILED); | ||
| 1090 | + | ||
| 1052 | AttentionToFFNTilingData* tilingData = context->GetTilingData<AttentionToFFNTilingData>(); | 1091 | AttentionToFFNTilingData* tilingData = context->GetTilingData<AttentionToFFNTilingData>(); |
| 1053 | std::string group = ""; | 1092 | std::string group = ""; |
| 1054 | const char* nodeName = context->GetNodeName(); | 1093 | const char* nodeName = context->GetNodeName(); |
| 1055 | - OP_TILING_CHECK(tilingData == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "tilingData"), return ge::GRAPH_FAILED); | 1094 | + OP_TILING_CHECK( |
| 1095 | + tilingData == nullptr, | ||
| 1096 | + Mc2Error::ReportTilingFailure( | ||
| 1097 | + nodeName, "AttentionToFFNTilingFuncBase: raw tilingData actual=null or capacity insufficient; required=" + | ||
| 1098 | + std::to_string(sizeof(AttentionToFFNTilingData))), | ||
| 1099 | + return ge::GRAPH_FAILED); | ||
| 1056 | 1100 | ||
| 1057 | if (config.isMc2Context) { | 1101 | if (config.isMc2Context) { |
| 1058 | OP_TILING_CHECK(CheckMc2Context(context, nodeName, config) != ge::GRAPH_SUCCESS, | 1102 | OP_TILING_CHECK(CheckMc2Context(context, nodeName, config) != ge::GRAPH_SUCCESS, |
| 1059 | OP_LOGE(nodeName, "Tiling check context failed."), return ge::GRAPH_FAILED); | 1103 | OP_LOGE(nodeName, "Tiling check context failed."), return ge::GRAPH_FAILED); |
| 1060 | } | 1104 | } |
| 1061 | 1105 | ||
| 1106 | + OP_TILING_CHECK(context->GetInputShape(config.xIndex) == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "x"), | ||
| 1107 | + return ge::GRAPH_FAILED); | ||
| 1108 | + OP_TILING_CHECK( | ||
| 1109 | + context->GetInputShape(config.xIndex)->GetStorageShape().GetDimNum() != DIM3, | ||
| 1110 | + OP_LOGE_FOR_INVALID_SHAPEDIM( | ||
| 1111 | + nodeName, "x", std::to_string(context->GetInputShape(config.xIndex)->GetStorageShape().GetDimNum()).c_str(), | ||
| 1112 | + "3"), | ||
| 1113 | + return ge::GRAPH_FAILED); | ||
| 1062 | // Function that get check and set Attrs | 1114 | // Function that get check and set Attrs |
| 1063 | OP_TILING_CHECK(!CheckAndSetAttrs(context, nodeName, *tilingData, group, config), | 1115 | OP_TILING_CHECK(!CheckAndSetAttrs(context, nodeName, *tilingData, group, config), |
| 1064 | - OP_LOGE(nodeName, "Check and set attributes failed!"), return ge::GRAPH_FAILED); | 1116 | + OP_LOGE_LIBOPAPI_REPORT(nodeName, "Check and set attributes failed!"), return ge::GRAPH_FAILED); |
| 1065 | 1117 | ||
| 1066 | // Function that check input | 1118 | // Function that check input |
| 1067 | OP_TILING_CHECK(!CheckInputAndSetTilingData(context, nodeName, *tilingData, config), | 1119 | OP_TILING_CHECK(!CheckInputAndSetTilingData(context, nodeName, *tilingData, config), |
| 1068 | - OP_LOGE(nodeName, "Check Inputs and Outputs failed!"), return ge::GRAPH_FAILED); | 1120 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check Inputs and Outputs failed!"), return ge::GRAPH_FAILED); |
| 1069 | 1121 | ||
| 1070 | OP_TILING_CHECK(CheckAttentionFFNRankRange(nodeName, tilingData) != ge::GRAPH_SUCCESS, static_cast<void>(0), | 1122 | OP_TILING_CHECK(CheckAttentionFFNRankRange(nodeName, tilingData) != ge::GRAPH_SUCCESS, static_cast<void>(0), |
| 1071 | return ge::GRAPH_FAILED); | 1123 | return ge::GRAPH_FAILED); |
| @@ -1076,11 +1128,11 @@ ge::graphStatus AttentionToFFNTilingFuncBase(gert::TilingContext* context, const | |||
| 1076 | 1128 | ||
| 1077 | // Set WorkSpace | 1129 | // Set WorkSpace |
| 1078 | OP_TILING_CHECK(SetWorkSpace(context, nodeName, tilingData) != ge::GRAPH_SUCCESS, | 1130 | OP_TILING_CHECK(SetWorkSpace(context, nodeName, tilingData) != ge::GRAPH_SUCCESS, |
| 1079 | - OP_LOGE(nodeName, "Tiling set workspace failed."), return ge::GRAPH_FAILED); | 1131 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Tiling set workspace failed."), return ge::GRAPH_FAILED); |
| 1080 | 1132 | ||
| 1081 | // Set HcommCfg | 1133 | // Set HcommCfg |
| 1082 | - OP_TILING_CHECK(SetHcommCfg(*tilingData, group) != ge::GRAPH_SUCCESS, OP_LOGE(nodeName, "setHcommCfg failed."), | 1134 | + OP_TILING_CHECK(SetHcommCfg(context, *tilingData, group) != ge::GRAPH_SUCCESS, |
| 1083 | - return ge::GRAPH_FAILED); | 1135 | + OP_LOGE_WITHOUT_REPORT(nodeName, "setHcommCfg failed."), return ge::GRAPH_FAILED); |
| 1084 | 1136 | ||
| 1085 | // Set TilingKey | 1137 | // Set TilingKey |
| 1086 | uint32_t syncFlag = tilingData->attentionToFFNInfo.syncFlag; | 1138 | uint32_t syncFlag = tilingData->attentionToFFNInfo.syncFlag; |
| @@ -0,0 +1,81 @@ | |||
| 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 | +#ifndef ATTENTION_TO_FFN_TILING_CHECKS_H | ||
| 12 | +#define ATTENTION_TO_FFN_TILING_CHECKS_H | ||
| 13 | + | ||
| 14 | +#include <string> | ||
| 15 | +#include "register/tilingdata_base.h" | ||
| 16 | +#include "mc2_log.h" | ||
| 17 | + | ||
| 18 | +namespace MC2Tiling { | ||
| 19 | +constexpr uint32_t UNQUANT_MODE = 0; | ||
| 20 | +constexpr uint32_t DYNAMIC_QUANT_MODE = 2; | ||
| 21 | +constexpr uint32_t NO_SCALES = 0; | ||
| 22 | +constexpr uint32_t DYNAMIC_SCALES = 2; | ||
| 23 | +constexpr int64_t MOE_EXPERT_MAX_NUM = 1024; | ||
| 24 | +constexpr int64_t MIN_WORLD_SIZE = 2; | ||
| 25 | +constexpr uint32_t USER_QUANT_MODE_MX_E5M2 = 3U; | ||
| 26 | +constexpr uint32_t USER_QUANT_MODE_MX_E4M3 = 4U; | ||
| 27 | +constexpr uint32_t USER_QUANT_MODE_MX_E2M1 = 5U; | ||
| 28 | +constexpr uint32_t USER_QUANT_MODE_MX_CLIP_E5M2 = 6U; | ||
| 29 | +constexpr uint32_t USER_QUANT_MODE_MX_CLIP_E4M3 = 7U; | ||
| 30 | + | ||
| 31 | +inline bool IsMxQuantMode(int64_t quantMode) | ||
| 32 | +{ | ||
| 33 | + return quantMode == USER_QUANT_MODE_MX_E5M2 || quantMode == USER_QUANT_MODE_MX_E4M3 || | ||
| 34 | + quantMode == USER_QUANT_MODE_MX_E2M1 || quantMode == USER_QUANT_MODE_MX_CLIP_E5M2 || | ||
| 35 | + quantMode == USER_QUANT_MODE_MX_CLIP_E4M3; | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +inline bool CheckAttrValues(const char* nodeName, const int64_t moeExpertNum, const int64_t worldSize, | ||
| 39 | + const int64_t quantMode, const int64_t syncFlag, const int64_t ffnStartRankId, | ||
| 40 | + const bool allowMxQuantMode, const int64_t maxWorldSize) | ||
| 41 | +{ | ||
| 42 | + OP_TILING_CHECK( | ||
| 43 | + (worldSize < MIN_WORLD_SIZE) || (static_cast<int64_t>(worldSize) > maxWorldSize), | ||
| 44 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 45 | + nodeName, "world_size", std::to_string(worldSize).c_str(), | ||
| 46 | + (std::string("[") + std::to_string(MIN_WORLD_SIZE) + ", " + std::to_string(maxWorldSize) + "]").c_str()), | ||
| 47 | + return false); | ||
| 48 | + | ||
| 49 | + OP_TILING_CHECK( | ||
| 50 | + (moeExpertNum <= 0) || (moeExpertNum > MOE_EXPERT_MAX_NUM), | ||
| 51 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(nodeName, "moe_expert_num", std::to_string(moeExpertNum).c_str(), | ||
| 52 | + (std::string("(0, ") + std::to_string(MOE_EXPERT_MAX_NUM) + "]").c_str()), | ||
| 53 | + return false); | ||
| 54 | + if (allowMxQuantMode) { | ||
| 55 | + OP_TILING_CHECK(quantMode != UNQUANT_MODE && quantMode != DYNAMIC_QUANT_MODE && | ||
| 56 | + !IsMxQuantMode(static_cast<uint32_t>(quantMode)), | ||
| 57 | + OP_LOGE_WITH_INVALID_ATTR("AttentionToFFN Tiling Debug", "quant_mode", | ||
| 58 | + std::to_string(quantMode).c_str(), "0, 2, 3, 4, 5, 6 or 7"), | ||
| 59 | + return false); | ||
| 60 | + } else { | ||
| 61 | + OP_TILING_CHECK( | ||
| 62 | + (quantMode < static_cast<int64_t>(NO_SCALES)) || (quantMode > static_cast<int64_t>(DYNAMIC_SCALES)), | ||
| 63 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(nodeName, "quant_mode", std::to_string(quantMode).c_str(), | ||
| 64 | + (std::string("[0, ") + std::to_string(DYNAMIC_SCALES) + "]").c_str()), | ||
| 65 | + return false); | ||
| 66 | + } | ||
| 67 | + OP_TILING_CHECK( | ||
| 68 | + (syncFlag != 0) && (syncFlag != 1), | ||
| 69 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(nodeName, "sync_flag", std::to_string(syncFlag).c_str(), "0 or 1"), | ||
| 70 | + return false); | ||
| 71 | + OP_TILING_CHECK( | ||
| 72 | + (ffnStartRankId >= worldSize) || (ffnStartRankId < 0), | ||
| 73 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(nodeName, "ffn_start_rank_id", std::to_string(ffnStartRankId).c_str(), | ||
| 74 | + (std::string("[0, ") + std::to_string(worldSize) + ")").c_str()), | ||
| 75 | + return false); | ||
| 76 | + | ||
| 77 | + return true; | ||
| 78 | +} | ||
| 79 | +} // namespace MC2Tiling | ||
| 80 | + | ||
| 81 | +#endif // ATTENTION_TO_FFN_TILING_CHECKS_H | ||
| @@ -10,4 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | if(UT_TEST_ALL OR OP_HOST_UT) | 11 | if(UT_TEST_ALL OR OP_HOST_UT) |
| 12 | add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) | 12 | add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 13 | + if(TARGET ${OP_TILING_MODULE_NAME}_cases_obj) | ||
| 14 | + target_link_libraries(${OP_TILING_MODULE_NAME}_cases_obj PRIVATE error_manager) | ||
| 15 | + endif() | ||
| 13 | endif() | 16 | endif() |
| @@ -10,8 +10,13 @@ | |||
| 10 | 10 | ||
| 11 | #include <iostream> | 11 | #include <iostream> |
| 12 | #include <gtest/gtest.h> | 12 | #include <gtest/gtest.h> |
| 13 | +#include "../../../../../common/tests/ut/formal_error_assertions.h" | ||
| 13 | #include "../../../../op_kernel/attention_to_ffn_tiling.h" | 14 | #include "../../../../op_kernel/attention_to_ffn_tiling.h" |
| 14 | #include "mc2_tiling_case_executor.h" | 15 | #include "mc2_tiling_case_executor.h" |
| 16 | +#include "mc2/attention_to_ffn/op_host/op_tiling/attention_to_ffn_tiling_checks.h" | ||
| 17 | + | ||
| 18 | +using Mc2ErrorCodeUT::ExcelErrorReportScope; | ||
| 19 | +using Mc2ErrorCodeUT::ExpectExcelFormalError; | ||
| 15 | 20 | ||
| 16 | namespace AttentionToFFNUT { | 21 | namespace AttentionToFFNUT { |
| 17 | 22 | ||
| @@ -1241,4 +1246,361 @@ TEST_F(AttentionToFFNArch22TilingTest, ActiveMaskFormatInvalid) | |||
| 1241 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); | 1246 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); |
| 1242 | } | 1247 | } |
| 1243 | 1248 | ||
| 1249 | +TEST_F(AttentionToFFNArch22TilingTest, InvalidExpertCountReportsSingleFormalError) | ||
| 1250 | +{ | ||
| 1251 | + ExcelErrorReportScope reportScope; | ||
| 1252 | + struct AttentionToFFNCompileInfo { | ||
| 1253 | + } compileInfo; | ||
| 1254 | + | ||
| 1255 | + gert::TilingContextPara tilingContextPara( | ||
| 1256 | + "AttentionToFFN", | ||
| 1257 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1258 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1259 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1260 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1261 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1262 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1263 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1264 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1265 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1266 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1267 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1268 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1269 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1270 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1271 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1272 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1273 | + &compileInfo, "Ascend910_93"); | ||
| 1274 | + | ||
| 1275 | + uint64_t expectTilingKey = 0UL; | ||
| 1276 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1277 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1278 | + ExpectExcelFormalError("EZ0026", "moe_expert_num", "0"); | ||
| 1279 | +} | ||
| 1280 | + | ||
| 1281 | +TEST_F(AttentionToFFNArch22TilingTest, InvalidQuantModeReportsSingleFormalError) | ||
| 1282 | +{ | ||
| 1283 | + ExcelErrorReportScope reportScope; | ||
| 1284 | + struct AttentionToFFNCompileInfo { | ||
| 1285 | + } compileInfo; | ||
| 1286 | + | ||
| 1287 | + gert::TilingContextPara tilingContextPara( | ||
| 1288 | + "AttentionToFFN", | ||
| 1289 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1290 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1291 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1292 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1293 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1294 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1295 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1296 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1297 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1298 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1299 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1300 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1301 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1302 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(9)}, | ||
| 1303 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1304 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1305 | + &compileInfo, "Ascend910_93"); | ||
| 1306 | + | ||
| 1307 | + uint64_t expectTilingKey = 0UL; | ||
| 1308 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1309 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1310 | + ExpectExcelFormalError("EZ0026", "quant_mode", "9"); | ||
| 1311 | +} | ||
| 1312 | + | ||
| 1313 | +TEST_F(AttentionToFFNArch22TilingTest, InvalidSyncFlagReportsSingleFormalError) | ||
| 1314 | +{ | ||
| 1315 | + ExcelErrorReportScope reportScope; | ||
| 1316 | + struct AttentionToFFNCompileInfo { | ||
| 1317 | + } compileInfo; | ||
| 1318 | + | ||
| 1319 | + gert::TilingContextPara tilingContextPara( | ||
| 1320 | + "AttentionToFFN", | ||
| 1321 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1322 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1323 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1324 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1325 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1326 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1327 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1328 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1329 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1330 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1331 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1332 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1333 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1334 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1335 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(2)}, | ||
| 1336 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1337 | + &compileInfo, "Ascend910_93"); | ||
| 1338 | + | ||
| 1339 | + uint64_t expectTilingKey = 0UL; | ||
| 1340 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1341 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1342 | + ExpectExcelFormalError("EZ0026", "sync_flag", "2"); | ||
| 1343 | +} | ||
| 1344 | + | ||
| 1345 | +TEST_F(AttentionToFFNArch22TilingTest, InvalidStartRankRelationReportsSingleFormalError) | ||
| 1346 | +{ | ||
| 1347 | + ExcelErrorReportScope reportScope; | ||
| 1348 | + struct AttentionToFFNCompileInfo { | ||
| 1349 | + } compileInfo; | ||
| 1350 | + | ||
| 1351 | + gert::TilingContextPara tilingContextPara( | ||
| 1352 | + "AttentionToFFN", | ||
| 1353 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1354 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1355 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1356 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1357 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1358 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1359 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1360 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1361 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1362 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1363 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1364 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1365 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1366 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1367 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1368 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}}, | ||
| 1369 | + &compileInfo, "Ascend910_93"); | ||
| 1370 | + | ||
| 1371 | + uint64_t expectTilingKey = 0UL; | ||
| 1372 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1373 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1374 | + ExpectExcelFormalError("EZ0026", "ffn_start_rank_id", "16"); | ||
| 1375 | +} | ||
| 1376 | + | ||
| 1377 | +TEST_F(AttentionToFFNArch22TilingTest, InvalidWorldSizeReportsSingleFormalError) | ||
| 1378 | +{ | ||
| 1379 | + ExcelErrorReportScope reportScope; | ||
| 1380 | + struct AttentionToFFNCompileInfo { | ||
| 1381 | + } compileInfo; | ||
| 1382 | + | ||
| 1383 | + gert::TilingContextPara tilingContextPara( | ||
| 1384 | + "AttentionToFFN", | ||
| 1385 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1386 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1387 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1388 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1389 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1390 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1391 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1392 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1393 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(1)}, | ||
| 1394 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1395 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1396 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1397 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1398 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1399 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1400 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1401 | + &compileInfo, "Ascend910_93"); | ||
| 1402 | + | ||
| 1403 | + uint64_t expectTilingKey = 0UL; | ||
| 1404 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1405 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1406 | + ExpectExcelFormalError("EZ0026", "world_size", "1"); | ||
| 1407 | +} | ||
| 1408 | + | ||
| 1409 | +TEST_F(AttentionToFFNArch22TilingTest, InvalidFfnRangeReportsSingleFormalError) | ||
| 1410 | +{ | ||
| 1411 | + ExcelErrorReportScope reportScope; | ||
| 1412 | + struct AttentionToFFNCompileInfo { | ||
| 1413 | + } compileInfo; | ||
| 1414 | + | ||
| 1415 | + gert::TilingContextPara tilingContextPara( | ||
| 1416 | + "AttentionToFFN", | ||
| 1417 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1418 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1419 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1420 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1421 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1422 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1423 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1424 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1425 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1426 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1427 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1428 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1429 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1430 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1431 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1432 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(12)}}, | ||
| 1433 | + &compileInfo, "Ascend910_93"); | ||
| 1434 | + | ||
| 1435 | + uint64_t expectTilingKey = 0UL; | ||
| 1436 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1437 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1438 | + ExpectExcelFormalError("EZ0027", "ffn_start_rank_id, ffn_num, world_size", | ||
| 1439 | + "ffn_start_rank_id=12, ffn_num=5, world_size=16", | ||
| 1440 | + "ffn_start_rank_id + ffn_num must not exceed world_size"); | ||
| 1441 | +} | ||
| 1442 | +TEST_F(AttentionToFFNArch22TilingTest, NegativeExpertCountPreservesSignedActual) | ||
| 1443 | +{ | ||
| 1444 | + ExcelErrorReportScope reportScope; | ||
| 1445 | + struct AttentionToFFNCompileInfo { | ||
| 1446 | + } compileInfo; | ||
| 1447 | + | ||
| 1448 | + gert::TilingContextPara tilingContextPara( | ||
| 1449 | + "AttentionToFFN", | ||
| 1450 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1451 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1452 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1453 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1454 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1455 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1456 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1457 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1458 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1459 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1460 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1461 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1462 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(-1)}, | ||
| 1463 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1464 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1465 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1466 | + &compileInfo, "Ascend910_93"); | ||
| 1467 | + | ||
| 1468 | + uint64_t expectTilingKey = 0UL; | ||
| 1469 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1470 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1471 | + ExpectExcelFormalError("EZ0026", "moe_expert_num", "-1"); | ||
| 1472 | +} | ||
| 1473 | + | ||
| 1474 | +TEST_F(AttentionToFFNArch22TilingTest, ZeroWorldSizeReportsBeforeRank) | ||
| 1475 | +{ | ||
| 1476 | + ExcelErrorReportScope reportScope; | ||
| 1477 | + struct AttentionToFFNCompileInfo { | ||
| 1478 | + } compileInfo; | ||
| 1479 | + | ||
| 1480 | + gert::TilingContextPara tilingContextPara( | ||
| 1481 | + "AttentionToFFN", | ||
| 1482 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1483 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1484 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1485 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1486 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1487 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1488 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1489 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1490 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1491 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1492 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1493 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1494 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1495 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1496 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1497 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1498 | + &compileInfo, "Ascend910_93"); | ||
| 1499 | + | ||
| 1500 | + uint64_t expectTilingKey = 0UL; | ||
| 1501 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1502 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1503 | + ExpectExcelFormalError("EZ0026", "world_size", "0"); | ||
| 1504 | +} | ||
| 1505 | + | ||
| 1506 | +TEST_F(AttentionToFFNArch22TilingTest, NegativeWorldSizeReportsBeforeRank) | ||
| 1507 | +{ | ||
| 1508 | + ExcelErrorReportScope reportScope; | ||
| 1509 | + struct AttentionToFFNCompileInfo { | ||
| 1510 | + } compileInfo; | ||
| 1511 | + | ||
| 1512 | + gert::TilingContextPara tilingContextPara( | ||
| 1513 | + "AttentionToFFN", | ||
| 1514 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1515 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1516 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1517 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1518 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1519 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1520 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1521 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1522 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(-1)}, | ||
| 1523 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1524 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1525 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1526 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1527 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1528 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1529 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1530 | + &compileInfo, "Ascend910_93"); | ||
| 1531 | + | ||
| 1532 | + uint64_t expectTilingKey = 0UL; | ||
| 1533 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1534 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1535 | + ExpectExcelFormalError("EZ0026", "world_size", "-1"); | ||
| 1536 | +} | ||
| 1537 | + | ||
| 1538 | +TEST_F(AttentionToFFNArch22TilingTest, ShapeListLengthPreservesSingleLeafReport) | ||
| 1539 | +{ | ||
| 1540 | + ExcelErrorReportScope reportScope; | ||
| 1541 | + struct AttentionToFFNCompileInfo { | ||
| 1542 | + } compileInfo; | ||
| 1543 | + | ||
| 1544 | + gert::TilingContextPara tilingContextPara( | ||
| 1545 | + "AttentionToFFN", | ||
| 1546 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1547 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1548 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1549 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1550 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1551 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1552 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1553 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1554 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 1555 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1556 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9})}, | ||
| 1557 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1558 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1559 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1560 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1561 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1562 | + &compileInfo, "Ascend910_93"); | ||
| 1563 | + | ||
| 1564 | + uint64_t expectTilingKey = 0UL; | ||
| 1565 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1566 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1567 | + ExpectExcelFormalError("EZ0011", "ffn_token_data_shape", "4D", nullptr, nullptr, {{"correct_dim", "5D"}}); | ||
| 1568 | +} | ||
| 1569 | + | ||
| 1570 | +TEST_F(AttentionToFFNArch22TilingTest, MissingWorldSizeUsesPublicAttributeName) | ||
| 1571 | +{ | ||
| 1572 | + ExcelErrorReportScope reportScope; | ||
| 1573 | + struct AttentionToFFNCompileInfo { | ||
| 1574 | + } compileInfo; | ||
| 1575 | + | ||
| 1576 | + gert::TilingContextPara tilingContextPara( | ||
| 1577 | + "AttentionToFFN", | ||
| 1578 | + {{{{1, 16, 7168}, {1, 16, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 1579 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1580 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1581 | + {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1582 | + {{{1, 16, 8}, {1, 16, 8}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 1583 | + {{{1, 9, 4}, {1, 9, 4}}, ge::DT_INT32, ge::FORMAT_ND}}, | ||
| 1584 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 1585 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 1586 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(1)}, | ||
| 1587 | + {"ffn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 146})}, | ||
| 1588 | + {"ffn_token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({11, 1, 16, 9, 7168})}, | ||
| 1589 | + {"attn_token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 1590 | + {"moe_expert_num", Ops::Transformer::AnyValue::CreateFrom<int64_t>(8)}, | ||
| 1591 | + {"quant_mode", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1592 | + {"sync_flag", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 1593 | + {"ffn_start_rank_id", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}}, | ||
| 1594 | + &compileInfo, "Ascend910_93"); | ||
| 1595 | + | ||
| 1596 | + tilingContextPara.attrs_.erase(tilingContextPara.attrs_.begin() + 1, tilingContextPara.attrs_.end()); | ||
| 1597 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 1598 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 1599 | + const auto errors = ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 1600 | + ASSERT_EQ(errors.size(), 1U); | ||
| 1601 | + EXPECT_EQ(errors[0].error_id, "EZ0037"); | ||
| 1602 | + EXPECT_EQ(errors[0].args_map.at("param_name"), "world_size"); | ||
| 1603 | + EXPECT_EQ(errors[0].args_map.at("reason"), "Required attribute world_size is missing; provide this attribute"); | ||
| 1604 | +} | ||
| 1605 | + | ||
| 1244 | } // namespace AttentionToFFNUT | 1606 | } // namespace AttentionToFFNUT |
| @@ -0,0 +1,26 @@ | |||
| 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 | +#ifndef MC2_API_ERROR_H | ||
| 12 | +#define MC2_API_ERROR_H | ||
| 13 | + | ||
| 14 | +#include <vector> | ||
| 15 | +#include "mc2_log_compat.h" | ||
| 16 | + | ||
| 17 | +namespace Mc2Aclnn { | ||
| 18 | +inline void ReportRequiredApiPointer(const char* functionName, const char* parameterName) | ||
| 19 | +{ | ||
| 20 | + OP_LOGE_LIBOPAPI_REPORT(functionName, "%s cannot be a null pointer.", parameterName); | ||
| 21 | + const std::vector<const char*> keys = {"functionName", "paraName"}; | ||
| 22 | + const std::vector<const char*> values = {functionName, parameterName}; | ||
| 23 | + REPORT_PREDEFINED_ERR_MSG("EZ1011", keys, values); | ||
| 24 | +} | ||
| 25 | +} // namespace Mc2Aclnn | ||
| 26 | +#endif | ||
| @@ -22,11 +22,18 @@ inline ge::graphStatus InferCombineOutputShape(gert::InferShapeContext* context, | |||
| 22 | size_t expertIdsIndex, size_t outputIndex) | 22 | size_t expertIdsIndex, size_t outputIndex) |
| 23 | { | 23 | { |
| 24 | const gert::Shape* expandXShape = context->GetInputShape(expandXIndex); | 24 | const gert::Shape* expandXShape = context->GetInputShape(expandXIndex); |
| 25 | - OPS_CHECK_NULL_WITH_CONTEXT(context, expandXShape); | 25 | + OP_CHECK_IF(expandXShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "expand_x"), |
| 26 | + return ge::GRAPH_FAILED); | ||
| 26 | const gert::Shape* expertIdsShape = context->GetInputShape(expertIdsIndex); | 27 | const gert::Shape* expertIdsShape = context->GetInputShape(expertIdsIndex); |
| 27 | - OPS_CHECK_NULL_WITH_CONTEXT(context, expertIdsShape); | 28 | + OP_CHECK_IF(expertIdsShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "expert_ids"), |
| 29 | + return ge::GRAPH_FAILED); | ||
| 28 | gert::Shape* xShape = context->GetOutputShape(outputIndex); | 30 | gert::Shape* xShape = context->GetOutputShape(outputIndex); |
| 29 | - OPS_CHECK_NULL_WITH_CONTEXT(context, xShape); | 31 | + if (xShape == nullptr) { |
| 32 | + const std::string reason = | ||
| 33 | + "InferCombineOutputShape: output x shape holder is absent at index " + std::to_string(outputIndex); | ||
| 34 | + OP_LOGE(context->GetNodeName(), "%s", reason.c_str()); | ||
| 35 | + return ge::GRAPH_FAILED; | ||
| 36 | + } | ||
| 30 | 37 | ||
| 31 | int64_t bs = ((expertIdsShape->GetDimNum() == 1U) ? -1 : expertIdsShape->GetDim(0)); | 38 | int64_t bs = ((expertIdsShape->GetDimNum() == 1U) ? -1 : expertIdsShape->GetDim(0)); |
| 32 | int64_t h = ((expandXShape->GetDimNum() == 1U) ? -1 : expandXShape->GetDim(1)); | 39 | int64_t h = ((expandXShape->GetDimNum() == 1U) ? -1 : expandXShape->GetDim(1)); |
| @@ -18,12 +18,29 @@ | |||
| 18 | 18 | ||
| 19 | using namespace ge; | 19 | using namespace ge; |
| 20 | namespace ops { | 20 | namespace ops { |
| 21 | +namespace { | ||
| 22 | +void ReportInferTypeMetadata(const char* opName, const char* detail) | ||
| 23 | +{ | ||
| 24 | + const std::string reason = | ||
| 25 | + std::string(detail) + "; actual=null, expected=materialized inference metadata. Rebuild the inference context"; | ||
| 26 | + OP_LOGE(opName, "%s", reason.c_str()); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +void ReportMc2InferShapeFailure(const char* opName, const std::string& reason) | ||
| 30 | +{ | ||
| 31 | + const char* name = opName == nullptr ? "Mc2InferShape" : opName; | ||
| 32 | + OP_LOGE(name, "%s", reason.c_str()); | ||
| 33 | +} | ||
| 34 | +} // namespace | ||
| 35 | + | ||
| 21 | static ge::graphStatus CheckMatrixInputShapes(const gert::InferShapeContext* context, CommParas& commParas) | 36 | static ge::graphStatus CheckMatrixInputShapes(const gert::InferShapeContext* context, CommParas& commParas) |
| 22 | { | 37 | { |
| 23 | commParas.x1MatrixShape = context->GetInputShape(0); | 38 | commParas.x1MatrixShape = context->GetInputShape(0); |
| 24 | - OPS_CHECK_NULL_WITH_CONTEXT(context, commParas.x1MatrixShape); | 39 | + OP_CHECK_IF(commParas.x1MatrixShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "x1"), |
| 40 | + return ge::GRAPH_FAILED); | ||
| 25 | commParas.x2MatrixShape = context->GetInputShape(1); | 41 | commParas.x2MatrixShape = context->GetInputShape(1); |
| 26 | - OPS_CHECK_NULL_WITH_CONTEXT(context, commParas.x2MatrixShape); | 42 | + OP_CHECK_IF(commParas.x2MatrixShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "x2"), |
| 43 | + return ge::GRAPH_FAILED); | ||
| 27 | if (commParas.x1MatrixShape->GetDimNum() != SUPPORT_DIM_SIZE) { | 44 | if (commParas.x1MatrixShape->GetDimNum() != SUPPORT_DIM_SIZE) { |
| 28 | OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "x1", | 45 | OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "x1", |
| 29 | std::to_string(commParas.x1MatrixShape->GetDimNum()) + "D", "2D"); | 46 | std::to_string(commParas.x1MatrixShape->GetDimNum()) + "D", "2D"); |
| @@ -43,13 +60,23 @@ static ge::graphStatus ResolveRankSize(const gert::InferShapeContext* context, c | |||
| 43 | if (*rankSizeAttr <= 0) { | 60 | if (*rankSizeAttr <= 0) { |
| 44 | #if defined(ENABLE_BUILT_IN) | 61 | #if defined(ENABLE_BUILT_IN) |
| 45 | uint32_t rankNum = 0; | 62 | uint32_t rankNum = 0; |
| 46 | - if (Mc2Hcom::MC2HcomTopology::CommGetInstSizeByGroup(groupStr, &rankNum) != HCCL_SUCCESS || rankNum == 0) { | 63 | + if (Mc2Hcom::MC2HcomTopology::CommGetInstSizeByGroup(groupStr, &rankNum) != HCCL_SUCCESS) { |
| 47 | - OP_LOGE(context->GetNodeName(), "Get rank size failed, group [%s], rankSize [%u]", groupStr, rankNum); | 64 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "Get rank size failed, group [%s], rankSize [%u]", groupStr, |
| 65 | + rankNum); | ||
| 66 | + return ge::GRAPH_FAILED; | ||
| 67 | + } | ||
| 68 | + if (rankNum == 0) { | ||
| 69 | + ReportMc2InferShapeFailure( | ||
| 70 | + context->GetNodeName(), | ||
| 71 | + "Communication group " + std::string(groupStr) + | ||
| 72 | + " query succeeded with rank count=0; positive rank metadata is required for shape inference"); | ||
| 48 | return ge::GRAPH_FAILED; | 73 | return ge::GRAPH_FAILED; |
| 49 | } | 74 | } |
| 50 | rankSize = static_cast<int64_t>(rankNum); | 75 | rankSize = static_cast<int64_t>(rankNum); |
| 51 | #else | 76 | #else |
| 52 | - OP_LOGE(context->GetNodeName(), "Get rank size failed, rankSize [%lld]", *rankSizeAttr); | 77 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 78 | + context->GetNodeName(), "rank_size", std::to_string(*rankSizeAttr).c_str(), | ||
| 79 | + "rank_size must be positive when built-in communication-group lookup is unavailable"); | ||
| 53 | return ge::GRAPH_FAILED; | 80 | return ge::GRAPH_FAILED; |
| 54 | #endif | 81 | #endif |
| 55 | } else { | 82 | } else { |
| @@ -69,10 +96,13 @@ static void FillMatmulDims(CommParas& commParas, bool isTransA, bool isTransB) | |||
| 69 | static ge::graphStatus CheckKDimMatch(const gert::InferShapeContext* context, const CommParas& commParas) | 96 | static ge::graphStatus CheckKDimMatch(const gert::InferShapeContext* context, const CommParas& commParas) |
| 70 | { | 97 | { |
| 71 | if (commParas.dimKX1 != commParas.dimKX2) { | 98 | if (commParas.dimKX1 != commParas.dimKX2) { |
| 72 | - OP_LOGE_FOR_INVALID_VALUES_WITH_REASON( | 99 | + OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( |
| 73 | - context->GetNodeName(), "x1.k, x2.k", | 100 | + context->GetNodeName(), "x1, x2", |
| 74 | - std::to_string(commParas.dimKX1) + ", " + std::to_string(commParas.dimKX2), | 101 | + (Ops::Base::ToString(*commParas.x1MatrixShape) + ", " + Ops::Base::ToString(*commParas.x2MatrixShape)) |
| 75 | - "The values of x1.k and x2.k must be the same"); | 102 | + .c_str(), |
| 103 | + ("K dimensions must match after transposition, actual x1.K=" + std::to_string(commParas.dimKX1) + | ||
| 104 | + ", x2.K=" + std::to_string(commParas.dimKX2)) | ||
| 105 | + .c_str()); | ||
| 76 | return ge::GRAPH_FAILED; | 106 | return ge::GRAPH_FAILED; |
| 77 | } | 107 | } |
| 78 | return ge::GRAPH_SUCCESS; | 108 | return ge::GRAPH_SUCCESS; |
| @@ -86,14 +116,32 @@ ge::graphStatus CommonParamCheck(const gert::InferShapeContext* context, const s | |||
| 86 | return ge::GRAPH_FAILED; | 116 | return ge::GRAPH_FAILED; |
| 87 | } | 117 | } |
| 88 | auto attrs = context->GetAttrs(); | 118 | auto attrs = context->GetAttrs(); |
| 89 | - OPS_CHECK_NULL_WITH_CONTEXT(context, attrs); | 119 | + OP_CHECK_IF(attrs == nullptr, |
| 120 | + ReportMc2InferShapeFailure(context->GetNodeName(), "CommonParamCheck: attribute container is absent"), | ||
| 121 | + return ge::GRAPH_FAILED); | ||
| 90 | const bool* isTransA = attrs->GetAttrPointer<bool>(isTransAIndex); | 122 | const bool* isTransA = attrs->GetAttrPointer<bool>(isTransAIndex); |
| 91 | const bool* isTransB = attrs->GetAttrPointer<bool>(isTransBIndex); | 123 | const bool* isTransB = attrs->GetAttrPointer<bool>(isTransBIndex); |
| 92 | const int64_t* rankSizeAttr = attrs->GetAttrPointer<int64_t>(RANK_SIZE); | 124 | const int64_t* rankSizeAttr = attrs->GetAttrPointer<int64_t>(RANK_SIZE); |
| 125 | + OP_CHECK_IF(rankSizeAttr == nullptr, | ||
| 126 | + ReportMc2InferShapeFailure( | ||
| 127 | + context->GetNodeName(), | ||
| 128 | + "CommonParamCheck: RuntimeAttrs is missing the rank_size slot, including its registered default"), | ||
| 129 | + return ge::GRAPH_FAILED); | ||
| 130 | + | ||
| 131 | + OP_CHECK_IF(isTransA == nullptr, | ||
| 132 | + ReportMc2InferShapeFailure( | ||
| 133 | + context->GetNodeName(), | ||
| 134 | + "CommonParamCheck: RuntimeAttrs is missing the is_trans_a slot, including its registered default"), | ||
| 135 | + return ge::GRAPH_FAILED); | ||
| 136 | + OP_CHECK_IF(isTransB == nullptr, | ||
| 137 | + ReportMc2InferShapeFailure( | ||
| 138 | + context->GetNodeName(), | ||
| 139 | + "CommonParamCheck: RuntimeAttrs is missing the is_trans_b slot, including its registered default"), | ||
| 140 | + return ge::GRAPH_FAILED); | ||
| 93 | 141 | ||
| 94 | const char* groupStr = attrs->GetAttrPointer<char>(GROUP); | 142 | const char* groupStr = attrs->GetAttrPointer<char>(GROUP); |
| 95 | if (groupStr == nullptr) { | 143 | if (groupStr == nullptr) { |
| 96 | - OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "groupStr"); | 144 | + OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "group"); |
| 97 | return ge::GRAPH_FAILED; | 145 | return ge::GRAPH_FAILED; |
| 98 | } | 146 | } |
| 99 | if (ResolveRankSize(context, groupStr, rankSizeAttr, commParas.rankSize) != ge::GRAPH_SUCCESS) { | 147 | if (ResolveRankSize(context, groupStr, rankSizeAttr, commParas.rankSize) != ge::GRAPH_SUCCESS) { |
| @@ -111,19 +159,24 @@ ge::graphStatus CommonParamCheck(const gert::InferShapeContext* context, const s | |||
| 111 | 159 | ||
| 112 | ge::graphStatus AllGatherMatmulInferYShape(gert::InferShapeContext* context, CommParas& commParas) | 160 | ge::graphStatus AllGatherMatmulInferYShape(gert::InferShapeContext* context, CommParas& commParas) |
| 113 | { | 161 | { |
| 114 | - OP_LOGE_IF(CommonParamCheck(context, AG_IS_TRANS_A, AG_IS_TRANS_B, commParas) != GRAPH_SUCCESS, GRAPH_FAILED, | 162 | + OP_CHECK_IF(CommonParamCheck(context, AG_IS_TRANS_A, AG_IS_TRANS_B, commParas) != GRAPH_SUCCESS, |
| 115 | - context->GetNodeName(), "CommonParamCheck execute failed."); | 163 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "CommonParamCheck execute failed."), |
| 164 | + return GRAPH_FAILED); | ||
| 116 | if (commParas.dimM == -1) { | 165 | if (commParas.dimM == -1) { |
| 117 | commParas.rankSize = 1; | 166 | commParas.rankSize = 1; |
| 118 | } | 167 | } |
| 119 | // 不支持k = 0 | 168 | // 不支持k = 0 |
| 120 | if (commParas.dimKX1 == 0) { | 169 | if (commParas.dimKX1 == 0) { |
| 121 | commParas.dimM = commParas.dimN = 0; | 170 | commParas.dimM = commParas.dimN = 0; |
| 122 | - OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "dimK", "0", "non-zero value"); | 171 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context->GetNodeName(), "x1", |
| 172 | + Ops::Base::ToString(*commParas.x1MatrixShape).c_str(), | ||
| 173 | + "K dimension must be nonzero after applying is_trans_a"); | ||
| 123 | return ge::GRAPH_FAILED; | 174 | return ge::GRAPH_FAILED; |
| 124 | } | 175 | } |
| 125 | gert::Shape* yShape = context->GetOutputShape(0); | 176 | gert::Shape* yShape = context->GetOutputShape(0); |
| 126 | - OPS_CHECK_NULL_WITH_CONTEXT(context, yShape); | 177 | + OP_CHECK_IF(yShape == nullptr, |
| 178 | + ReportMc2InferShapeFailure(context->GetNodeName(), "output y shape holder is absent at index 0"), | ||
| 179 | + return ge::GRAPH_FAILED); | ||
| 127 | yShape->SetDimNum(SUPPORT_DIM_SIZE); | 180 | yShape->SetDimNum(SUPPORT_DIM_SIZE); |
| 128 | yShape->SetDim(0, commParas.dimM * commParas.rankSize); | 181 | yShape->SetDim(0, commParas.dimM * commParas.rankSize); |
| 129 | yShape->SetDim(1, commParas.dimN); | 182 | yShape->SetDim(1, commParas.dimN); |
| @@ -134,13 +187,21 @@ ge::graphStatus AllGatherMatmulInferGatherOutShape(gert::InferShapeContext* cont | |||
| 134 | const size_t gatherIndex) | 187 | const size_t gatherIndex) |
| 135 | { | 188 | { |
| 136 | if (context->GetAttrs() == nullptr) { | 189 | if (context->GetAttrs() == nullptr) { |
| 137 | - OP_LOGE(context->GetNodeName(), "get attrs failed."); | 190 | + ReportMc2InferShapeFailure(context->GetNodeName(), "InferGatherOutShape: attribute container is absent"); |
| 138 | return ge::GRAPH_FAILED; | 191 | return ge::GRAPH_FAILED; |
| 139 | } | 192 | } |
| 140 | const bool* isGatherOut = context->GetAttrs()->GetAttrPointer<bool>(gatherIndex); | 193 | const bool* isGatherOut = context->GetAttrs()->GetAttrPointer<bool>(gatherIndex); |
| 141 | - OPS_CHECK_NULL_WITH_CONTEXT(context, isGatherOut); | 194 | + OP_CHECK_IF( |
| 195 | + isGatherOut == nullptr, | ||
| 196 | + ReportMc2InferShapeFailure( | ||
| 197 | + context->GetNodeName(), | ||
| 198 | + "InferGatherOutShape: RuntimeAttrs is missing the is_gather_out slot, including its registered default"), | ||
| 199 | + return ge::GRAPH_FAILED); | ||
| 142 | gert::Shape* gatherOutShape = context->GetOutputShape(1); | 200 | gert::Shape* gatherOutShape = context->GetOutputShape(1); |
| 143 | - OPS_CHECK_NULL_WITH_CONTEXT(context, gatherOutShape); | 201 | + OP_CHECK_IF( |
| 202 | + gatherOutShape == nullptr, | ||
| 203 | + ReportMc2InferShapeFailure(context->GetNodeName(), "output gather_out shape holder is absent at index 1"), | ||
| 204 | + return ge::GRAPH_FAILED); | ||
| 144 | if (*isGatherOut) { | 205 | if (*isGatherOut) { |
| 145 | gatherOutShape->SetDimNum(SUPPORT_DIM_SIZE); | 206 | gatherOutShape->SetDimNum(SUPPORT_DIM_SIZE); |
| 146 | gatherOutShape->SetDim(0, commParas.dimM * commParas.rankSize); | 207 | gatherOutShape->SetDim(0, commParas.dimM * commParas.rankSize); |
| @@ -155,11 +216,14 @@ ge::graphStatus AllGatherMatmulInferGatherOutShape(gert::InferShapeContext* cont | |||
| 155 | ge::graphStatus AllGatherMatmulCommonInferShape(gert::InferShapeContext* context, const size_t gatherIndex) | 216 | ge::graphStatus AllGatherMatmulCommonInferShape(gert::InferShapeContext* context, const size_t gatherIndex) |
| 156 | { | 217 | { |
| 157 | CommParas commParas; | 218 | CommParas commParas; |
| 158 | - OP_LOGE_IF(AllGatherMatmulInferYShape(context, commParas) != GRAPH_SUCCESS, GRAPH_FAILED, context->GetNodeName(), | 219 | + OP_CHECK_IF(AllGatherMatmulInferYShape(context, commParas) != GRAPH_SUCCESS, |
| 159 | - "InferShapeAllGatherMatmul inferYshape execute failed."); | 220 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "InferShapeAllGatherMatmul inferYshape execute failed."), |
| 221 | + return GRAPH_FAILED); | ||
| 160 | 222 | ||
| 161 | - OP_LOGE_IF(AllGatherMatmulInferGatherOutShape(context, commParas, gatherIndex) != GRAPH_SUCCESS, GRAPH_FAILED, | 223 | + OP_CHECK_IF( |
| 162 | - context->GetNodeName(), "InferShapeAllGatherMatmul inferGatherOutShape execute failed."); | 224 | + AllGatherMatmulInferGatherOutShape(context, commParas, gatherIndex) != GRAPH_SUCCESS, |
| 225 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "InferShapeAllGatherMatmul inferGatherOutShape execute failed."), | ||
| 226 | + return GRAPH_FAILED); | ||
| 163 | 227 | ||
| 164 | return GRAPH_SUCCESS; | 228 | return GRAPH_SUCCESS; |
| 165 | } | 229 | } |
| @@ -167,18 +231,23 @@ ge::graphStatus AllGatherMatmulCommonInferShape(gert::InferShapeContext* context | |||
| 167 | ge::graphStatus InferMatmulReduceScatterCommon(gert::InferShapeContext* context) | 231 | ge::graphStatus InferMatmulReduceScatterCommon(gert::InferShapeContext* context) |
| 168 | { | 232 | { |
| 169 | CommParas commParas; | 233 | CommParas commParas; |
| 170 | - OP_LOGE_IF(CommonParamCheck(context, RS_IS_TRANS_A, RS_IS_TRANS_B, commParas) != GRAPH_SUCCESS, GRAPH_FAILED, | 234 | + OP_CHECK_IF(CommonParamCheck(context, RS_IS_TRANS_A, RS_IS_TRANS_B, commParas) != GRAPH_SUCCESS, |
| 171 | - context->GetNodeName(), "CommonParamCheck execute failed."); | 235 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "CommonParamCheck execute failed."), |
| 236 | + return GRAPH_FAILED); | ||
| 172 | if (commParas.dimM == -1) { | 237 | if (commParas.dimM == -1) { |
| 173 | commParas.rankSize = 1; | 238 | commParas.rankSize = 1; |
| 174 | } | 239 | } |
| 175 | if (commParas.dimKX1 == 0) { | 240 | if (commParas.dimKX1 == 0) { |
| 176 | commParas.dimM = commParas.dimN = 0; | 241 | commParas.dimM = commParas.dimN = 0; |
| 177 | - OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "dimK", "0", "non-zero value"); | 242 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context->GetNodeName(), "x1", |
| 243 | + Ops::Base::ToString(*commParas.x1MatrixShape).c_str(), | ||
| 244 | + "K dimension must be nonzero after applying is_trans_a"); | ||
| 178 | return ge::GRAPH_FAILED; | 245 | return ge::GRAPH_FAILED; |
| 179 | } | 246 | } |
| 180 | gert::Shape* yShape = context->GetOutputShape(0); | 247 | gert::Shape* yShape = context->GetOutputShape(0); |
| 181 | - OPS_CHECK_NULL_WITH_CONTEXT(context, yShape); | 248 | + OP_CHECK_IF(yShape == nullptr, |
| 249 | + ReportMc2InferShapeFailure(context->GetNodeName(), "output y shape holder is absent at index 0"), | ||
| 250 | + return ge::GRAPH_FAILED); | ||
| 182 | yShape->SetDimNum(SUPPORT_DIM_SIZE); | 251 | yShape->SetDimNum(SUPPORT_DIM_SIZE); |
| 183 | yShape->SetDim(0, commParas.dimM / commParas.rankSize); | 252 | yShape->SetDim(0, commParas.dimM / commParas.rankSize); |
| 184 | yShape->SetDim(1, commParas.dimN); | 253 | yShape->SetDim(1, commParas.dimN); |
| @@ -189,7 +258,10 @@ ge::graphStatus InferMatmulOutputDataType(gert::InferDataTypeContext* context, s | |||
| 189 | size_t yDtypeAttrIndex, size_t outputIndex) | 258 | size_t yDtypeAttrIndex, size_t outputIndex) |
| 190 | { | 259 | { |
| 191 | auto attrs = context->GetAttrs(); | 260 | auto attrs = context->GetAttrs(); |
| 192 | - OPS_CHECK_NULL_WITH_CONTEXT(context, attrs); | 261 | + OP_CHECK_IF(attrs == nullptr, |
| 262 | + ReportInferTypeMetadata(context->GetNodeName(), | ||
| 263 | + "InferMatmulOutputDataType: GetAttrs returned no RuntimeAttrs holder"), | ||
| 264 | + return ge::GRAPH_FAILED); | ||
| 193 | const auto inputDtype = context->GetInputDataType(inputIndex); | 265 | const auto inputDtype = context->GetInputDataType(inputIndex); |
| 194 | if ((inputDtype == ge::DataType::DT_FLOAT16) || (inputDtype == ge::DataType::DT_BF16)) { | 266 | if ((inputDtype == ge::DataType::DT_FLOAT16) || (inputDtype == ge::DataType::DT_BF16)) { |
| 195 | context->SetOutputDataType(outputIndex, inputDtype); | 267 | context->SetOutputDataType(outputIndex, inputDtype); |
| @@ -198,7 +270,9 @@ ge::graphStatus InferMatmulOutputDataType(gert::InferDataTypeContext* context, s | |||
| 198 | 270 | ||
| 199 | const int64_t* yDtype = attrs->GetInt(yDtypeAttrIndex); | 271 | const int64_t* yDtype = attrs->GetInt(yDtypeAttrIndex); |
| 200 | if (yDtype == nullptr || *yDtype == static_cast<int64_t>(ge::DataType::DT_UNDEFINED)) { | 272 | if (yDtype == nullptr || *yDtype == static_cast<int64_t>(ge::DataType::DT_UNDEFINED)) { |
| 201 | - OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "yDtype", "DT_UNDEFINED", "valid dtype value"); | 273 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 274 | + context->GetNodeName(), "y_dtype", yDtype == nullptr ? "null" : "DT_UNDEFINED", | ||
| 275 | + "Set y_dtype to a defined data type when the input is not FLOAT16 or BF16"); | ||
| 202 | return ge::GRAPH_FAILED; | 276 | return ge::GRAPH_FAILED; |
| 203 | } | 277 | } |
| 204 | context->SetOutputDataType(outputIndex, static_cast<ge::DataType>(*yDtype)); | 278 | context->SetOutputDataType(outputIndex, static_cast<ge::DataType>(*yDtype)); |
| @@ -31,11 +31,14 @@ inline uint64_t GetNumBlocks(const uint64_t aicNum, const uint64_t aivNum, const | |||
| 31 | "so the actual enabled AIC cores is %lu and AIV cores is %lu.", | 31 | "so the actual enabled AIC cores is %lu and AIV cores is %lu.", |
| 32 | aicNum, aivNum, ratio, pairedAicNum, numBlocks, numBlocks * ratio); | 32 | aicNum, aivNum, ratio, pairedAicNum, numBlocks, numBlocks * ratio); |
| 33 | } | 33 | } |
| 34 | - OP_TILING_CHECK((numBlocks == 0U), | 34 | + if (numBlocks == 0U) { |
| 35 | - OP_LOGE_FOR_INVALID_VALUE(debugDesc, "aicNum, aivNum", | 35 | + const char* opName = debugDesc == nullptr ? "Mc2Tiling" : debugDesc; |
| 36 | - (std::to_string(aicNum) + ", " + std::to_string(aivNum)).c_str(), | 36 | + const std::string reason = "GetNumBlocks: aic=" + std::to_string(aicNum) + ", aiv=" + std::to_string(aivNum) + |
| 37 | - "numBlocks=min(aicNum, aivNum/ratio) should not be 0"), | 37 | + ", ratio=" + std::to_string(ratio) + |
| 38 | - return ge::GRAPH_FAILED); | 38 | + "; no logical core can be formed from the platform core counts"; |
| 39 | + OP_LOGE(opName, "%s", reason.c_str()); | ||
| 40 | + return 0; | ||
| 41 | + } | ||
| 39 | return numBlocks; | 42 | return numBlocks; |
| 40 | } | 43 | } |
| 41 | } // namespace mc2tiling | 44 | } // namespace mc2tiling |
| @@ -17,6 +17,7 @@ | |||
| 17 | #define __MC2_TILING_UTILS_H__ | 17 | #define __MC2_TILING_UTILS_H__ |
| 18 | 18 | ||
| 19 | #include <cstdint> | 19 | #include <cstdint> |
| 20 | +#include <cstring> | ||
| 20 | #include <map> | 21 | #include <map> |
| 21 | #include <string> | 22 | #include <string> |
| 22 | 23 | ||
| @@ -380,12 +381,37 @@ inline ge::graphStatus SetHcclCcTilingConfig(const gert::TilingContext* context, | |||
| 380 | TilingDataT* tilingData) | 381 | TilingDataT* tilingData) |
| 381 | { | 382 | { |
| 382 | constexpr uint32_t MC2_CC_OP_TYPE_BATCH_WRITE = 18; // batch write | 383 | constexpr uint32_t MC2_CC_OP_TYPE_BATCH_WRITE = 18; // batch write |
| 384 | + constexpr size_t GROUP_BUFFER_BYTES = 128; | ||
| 385 | + const char* nodeName = context->GetNodeName(); | ||
| 386 | + const auto reportTilingFailure = [nodeName](const std::string& reason) { OP_LOGE(nodeName, "%s", reason.c_str()); }; | ||
| 383 | auto attrs = context->GetAttrs(); | 387 | auto attrs = context->GetAttrs(); |
| 388 | + if (attrs == nullptr || tilingData == nullptr) { | ||
| 389 | + reportTilingFailure(std::string("SetHcclCcTilingConfig: missing ") + | ||
| 390 | + (attrs == nullptr ? "RuntimeAttrs" : "tiling data") + "; rebuild the tiling context"); | ||
| 391 | + return ge::GRAPH_FAILED; | ||
| 392 | + } | ||
| 384 | auto group = attrs->GetAttrPointer<char>(static_cast<int>(attrGroupIndex)); | 393 | auto group = attrs->GetAttrPointer<char>(static_cast<int>(attrGroupIndex)); |
| 394 | + if (group == nullptr || std::strlen(group) >= GROUP_BUFFER_BYTES) { | ||
| 395 | + const std::string reason = group == nullptr ? | ||
| 396 | + "required group attribute is absent" : | ||
| 397 | + "group name length=" + std::to_string(std::strlen(group)) + | ||
| 398 | + "; expected fewer than " + std::to_string(GROUP_BUFFER_BYTES) + " bytes"; | ||
| 399 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(nodeName, "group", reason.c_str()); | ||
| 400 | + return ge::GRAPH_FAILED; | ||
| 401 | + } | ||
| 385 | const std::string algConfig = "MultiPut=level0:fullmesh"; | 402 | const std::string algConfig = "MultiPut=level0:fullmesh"; |
| 386 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, MC2_CC_OP_TYPE_BATCH_WRITE, algConfig); | 403 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, MC2_CC_OP_TYPE_BATCH_WRITE, algConfig); |
| 387 | - mc2CcTilingConfig.GetTiling(tilingData->mc2InitTiling); | 404 | + const auto initRet = mc2CcTilingConfig.GetTiling(tilingData->mc2InitTiling); |
| 388 | - mc2CcTilingConfig.GetTiling(tilingData->mc2CcTiling); | 405 | + if (initRet != 0) { |
| 406 | + OP_LOGE(nodeName, "MC2 tiling initialization failed: GetTiling(init) returned %u", initRet); | ||
| 407 | + return ge::GRAPH_FAILED; | ||
| 408 | + } | ||
| 409 | + const auto commRet = mc2CcTilingConfig.GetTiling(tilingData->mc2CcTiling); | ||
| 410 | + if (commRet != 0) { | ||
| 411 | + OP_LOGE_WITHOUT_REPORT( | ||
| 412 | + nodeName, "Mc2CcTiling invariant failed after initialization and group length validation; rc=%u", commRet); | ||
| 413 | + return ge::GRAPH_FAILED; | ||
| 414 | + } | ||
| 389 | return ge::GRAPH_SUCCESS; | 415 | return ge::GRAPH_SUCCESS; |
| 390 | } | 416 | } |
| 391 | 417 | ||
| @@ -22,8 +22,13 @@ ge::graphStatus MoeTilingBase::GetPlatformInfo() | |||
| 22 | { | 22 | { |
| 23 | auto platformInfo = context_->GetPlatformInfo(); | 23 | auto platformInfo = context_->GetPlatformInfo(); |
| 24 | const char* nodeName = context_->GetNodeName(); | 24 | const char* nodeName = context_->GetNodeName(); |
| 25 | - OP_TILING_CHECK(nodeName == nullptr, OP_LOGE(nodeName, "Fail to get nodeName."), return ge::GRAPH_FAILED); | 25 | + if (nodeName == nullptr || platformInfo == nullptr) { |
| 26 | - OP_TILING_CHECK(platformInfo == nullptr, OP_LOGE(nodeName, "fail to get platform info"), return ge::GRAPH_FAILED); | 26 | + const char* name = nodeName == nullptr ? "MoeTilingBase" : nodeName; |
| 27 | + const char* reason = nodeName == nullptr ? "MoeTilingBase::GetPlatformInfo: node-name metadata is absent" : | ||
| 28 | + "MoeTilingBase::GetPlatformInfo: platform information is absent"; | ||
| 29 | + OP_LOGE(name, "%s", reason); | ||
| 30 | + return ge::GRAPH_FAILED; | ||
| 31 | + } | ||
| 27 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); | 32 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); |
| 28 | npuArch_ = ascendcPlatform.GetCurNpuArch(); | 33 | npuArch_ = ascendcPlatform.GetCurNpuArch(); |
| 29 | return ge::GRAPH_SUCCESS; | 34 | return ge::GRAPH_SUCCESS; |
| @@ -56,27 +61,30 @@ ge::graphStatus MoeTilingBase::CheckSharedExpertAttrValue(const char* nodeName, | |||
| 56 | if (sharedExpertRankNum == 0) { | 61 | if (sharedExpertRankNum == 0) { |
| 57 | return ge::GRAPH_SUCCESS; | 62 | return ge::GRAPH_SUCCESS; |
| 58 | } | 63 | } |
| 59 | - OP_TILING_CHECK((sharedExpertNum == 0), | 64 | + OP_TILING_CHECK( |
| 60 | - OP_LOGE_FOR_INVALID_VALUE(nodeName, "sharedExpertNum", | 65 | + (sharedExpertNum == 0), |
| 61 | - (std::string("sharedExpertNum=") + std::to_string(sharedExpertNum) + | 66 | + OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(nodeName, "shared_expert_num, shared_expert_rank_num", |
| 62 | - ", sharedExpertRankNum=" + std::to_string(sharedExpertRankNum)) | 67 | + (std::string("sharedExpertNum=") + std::to_string(sharedExpertNum) + |
| 63 | - .c_str(), | 68 | + ", sharedExpertRankNum=" + std::to_string(sharedExpertRankNum)) |
| 64 | - "sharedExpertNum != 0"), | 69 | + .c_str(), |
| 65 | - return ge::GRAPH_FAILED); | 70 | + "sharedExpertNum != 0"), |
| 66 | - OP_TILING_CHECK((sharedExpertNum > sharedExpertRankNum), | 71 | + return ge::GRAPH_FAILED); |
| 67 | - OP_LOGE_FOR_INVALID_VALUE(nodeName, "sharedExpertNum", | 72 | + OP_TILING_CHECK( |
| 68 | - (std::string("sharedExpertNum=") + std::to_string(sharedExpertNum) + | 73 | + (sharedExpertNum > sharedExpertRankNum), |
| 69 | - ", sharedExpertRankNum=" + std::to_string(sharedExpertRankNum)) | 74 | + OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(nodeName, "shared_expert_num, shared_expert_rank_num", |
| 70 | - .c_str(), | 75 | + (std::string("sharedExpertNum=") + std::to_string(sharedExpertNum) + |
| 71 | - "sharedExpertNum <= sharedExpertRankNum"), | 76 | + ", sharedExpertRankNum=" + std::to_string(sharedExpertRankNum)) |
| 72 | - return ge::GRAPH_FAILED); | 77 | + .c_str(), |
| 73 | - OP_TILING_CHECK((sharedExpertRankNum % sharedExpertNum != 0), | 78 | + "sharedExpertNum <= sharedExpertRankNum"), |
| 74 | - OP_LOGE_FOR_INVALID_VALUE(nodeName, "sharedExpertRankNum", | 79 | + return ge::GRAPH_FAILED); |
| 75 | - (std::string("sharedExpertNum=") + std::to_string(sharedExpertNum) + | 80 | + OP_TILING_CHECK( |
| 76 | - ", sharedExpertRankNum=" + std::to_string(sharedExpertRankNum)) | 81 | + (sharedExpertRankNum % sharedExpertNum != 0), |
| 77 | - .c_str(), | 82 | + OP_LOGE_FOR_INVALID_VALUES_WITH_REASON(nodeName, "shared_expert_num, shared_expert_rank_num", |
| 78 | - "sharedExpertRankNum % sharedExpertNum == 0"), | 83 | + (std::string("sharedExpertNum=") + std::to_string(sharedExpertNum) + |
| 79 | - return ge::GRAPH_FAILED); | 84 | + ", sharedExpertRankNum=" + std::to_string(sharedExpertRankNum)) |
| 85 | + .c_str(), | ||
| 86 | + "sharedExpertRankNum % sharedExpertNum == 0"), | ||
| 87 | + return ge::GRAPH_FAILED); | ||
| 80 | return ge::GRAPH_SUCCESS; | 88 | return ge::GRAPH_SUCCESS; |
| 81 | } | 89 | } |
| 82 | } // namespace optiling | 90 | } // namespace optiling |
| @@ -0,0 +1,33 @@ | |||
| 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 | +#ifndef MC2_API_POINTER_ERROR_ASSERTIONS_H | ||
| 12 | +#define MC2_API_POINTER_ERROR_ASSERTIONS_H | ||
| 13 | + | ||
| 14 | +#include "formal_error_assertions.h" | ||
| 15 | +#include "opdev/op_errno.h" | ||
| 16 | + | ||
| 17 | +namespace Mc2ErrorCodeUT { | ||
| 18 | +inline void ExpectRequiredApiPointerError(const char* functionName, const char* parameterName) | ||
| 19 | +{ | ||
| 20 | + const auto reports = ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 21 | + ASSERT_EQ(reports.size(), 1U); | ||
| 22 | + ASSERT_EQ(reports[0].error_id, "EZ1011"); | ||
| 23 | + ASSERT_EQ(reports[0].args_map.count("functionName"), 1U); | ||
| 24 | + ASSERT_EQ(reports[0].args_map.count("paraName"), 1U); | ||
| 25 | + EXPECT_EQ(reports[0].args_map.at("functionName"), functionName); | ||
| 26 | + EXPECT_EQ(reports[0].args_map.at("paraName"), parameterName); | ||
| 27 | + ASSERT_EQ(ErrorManager::GetInstance().SetRawErrorMessages(reports), 0); | ||
| 28 | + const auto message = ErrorManager::GetInstance().GetErrorMessage(); | ||
| 29 | + EXPECT_NE(message.find(functionName), std::string::npos); | ||
| 30 | + EXPECT_NE(message.find(parameterName), std::string::npos); | ||
| 31 | +} | ||
| 32 | +} // namespace Mc2ErrorCodeUT | ||
| 33 | +#endif | ||
| @@ -0,0 +1,114 @@ | |||
| 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 | +#ifndef MC2_UT_FORMAL_ERROR_ASSERTIONS_H | ||
| 12 | +#define MC2_UT_FORMAL_ERROR_ASSERTIONS_H | ||
| 13 | +#include <gtest/gtest.h> | ||
| 14 | +#include <map> | ||
| 15 | +#include <sstream> | ||
| 16 | +#include <string> | ||
| 17 | +#include "experiment/metadef/common/util/error_manager/error_manager.h" | ||
| 18 | +namespace Mc2ErrorCodeUT { | ||
| 19 | +class ExcelErrorReportScope { | ||
| 20 | +public: | ||
| 21 | + ExcelErrorReportScope() | ||
| 22 | + { | ||
| 23 | + (void)ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 24 | + } | ||
| 25 | + ~ExcelErrorReportScope() | ||
| 26 | + { | ||
| 27 | + (void)ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 28 | + } | ||
| 29 | +}; | ||
| 30 | +inline void ExpectExcelFormalError(const char* code, const char* parameter, const char* actual, | ||
| 31 | + const char* expectedReason = nullptr, const char* correctFormat = nullptr, | ||
| 32 | + const std::map<std::string, std::string>& expectedFields = {}) | ||
| 33 | +{ | ||
| 34 | + const auto reports = ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 35 | + std::ostringstream detail; | ||
| 36 | + for (const auto& report : reports) { | ||
| 37 | + detail << report.error_id << " "; | ||
| 38 | + for (const auto& field : report.args_map) { | ||
| 39 | + detail << field.first << "=" << field.second << "; "; | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + SCOPED_TRACE(detail.str()); | ||
| 43 | + ASSERT_EQ(reports.size(), 1U); | ||
| 44 | + ASSERT_EQ(reports[0].error_id, code); | ||
| 45 | + ASSERT_EQ(ErrorManager::GetInstance().SetRawErrorMessages(reports), 0); | ||
| 46 | + const auto formatted = ErrorManager::GetInstance().GetErrorMessage(); | ||
| 47 | + EXPECT_NE(formatted.find(code), std::string::npos) << formatted; | ||
| 48 | + | ||
| 49 | + const auto& fields = reports[0].args_map; | ||
| 50 | + ASSERT_EQ(fields.count("op_name"), 1U); | ||
| 51 | + EXPECT_FALSE(fields.at("op_name").empty()); | ||
| 52 | + for (const auto& expected : expectedFields) { | ||
| 53 | + ASSERT_EQ(fields.count(expected.first), 1U); | ||
| 54 | + EXPECT_EQ(fields.at(expected.first), expected.second); | ||
| 55 | + } | ||
| 56 | + if (std::string(code) == "EZ0004") { | ||
| 57 | + ASSERT_EQ(fields.count("param_name"), 1U); | ||
| 58 | + EXPECT_EQ(fields.at("param_name"), parameter); | ||
| 59 | + return; | ||
| 60 | + } | ||
| 61 | + if (std::string(code) == "EZ0017") { | ||
| 62 | + ASSERT_EQ(fields.count("param_name"), 1U); | ||
| 63 | + ASSERT_EQ(fields.count("incorrect_format"), 1U); | ||
| 64 | + ASSERT_EQ(fields.count("correct_format"), 1U); | ||
| 65 | + EXPECT_EQ(fields.at("param_name"), parameter); | ||
| 66 | + EXPECT_EQ(fields.at("incorrect_format"), actual); | ||
| 67 | + EXPECT_FALSE(fields.at("correct_format").empty()); | ||
| 68 | + if (correctFormat != nullptr) { | ||
| 69 | + EXPECT_EQ(fields.at("correct_format"), correctFormat); | ||
| 70 | + } | ||
| 71 | + return; | ||
| 72 | + } | ||
| 73 | + if (std::string(code) == "EZ0019") { | ||
| 74 | + ASSERT_EQ(fields.count("param_name"), 1U); | ||
| 75 | + ASSERT_EQ(fields.count("incorrect_dtype"), 1U); | ||
| 76 | + ASSERT_EQ(fields.count("correct_dtype"), 1U); | ||
| 77 | + EXPECT_EQ(fields.at("param_name"), parameter); | ||
| 78 | + EXPECT_EQ(fields.at("incorrect_dtype"), actual); | ||
| 79 | + EXPECT_FALSE(fields.at("correct_dtype").empty()); | ||
| 80 | + EXPECT_NE(formatted.find(fields.at("incorrect_dtype")), std::string::npos) << formatted; | ||
| 81 | + EXPECT_NE(formatted.find(fields.at("correct_dtype")), std::string::npos) << formatted; | ||
| 82 | + return; | ||
| 83 | + } | ||
| 84 | + if (std::string(code) != "EZ0024" && std::string(code) != "EZ0011") { | ||
| 85 | + ASSERT_EQ(fields.count("reason"), 1U); | ||
| 86 | + EXPECT_FALSE(fields.at("reason").empty()); | ||
| 87 | + } | ||
| 88 | + if (expectedReason != nullptr) { | ||
| 89 | + ASSERT_EQ(fields.count("reason"), 1U); | ||
| 90 | + EXPECT_EQ(fields.at("reason"), expectedReason); | ||
| 91 | + } | ||
| 92 | + const bool relation = std::string(code) == "EZ0027"; | ||
| 93 | + const char* nameKey = relation ? "param_names" : "param_name"; | ||
| 94 | + const char* valueKey = relation ? "incorrect_values" : | ||
| 95 | + ((std::string(code) == "EZ0011" || std::string(code) == "EZ0012") ? | ||
| 96 | + "incorrect_dim" : | ||
| 97 | + (std::string(code) == "EZ0035" ? "incorrect_format" : "incorrect_value")); | ||
| 98 | + ASSERT_EQ(fields.count(nameKey), 1U); | ||
| 99 | + ASSERT_EQ(fields.count(valueKey), 1U); | ||
| 100 | + EXPECT_EQ(fields.at(nameKey), parameter); | ||
| 101 | + EXPECT_EQ(fields.at(valueKey), actual); | ||
| 102 | + EXPECT_NE(formatted.find(fields.at(nameKey)), std::string::npos) << formatted; | ||
| 103 | + EXPECT_NE(formatted.find(fields.at(valueKey)), std::string::npos) << formatted; | ||
| 104 | + if (std::string(code) == "EZ0011") { | ||
| 105 | + ASSERT_EQ(fields.count("correct_dim"), 1U); | ||
| 106 | + EXPECT_FALSE(fields.at("correct_dim").empty()); | ||
| 107 | + } | ||
| 108 | + if (std::string(code) == "EZ0024") { | ||
| 109 | + ASSERT_EQ(fields.count("correct_value"), 1U); | ||
| 110 | + EXPECT_FALSE(fields.at("correct_value").empty()); | ||
| 111 | + } | ||
| 112 | +} | ||
| 113 | +} // namespace Mc2ErrorCodeUT | ||
| 114 | +#endif | ||
| @@ -0,0 +1,33 @@ | |||
| 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 | +#ifndef MC2_INTERNAL_FALLBACK_ASSERTIONS_H | ||
| 12 | +#define MC2_INTERNAL_FALLBACK_ASSERTIONS_H | ||
| 13 | +#include <string> | ||
| 14 | +#include <gtest/gtest.h> | ||
| 15 | +#include "experiment/metadef/common/util/error_manager/error_manager.h" | ||
| 16 | +namespace Mc2ErrorCodeUT { | ||
| 17 | +// This checks the scope-constrained internal fallback, not formal-code closure. | ||
| 18 | +inline void ExpectInternalFallbackReport(const std::string& reason) | ||
| 19 | +{ | ||
| 20 | + auto& manager = ErrorManager::GetInstance(); | ||
| 21 | + const auto errors = manager.GetRawErrorMessages(); | ||
| 22 | + ASSERT_EQ(errors.size(), 1U); | ||
| 23 | + EXPECT_EQ(errors[0].error_id, "EZ9999"); | ||
| 24 | + const auto metadata = errors[0].error_message.find("[FUNC:"); | ||
| 25 | + ASSERT_NE(metadata, std::string::npos); | ||
| 26 | + EXPECT_EQ(errors[0].error_message.substr(0, metadata), reason); | ||
| 27 | + ASSERT_EQ(manager.SetRawErrorMessages(errors), 0); | ||
| 28 | + const auto formatted = manager.GetErrorMessage(); | ||
| 29 | + EXPECT_NE(formatted.find("EZ9999"), std::string::npos); | ||
| 30 | + EXPECT_NE(formatted.find(reason), std::string::npos); | ||
| 31 | +} | ||
| 32 | +} // namespace Mc2ErrorCodeUT | ||
| 33 | +#endif | ||
| @@ -101,10 +101,10 @@ inline aclrtGetArgsFromExceptionInfo_t GetAclrtGetArgsFromExceptionInfoFunc() | |||
| 101 | if (handle != nullptr) { | 101 | if (handle != nullptr) { |
| 102 | func = (aclrtGetArgsFromExceptionInfo_t)dlsym(handle, "aclrtGetArgsFromExceptionInfo"); | 102 | func = (aclrtGetArgsFromExceptionInfo_t)dlsym(handle, "aclrtGetArgsFromExceptionInfo"); |
| 103 | if (func == nullptr) { | 103 | if (func == nullptr) { |
| 104 | - OP_LOGE(OP_NAME, "dlsym aclrtGetArgsFromExceptionInfo failed: %s", dlerror()); | 104 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "dlsym aclrtGetArgsFromExceptionInfo failed: %s", dlerror()); |
| 105 | } | 105 | } |
| 106 | } else { | 106 | } else { |
| 107 | - OP_LOGE(OP_NAME, "dlopen failed: %s", dlerror()); | 107 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "dlopen failed: %s", dlerror()); |
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | return func; | 110 | return func; |
| @@ -122,12 +122,12 @@ inline acldumpGetPath_t GetAcldumpGetPathFunc() | |||
| 122 | if (handle != nullptr) { | 122 | if (handle != nullptr) { |
| 123 | func = (acldumpGetPath_t)dlsym(handle, "acldumpGetPath"); | 123 | func = (acldumpGetPath_t)dlsym(handle, "acldumpGetPath"); |
| 124 | if (func == nullptr) { | 124 | if (func == nullptr) { |
| 125 | - OP_LOGE(OP_NAME, "dlsym acldumpGetPath failed: %s", dlerror()); | 125 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "dlsym acldumpGetPath failed: %s", dlerror()); |
| 126 | } else { | 126 | } else { |
| 127 | OP_LOGD(OP_NAME, "Successfully loaded acldumpGetPath function"); | 127 | OP_LOGD(OP_NAME, "Successfully loaded acldumpGetPath function"); |
| 128 | } | 128 | } |
| 129 | } else { | 129 | } else { |
| 130 | - OP_LOGE(OP_NAME, "dlopen libascend_dump.so failed: %s", dlerror()); | 130 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "dlopen libascend_dump.so failed: %s", dlerror()); |
| 131 | } | 131 | } |
| 132 | } | 132 | } |
| 133 | return func; | 133 | return func; |
| @@ -170,19 +170,19 @@ inline int DumpToFile(std::string dir, std::string name, uint32_t id, void* buf, | |||
| 170 | { | 170 | { |
| 171 | // check if dir and buf valid | 171 | // check if dir and buf valid |
| 172 | if (IsStrEmpty(dir) || IsStrEmpty(name)) { | 172 | if (IsStrEmpty(dir) || IsStrEmpty(name)) { |
| 173 | - OP_LOGE_WITH_INVALID_INPUT(OP_NAME, "dir or name"); | 173 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Dump directory and filename must be nonempty"); |
| 174 | return -1; | 174 | return -1; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | std::string rankPath = dir + "/" + std::to_string(id) + "/"; | 177 | std::string rankPath = dir + "/" + std::to_string(id) + "/"; |
| 178 | std::string path = rankPath + name; | 178 | std::string path = rankPath + name; |
| 179 | - OP_LOGE(OP_NAME, "Start to dump file. The dump path is %s", path.c_str()); | 179 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Start to dump file. The dump path is %s", path.c_str()); |
| 180 | 180 | ||
| 181 | // Open file | 181 | // Open file |
| 182 | int fd = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, FILE_MODE); | 182 | int fd = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, FILE_MODE); |
| 183 | if (fd < 0) { | 183 | if (fd < 0) { |
| 184 | int openErrno = errno; | 184 | int openErrno = errno; |
| 185 | - OP_LOGE(OP_NAME, "Failed to open a dump file. errno=%d(%s)", openErrno, strerror(openErrno)); | 185 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to open a dump file. errno=%d(%s)", openErrno, strerror(openErrno)); |
| 186 | return -1; | 186 | return -1; |
| 187 | } | 187 | } |
| 188 | 188 | ||
| @@ -190,14 +190,14 @@ inline int DumpToFile(std::string dir, std::string name, uint32_t id, void* buf, | |||
| 190 | ssize_t ret = write(fd, buf, bufSize); | 190 | ssize_t ret = write(fd, buf, bufSize); |
| 191 | if (ret < 0) { | 191 | if (ret < 0) { |
| 192 | int writeErrno = errno; | 192 | int writeErrno = errno; |
| 193 | - OP_LOGE(OP_NAME, "Failed to write a dump file. errno=%d(%s)", writeErrno, strerror(writeErrno)); | 193 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to write a dump file. errno=%d(%s)", writeErrno, strerror(writeErrno)); |
| 194 | close(fd); | 194 | close(fd); |
| 195 | return -1; | 195 | return -1; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | // Close file | 198 | // Close file |
| 199 | close(fd); | 199 | close(fd); |
| 200 | - OP_LOGE(OP_NAME, "Dump to file %s done.", path.c_str()); | 200 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Dump to file %s done.", path.c_str()); |
| 201 | return 0; | 201 | return 0; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| @@ -329,26 +329,26 @@ inline int ProcessArgsForA3(uint64_t argsAddr, std::vector<uint8_t>& winBuf) | |||
| 329 | auto ret = aclrtMemcpy(hcclArgs.data(), sizeof(CommContextForDump), (void*)argsAddr, sizeof(CommContextForDump), | 329 | auto ret = aclrtMemcpy(hcclArgs.data(), sizeof(CommContextForDump), (void*)argsAddr, sizeof(CommContextForDump), |
| 330 | ACL_MEMCPY_DEVICE_TO_HOST); | 330 | ACL_MEMCPY_DEVICE_TO_HOST); |
| 331 | if (ret != ACL_SUCCESS) { | 331 | if (ret != ACL_SUCCESS) { |
| 332 | - OP_LOGE(OP_NAME, "aclrtMemcpy CommContextForDump from device to host failed. ret = %d", ret); | 332 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy CommContextForDump from device to host failed. ret = %d", ret); |
| 333 | return -1; | 333 | return -1; |
| 334 | } | 334 | } |
| 335 | CommContextForDump* winContext = reinterpret_cast<CommContextForDump*>(hcclArgs.data()); | 335 | CommContextForDump* winContext = reinterpret_cast<CommContextForDump*>(hcclArgs.data()); |
| 336 | if (winContext == nullptr) { | 336 | if (winContext == nullptr) { |
| 337 | - OP_LOGE_WITH_INVALID_INPUT(OP_NAME, "winContext"); | 337 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Dump communication context is null"); |
| 338 | return -1; | 338 | return -1; |
| 339 | } | 339 | } |
| 340 | OP_LOGD(OP_NAME, "Get winContext from args. rankId=%u", winContext->epRankId); | 340 | OP_LOGD(OP_NAME, "Get winContext from args. rankId=%u", winContext->epRankId); |
| 341 | 341 | ||
| 342 | void* winAddr = reinterpret_cast<void*>(winContext->epHcclBufffer_[winContext->epRankId]); | 342 | void* winAddr = reinterpret_cast<void*>(winContext->epHcclBufffer_[winContext->epRankId]); |
| 343 | if (winAddr == nullptr) { | 343 | if (winAddr == nullptr) { |
| 344 | - OP_LOGE(OP_NAME, "Get win addr failed."); | 344 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Get win addr failed."); |
| 345 | return -1; | 345 | return -1; |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | // Get windowsIn of each rank from hccl context | 348 | // Get windowsIn of each rank from hccl context |
| 349 | ret = aclrtMemcpy(winBuf.data(), WIN_SIZE, winAddr, WIN_SIZE, ACL_MEMCPY_DEVICE_TO_HOST); | 349 | ret = aclrtMemcpy(winBuf.data(), WIN_SIZE, winAddr, WIN_SIZE, ACL_MEMCPY_DEVICE_TO_HOST); |
| 350 | if (ret != ACL_SUCCESS) { | 350 | if (ret != ACL_SUCCESS) { |
| 351 | - OP_LOGE(OP_NAME, "aclrtMemcpy win from device to host failed. ret = %d", ret); | 351 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy win from device to host failed. ret = %d", ret); |
| 352 | return -1; | 352 | return -1; |
| 353 | } | 353 | } |
| 354 | return 0; | 354 | return 0; |
| @@ -358,21 +358,21 @@ inline int ProcessArgsForA2(const char* groupName, std::vector<uint8_t>& winBuf) | |||
| 358 | { | 358 | { |
| 359 | if (groupName == nullptr || strnlen(groupName, MAX_GROUP_NAME_LENGTH) == 0 || | 359 | if (groupName == nullptr || strnlen(groupName, MAX_GROUP_NAME_LENGTH) == 0 || |
| 360 | strnlen(groupName, MAX_GROUP_NAME_LENGTH) == MAX_GROUP_NAME_LENGTH) { | 360 | strnlen(groupName, MAX_GROUP_NAME_LENGTH) == MAX_GROUP_NAME_LENGTH) { |
| 361 | - OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(OP_NAME, "groupName", groupName, | 361 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Dump groupName %.128s must be nonempty and shorter than %zu bytes", |
| 362 | - "The value of groupName must be within the supported range."); | 362 | + groupName == nullptr ? "(null)" : groupName, MAX_GROUP_NAME_LENGTH); |
| 363 | return -1; | 363 | return -1; |
| 364 | } | 364 | } |
| 365 | uint64_t size; | 365 | uint64_t size; |
| 366 | void* winAddr = nullptr; | 366 | void* winAddr = nullptr; |
| 367 | Mc2Hcom::MC2HcomTopology::CommGetHcclBufferByGroup(groupName, &winAddr, &size); | 367 | Mc2Hcom::MC2HcomTopology::CommGetHcclBufferByGroup(groupName, &winAddr, &size); |
| 368 | if (winAddr == nullptr) { | 368 | if (winAddr == nullptr) { |
| 369 | - OP_LOGE(OP_NAME, "Get win addr failed."); | 369 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Get win addr failed."); |
| 370 | return -1; | 370 | return -1; |
| 371 | } | 371 | } |
| 372 | - OP_LOGE(OP_NAME, "HCCL BUFFER SIZE=%luMB. WindowInAddr=%p.", size / (1 * 1024 * 1024) / 2, winAddr); | 372 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "HCCL BUFFER SIZE=%luMB. WindowInAddr=%p.", size / (1 * 1024 * 1024) / 2, winAddr); |
| 373 | auto ret = aclrtMemcpy(winBuf.data(), WIN_SIZE, winAddr, WIN_SIZE, ACL_MEMCPY_DEVICE_TO_HOST); | 373 | auto ret = aclrtMemcpy(winBuf.data(), WIN_SIZE, winAddr, WIN_SIZE, ACL_MEMCPY_DEVICE_TO_HOST); |
| 374 | if (ret != ACL_SUCCESS) { | 374 | if (ret != ACL_SUCCESS) { |
| 375 | - OP_LOGE(OP_NAME, "aclrtMemcpy win from device to host failed. ret = %d", ret); | 375 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy win from device to host failed. ret = %d", ret); |
| 376 | return -1; | 376 | return -1; |
| 377 | } | 377 | } |
| 378 | return 0; | 378 | return 0; |
| @@ -401,7 +401,7 @@ inline void* GetPeermemBase(const char* socName, uint64_t argsAddr) | |||
| 401 | std::vector<uint8_t> hcclArgs(sizeof(CommContextForDump), 0); | 401 | std::vector<uint8_t> hcclArgs(sizeof(CommContextForDump), 0); |
| 402 | if (aclrtMemcpy(hcclArgs.data(), sizeof(CommContextForDump), reinterpret_cast<void*>(argsAddr), | 402 | if (aclrtMemcpy(hcclArgs.data(), sizeof(CommContextForDump), reinterpret_cast<void*>(argsAddr), |
| 403 | sizeof(CommContextForDump), ACL_MEMCPY_DEVICE_TO_HOST) != ACL_SUCCESS) { | 403 | sizeof(CommContextForDump), ACL_MEMCPY_DEVICE_TO_HOST) != ACL_SUCCESS) { |
| 404 | - OP_LOGE(OP_NAME, "GetPeermemBase: aclrtMemcpy CommContextForDump failed"); | 404 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "GetPeermemBase: aclrtMemcpy CommContextForDump failed"); |
| 405 | return nullptr; | 405 | return nullptr; |
| 406 | } | 406 | } |
| 407 | CommContextForDump* ctx = reinterpret_cast<CommContextForDump*>(hcclArgs.data()); | 407 | CommContextForDump* ctx = reinterpret_cast<CommContextForDump*>(hcclArgs.data()); |
| @@ -420,32 +420,32 @@ inline int ParseStructuredDump(uint64_t argsAddr, std::vector<uint8_t>& winBuf) | |||
| 420 | aclError ret = aclrtMemcpy(&hdr, sizeof(MC2ExceptionDump::Header), reinterpret_cast<void*>(argsAddr), | 420 | aclError ret = aclrtMemcpy(&hdr, sizeof(MC2ExceptionDump::Header), reinterpret_cast<void*>(argsAddr), |
| 421 | sizeof(MC2ExceptionDump::Header), ACL_MEMCPY_DEVICE_TO_HOST); | 421 | sizeof(MC2ExceptionDump::Header), ACL_MEMCPY_DEVICE_TO_HOST); |
| 422 | if (ret != ACL_SUCCESS) { | 422 | if (ret != ACL_SUCCESS) { |
| 423 | - OP_LOGE(OP_NAME, "aclrtMemcpy Header failed. ret=%d", ret); | 423 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy Header failed. ret=%d", ret); |
| 424 | return -1; | 424 | return -1; |
| 425 | } | 425 | } |
| 426 | OP_LOGD(OP_NAME, "Phase1: headerMagic=0x%x opType=%d stageNum=%d tilingDataSize=%u numBlocks=%u dumpCount=%lu", | 426 | OP_LOGD(OP_NAME, "Phase1: headerMagic=0x%x opType=%d stageNum=%d tilingDataSize=%u numBlocks=%u dumpCount=%lu", |
| 427 | hdr.headerMagic, hdr.opType, hdr.stageNum, hdr.tilingDataSize, hdr.numBlocks, hdr.dumpCount); | 427 | hdr.headerMagic, hdr.opType, hdr.stageNum, hdr.tilingDataSize, hdr.numBlocks, hdr.dumpCount); |
| 428 | if (hdr.headerMagic != MC2ExceptionDump::HEADER_MAGIC) { | 428 | if (hdr.headerMagic != MC2ExceptionDump::HEADER_MAGIC) { |
| 429 | - OP_LOGE(OP_NAME, "headerMagic mismatch: 0x%x != 0x%x, ExceptionDump not enabled", hdr.headerMagic, | 429 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "headerMagic mismatch: 0x%x != 0x%x, ExceptionDump not enabled", |
| 430 | - MC2ExceptionDump::HEADER_MAGIC); | 430 | + hdr.headerMagic, MC2ExceptionDump::HEADER_MAGIC); |
| 431 | return -1; | 431 | return -1; |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | uint64_t dumpCount = hdr.dumpCount; | 434 | uint64_t dumpCount = hdr.dumpCount; |
| 435 | if (dumpCount > MC2ExceptionDump::MAX_DUMP_ENTRIES) { | 435 | if (dumpCount > MC2ExceptionDump::MAX_DUMP_ENTRIES) { |
| 436 | - OP_LOGE(OP_NAME, "dumpCount=%lu > MAX_DUMP_ENTRIES=%d, truncating", dumpCount, | 436 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "dumpCount=%lu > MAX_DUMP_ENTRIES=%d, truncating", dumpCount, |
| 437 | - MC2ExceptionDump::MAX_DUMP_ENTRIES); | 437 | + MC2ExceptionDump::MAX_DUMP_ENTRIES); |
| 438 | dumpCount = MC2ExceptionDump::MAX_DUMP_ENTRIES; | 438 | dumpCount = MC2ExceptionDump::MAX_DUMP_ENTRIES; |
| 439 | } | 439 | } |
| 440 | uint32_t tilingDataSize = hdr.tilingDataSize; | 440 | uint32_t tilingDataSize = hdr.tilingDataSize; |
| 441 | if (tilingDataSize > MC2ExceptionDump::MAX_DUMP_TILING_SIZE) { | 441 | if (tilingDataSize > MC2ExceptionDump::MAX_DUMP_TILING_SIZE) { |
| 442 | - OP_LOGE(OP_NAME, "tilingDataSize=%u > MAX=%zu, truncating", tilingDataSize, | 442 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "tilingDataSize=%u > MAX=%zu, truncating", tilingDataSize, |
| 443 | - MC2ExceptionDump::MAX_DUMP_TILING_SIZE); | 443 | + MC2ExceptionDump::MAX_DUMP_TILING_SIZE); |
| 444 | tilingDataSize = MC2ExceptionDump::MAX_DUMP_TILING_SIZE; | 444 | tilingDataSize = MC2ExceptionDump::MAX_DUMP_TILING_SIZE; |
| 445 | } | 445 | } |
| 446 | uint32_t numBlocks = hdr.numBlocks; | 446 | uint32_t numBlocks = hdr.numBlocks; |
| 447 | if (numBlocks == 0) { | 447 | if (numBlocks == 0) { |
| 448 | - OP_LOGE(OP_NAME, "numBlocks=0, Header not initialized"); | 448 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "numBlocks=0, Header not initialized"); |
| 449 | return -1; | 449 | return -1; |
| 450 | } | 450 | } |
| 451 | 451 | ||
| @@ -469,7 +469,7 @@ inline int ParseStructuredDump(uint64_t argsAddr, std::vector<uint8_t>& winBuf) | |||
| 469 | ret = aclrtMemcpy(dumpParamsBuf.data(), dumpParamsSize, reinterpret_cast<void*>(dumpParamsOffset), dumpParamsSize, | 469 | ret = aclrtMemcpy(dumpParamsBuf.data(), dumpParamsSize, reinterpret_cast<void*>(dumpParamsOffset), dumpParamsSize, |
| 470 | ACL_MEMCPY_DEVICE_TO_HOST); | 470 | ACL_MEMCPY_DEVICE_TO_HOST); |
| 471 | if (ret != ACL_SUCCESS) { | 471 | if (ret != ACL_SUCCESS) { |
| 472 | - OP_LOGE(OP_NAME, "aclrtMemcpy DumpParams failed. ret=%d", ret); | 472 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy DumpParams failed. ret=%d", ret); |
| 473 | return -1; | 473 | return -1; |
| 474 | } | 474 | } |
| 475 | 475 | ||
| @@ -506,7 +506,7 @@ inline int ParseStructuredDump(uint64_t argsAddr, std::vector<uint8_t>& winBuf) | |||
| 506 | ret = aclrtMemcpy(winBuf.data() + offset, tilingDataSize, reinterpret_cast<void*>(tilingOffset), tilingDataSize, | 506 | ret = aclrtMemcpy(winBuf.data() + offset, tilingDataSize, reinterpret_cast<void*>(tilingOffset), tilingDataSize, |
| 507 | ACL_MEMCPY_DEVICE_TO_HOST); | 507 | ACL_MEMCPY_DEVICE_TO_HOST); |
| 508 | if (ret != ACL_SUCCESS) { | 508 | if (ret != ACL_SUCCESS) { |
| 509 | - OP_LOGE(OP_NAME, "aclrtMemcpy Tiling failed. ret=%d", ret); | 509 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy Tiling failed. ret=%d", ret); |
| 510 | } | 510 | } |
| 511 | } | 511 | } |
| 512 | offset += tilingDataSize; | 512 | offset += tilingDataSize; |
| @@ -518,7 +518,7 @@ inline int ParseStructuredDump(uint64_t argsAddr, std::vector<uint8_t>& winBuf) | |||
| 518 | ret = aclrtMemcpy(winBuf.data() + offset, blockStageTotalSize, reinterpret_cast<void*>(blockStageOffset), | 518 | ret = aclrtMemcpy(winBuf.data() + offset, blockStageTotalSize, reinterpret_cast<void*>(blockStageOffset), |
| 519 | blockStageTotalSize, ACL_MEMCPY_DEVICE_TO_HOST); | 519 | blockStageTotalSize, ACL_MEMCPY_DEVICE_TO_HOST); |
| 520 | if (ret != ACL_SUCCESS) { | 520 | if (ret != ACL_SUCCESS) { |
| 521 | - OP_LOGE(OP_NAME, "aclrtMemcpy BlockStage failed. ret=%d", ret); | 521 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy BlockStage failed. ret=%d", ret); |
| 522 | } | 522 | } |
| 523 | } | 523 | } |
| 524 | offset += blockStageTotalSize; | 524 | offset += blockStageTotalSize; |
| @@ -541,15 +541,15 @@ inline int ParseStructuredDump(uint64_t argsAddr, std::vector<uint8_t>& winBuf) | |||
| 541 | void* srcAddr = reinterpret_cast<void*>(dp->dumpAddr + b * dp->srcStride); | 541 | void* srcAddr = reinterpret_cast<void*>(dp->dumpAddr + b * dp->srcStride); |
| 542 | ret = aclrtMemcpy(winBuf.data() + offset, dp->blockLen, srcAddr, dp->blockLen, ACL_MEMCPY_DEVICE_TO_HOST); | 542 | ret = aclrtMemcpy(winBuf.data() + offset, dp->blockLen, srcAddr, dp->blockLen, ACL_MEMCPY_DEVICE_TO_HOST); |
| 543 | if (ret != ACL_SUCCESS) { | 543 | if (ret != ACL_SUCCESS) { |
| 544 | - OP_LOGE(OP_NAME, "aclrtMemcpy dump entry %lu block %zu failed. ret=%d", i, b, ret); | 544 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy dump entry %lu block %zu failed. ret=%d", i, b, ret); |
| 545 | break; | 545 | break; |
| 546 | } | 546 | } |
| 547 | offset += dp->blockLen; | 547 | offset += dp->blockLen; |
| 548 | } | 548 | } |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | - OP_LOGE(OP_NAME, "Structured dump completed: totalSize=%zu dumpCount=%lu winBufSize=%zu", totalSize, dumpCount, | 551 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Structured dump completed: totalSize=%zu dumpCount=%lu winBufSize=%zu", totalSize, |
| 552 | - winBuf.size()); | 552 | + dumpCount, winBuf.size()); |
| 553 | return 0; | 553 | return 0; |
| 554 | } | 554 | } |
| 555 | 555 | ||
| @@ -558,7 +558,7 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 558 | const char* socName = aclrtGetSocName(); | 558 | const char* socName = aclrtGetSocName(); |
| 559 | if ((std::strstr(socName, "Ascend960") == nullptr) && (std::strstr(socName, "Ascend950") == nullptr) && | 559 | if ((std::strstr(socName, "Ascend960") == nullptr) && (std::strstr(socName, "Ascend950") == nullptr) && |
| 560 | (std::strstr(socName, "Ascend910_93") == nullptr) && (std::strstr(socName, "Ascend910B") == nullptr)) { | 560 | (std::strstr(socName, "Ascend910_93") == nullptr) && (std::strstr(socName, "Ascend910B") == nullptr)) { |
| 561 | - OP_LOGE(OP_NAME, "The soc version is %s, skip dump process", socName); | 561 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "The soc version is %s, skip dump process", socName); |
| 562 | return; | 562 | return; |
| 563 | } | 563 | } |
| 564 | 564 | ||
| @@ -570,19 +570,19 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 570 | 570 | ||
| 571 | auto aclrtGetArgsFromExceptionInfoFunc = GetAclrtGetArgsFromExceptionInfoFunc(); | 571 | auto aclrtGetArgsFromExceptionInfoFunc = GetAclrtGetArgsFromExceptionInfoFunc(); |
| 572 | if (aclrtGetArgsFromExceptionInfoFunc == nullptr) { | 572 | if (aclrtGetArgsFromExceptionInfoFunc == nullptr) { |
| 573 | - OP_LOGE(OP_NAME, "Failed to load aclrtGetArgsFromExceptionInfo function."); | 573 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to load aclrtGetArgsFromExceptionInfo function."); |
| 574 | return; | 574 | return; |
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | auto ret = aclrtGetArgsFromExceptionInfoFunc(args, &devArgsPtr, &devArgsLen); | 577 | auto ret = aclrtGetArgsFromExceptionInfoFunc(args, &devArgsPtr, &devArgsLen); |
| 578 | if (ret != ACL_SUCCESS) { | 578 | if (ret != ACL_SUCCESS) { |
| 579 | - OP_LOGE(OP_NAME, "aclrtGetArgsFromExceptionInfo failed. ret=%d", ret); | 579 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtGetArgsFromExceptionInfo failed. ret=%d", ret); |
| 580 | return; | 580 | return; |
| 581 | } | 581 | } |
| 582 | 582 | ||
| 583 | uint32_t deviceId = aclrtGetDeviceIdFromExceptionInfo(args); | 583 | uint32_t deviceId = aclrtGetDeviceIdFromExceptionInfo(args); |
| 584 | if (ret != ACL_SUCCESS) { | 584 | if (ret != ACL_SUCCESS) { |
| 585 | - OP_LOGE(OP_NAME, "aclrtGetDeviceIdFromExceptionInfo failed. ret=%d", ret); | 585 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtGetDeviceIdFromExceptionInfo failed. ret=%d", ret); |
| 586 | return; | 586 | return; |
| 587 | } | 587 | } |
| 588 | OP_LOGD(OP_NAME, "Get context from args. deviceId=%u, devArgsAddr=%p, devArgsLen=%u", deviceId, devArgsPtr, | 588 | OP_LOGD(OP_NAME, "Get context from args. deviceId=%u, devArgsAddr=%p, devArgsLen=%u", deviceId, devArgsPtr, |
| @@ -601,7 +601,7 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 601 | ret = | 601 | ret = |
| 602 | aclrtMemcpy(&argsAddr, sizeof(uint64_t), devArgsPtr + argsOffset, sizeof(uint64_t), ACL_MEMCPY_DEVICE_TO_HOST); | 602 | aclrtMemcpy(&argsAddr, sizeof(uint64_t), devArgsPtr + argsOffset, sizeof(uint64_t), ACL_MEMCPY_DEVICE_TO_HOST); |
| 603 | if (ret != ACL_SUCCESS) { | 603 | if (ret != ACL_SUCCESS) { |
| 604 | - OP_LOGE(OP_NAME, "aclrtMemcpy address of args failed. ret=%d", ret); | 604 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "aclrtMemcpy address of args failed. ret=%d", ret); |
| 605 | return; | 605 | return; |
| 606 | } | 606 | } |
| 607 | OP_LOGD(OP_NAME, "argsAddr=0x%lx (argsOffset=%lu)", argsAddr, argsOffset); | 607 | OP_LOGD(OP_NAME, "argsAddr=0x%lx (argsOffset=%lu)", argsAddr, argsOffset); |
| @@ -616,11 +616,11 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 616 | OP_LOGD(OP_NAME, "MegaMoe structured dump: getting peermem base"); | 616 | OP_LOGD(OP_NAME, "MegaMoe structured dump: getting peermem base"); |
| 617 | void* peermemBase = GetPeermemBase(socName, argsAddr); | 617 | void* peermemBase = GetPeermemBase(socName, argsAddr); |
| 618 | if (peermemBase == nullptr) { | 618 | if (peermemBase == nullptr) { |
| 619 | - OP_LOGE(OP_NAME, "Failed to get peermem base."); | 619 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to get peermem base."); |
| 620 | return; | 620 | return; |
| 621 | } | 621 | } |
| 622 | if (ParseStructuredDump(reinterpret_cast<uint64_t>(peermemBase), winContent) != 0) { | 622 | if (ParseStructuredDump(reinterpret_cast<uint64_t>(peermemBase), winContent) != 0) { |
| 623 | - OP_LOGE(OP_NAME, "Failed to parse structured dump."); | 623 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to parse structured dump."); |
| 624 | return; | 624 | return; |
| 625 | } | 625 | } |
| 626 | } else { | 626 | } else { |
| @@ -629,7 +629,7 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 629 | winContent.resize(WIN_SIZE, 0); | 629 | winContent.resize(WIN_SIZE, 0); |
| 630 | if (std::strstr(socName, "Ascend910_93") != nullptr) { | 630 | if (std::strstr(socName, "Ascend910_93") != nullptr) { |
| 631 | if (ProcessArgsForA3(argsAddr, winContent) != 0) { | 631 | if (ProcessArgsForA3(argsAddr, winContent) != 0) { |
| 632 | - OP_LOGE(OP_NAME, "Failed to get win content."); | 632 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to get win content."); |
| 633 | return; | 633 | return; |
| 634 | } | 634 | } |
| 635 | } else if ((std::strstr(socName, "Ascend960") != nullptr) || (std::strstr(socName, "Ascend950") != nullptr)) { | 635 | } else if ((std::strstr(socName, "Ascend960") != nullptr) || (std::strstr(socName, "Ascend950") != nullptr)) { |
| @@ -640,7 +640,7 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 640 | } else if (std::strstr(socName, "Ascend910B") != nullptr) { | 640 | } else if (std::strstr(socName, "Ascend910B") != nullptr) { |
| 641 | const char* groupName = MC2GroupNameManager::GetInstance().GetGroupName(); | 641 | const char* groupName = MC2GroupNameManager::GetInstance().GetGroupName(); |
| 642 | if (ProcessArgsForA2(groupName, winContent) != 0) { | 642 | if (ProcessArgsForA2(groupName, winContent) != 0) { |
| 643 | - OP_LOGE(OP_NAME, "Failed to get win content."); | 643 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to get win content."); |
| 644 | return; | 644 | return; |
| 645 | } | 645 | } |
| 646 | } | 646 | } |
| @@ -649,14 +649,14 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 649 | // 获取acldumpGetPath函数指针 | 649 | // 获取acldumpGetPath函数指针 |
| 650 | auto acldumpGetPathFunc = GetAcldumpGetPathFunc(); | 650 | auto acldumpGetPathFunc = GetAcldumpGetPathFunc(); |
| 651 | if (acldumpGetPathFunc == nullptr) { | 651 | if (acldumpGetPathFunc == nullptr) { |
| 652 | - OP_LOGE(OP_NAME, "Failed to load acldumpGetPath function, skip dump"); | 652 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to load acldumpGetPath function, skip dump"); |
| 653 | return; | 653 | return; |
| 654 | } | 654 | } |
| 655 | 655 | ||
| 656 | // 获取dump路径 | 656 | // 获取dump路径 |
| 657 | const char* dumpPath = acldumpGetPathFunc(acldumpType::AIC_ERR_BRIEF_DUMP); | 657 | const char* dumpPath = acldumpGetPathFunc(acldumpType::AIC_ERR_BRIEF_DUMP); |
| 658 | if (dumpPath == nullptr) { | 658 | if (dumpPath == nullptr) { |
| 659 | - OP_LOGE(OP_NAME, "acldumpGetPath returned NULL"); | 659 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "acldumpGetPath returned NULL"); |
| 660 | return; | 660 | return; |
| 661 | } | 661 | } |
| 662 | OP_LOGD(OP_NAME, "dumpPath=%s, winContent.size()=%zu", dumpPath, winContent.size()); | 662 | OP_LOGD(OP_NAME, "dumpPath=%s, winContent.size()=%zu", dumpPath, winContent.size()); |
| @@ -666,7 +666,7 @@ inline void Mc2ExceptionImpl(aclrtExceptionInfo* args, void* userdata, const cha | |||
| 666 | OP_LOGD(OP_NAME, "Writing dump file: deviceId=%u fileName=%s bufSize=%zu", deviceId, fileName.c_str(), | 666 | OP_LOGD(OP_NAME, "Writing dump file: deviceId=%u fileName=%s bufSize=%zu", deviceId, fileName.c_str(), |
| 667 | winContent.size()); | 667 | winContent.size()); |
| 668 | if (DumpToFile(std::string(dumpPath), fileName, deviceId, winContent.data(), winContent.size()) != 0) { | 668 | if (DumpToFile(std::string(dumpPath), fileName, deviceId, winContent.data(), winContent.size()) != 0) { |
| 669 | - OP_LOGE(OP_NAME, "Failed to dump win content."); | 669 | + OP_LOGE_WITHOUT_REPORT(OP_NAME, "Failed to dump win content."); |
| 670 | } | 670 | } |
| 671 | } | 671 | } |
| 672 | 672 | ||
| @@ -0,0 +1,42 @@ | |||
| 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 MC2_HCCL_TILING_REPORT_H | ||
| 11 | +#define MC2_HCCL_TILING_REPORT_H | ||
| 12 | +#include <cstdlib> | ||
| 13 | +#include "graph/types.h" | ||
| 14 | +#include "mc2_tiling_failure_report.h" | ||
| 15 | +namespace Mc2Error { | ||
| 16 | +// Caller validates the group length and all communication configuration fields. | ||
| 17 | +template <typename Config, typename Init, typename Cc> | ||
| 18 | +ge::graphStatus GetValidatedHcclTiling(Config& config, Init& init, Cc& cc, const char* opName) | ||
| 19 | +{ | ||
| 20 | + const char* ascendHome = std::getenv("ASCEND_HOME_PATH"); | ||
| 21 | + if (ascendHome == nullptr || ascendHome[0] == '\0') { | ||
| 22 | + // Formal environment-code registration is unavailable in this host target. | ||
| 23 | + OP_LOGE(opName, "%s: required environment variable ASCEND_HOME_PATH is absent or empty", opName); | ||
| 24 | + return ge::GRAPH_FAILED; | ||
| 25 | + } | ||
| 26 | + const auto initRet = config.GetTiling(init); | ||
| 27 | + if (initRet != 0) { | ||
| 28 | + ReportTilingFailure( | ||
| 29 | + opName, "Mc2CcTilingConfig::GetTiling(init) failed to load the required rtGetSocVersion entry; rc=" + | ||
| 30 | + std::to_string(initRet) + ", library=" + ascendHome + | ||
| 31 | + "/lib64/libruntime.so; check the CANN runtime installation"); | ||
| 32 | + return ge::GRAPH_FAILED; | ||
| 33 | + } | ||
| 34 | + const auto ccRet = config.GetTiling(cc); | ||
| 35 | + if (ccRet != 0) { | ||
| 36 | + OP_LOGE_WITHOUT_REPORT(opName, "Validated communication tiling configuration failed, rc=%u", ccRet); | ||
| 37 | + return ge::GRAPH_FAILED; | ||
| 38 | + } | ||
| 39 | + return ge::GRAPH_SUCCESS; | ||
| 40 | +} | ||
| 41 | +} // namespace Mc2Error | ||
| 42 | +#endif | ||
| @@ -0,0 +1,27 @@ | |||
| 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 MC2_INFER_FAILURE_REPORT_H | ||
| 11 | +#define MC2_INFER_FAILURE_REPORT_H | ||
| 12 | +#include <string> | ||
| 13 | +#include <vector> | ||
| 14 | +#include "mc2_log.h" | ||
| 15 | +namespace Mc2Error { | ||
| 16 | +inline void ReportInferFailure(const char* opName, const std::string& reason) | ||
| 17 | +{ | ||
| 18 | + const char* name = opName == nullptr ? "Mc2InferShape" : opName; | ||
| 19 | + OP_LOGE(name, "%s", reason.c_str()); | ||
| 20 | +} | ||
| 21 | +inline void ReportDataTypeMetadataFailure(const char* opName, const std::string& reason) | ||
| 22 | +{ | ||
| 23 | + const char* name = opName == nullptr ? "Mc2InferDataType" : opName; | ||
| 24 | + OP_LOGE(name, "%s", reason.c_str()); | ||
| 25 | +} | ||
| 26 | +} // namespace Mc2Error | ||
| 27 | +#endif | ||
| @@ -0,0 +1,22 @@ | |||
| 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 MC2_TILING_FAILURE_REPORT_H | ||
| 11 | +#define MC2_TILING_FAILURE_REPORT_H | ||
| 12 | +#include <string> | ||
| 13 | +#include <vector> | ||
| 14 | +#include "mc2_log.h" | ||
| 15 | +namespace Mc2Error { | ||
| 16 | +inline void ReportTilingFailure(const char* opName, const std::string& reason) | ||
| 17 | +{ | ||
| 18 | + const char* name = opName == nullptr ? "Mc2Tiling" : opName; | ||
| 19 | + OP_LOGE(name, "%s", reason.c_str()); | ||
| 20 | +} | ||
| 21 | +} // namespace Mc2Error | ||
| 22 | +#endif | ||
| @@ -13,6 +13,7 @@ | |||
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | #include "mc2_log.h" | 15 | #include "mc2_log.h" |
| 16 | +#include "mc2_infer_failure_report.h" | ||
| 16 | #include "platform/platform_info.h" | 17 | #include "platform/platform_info.h" |
| 17 | #include "register/op_impl_registry.h" | 18 | #include "register/op_impl_registry.h" |
| 18 | using namespace ge; | 19 | using namespace ge; |
| @@ -25,12 +26,21 @@ static constexpr size_t BARRIER_OUTPUT_X_REF_INDEX = 0; | |||
| 25 | 26 | ||
| 26 | static ge::graphStatus InferShapeDistributeBarrier(gert::InferShapeContext* context) | 27 | static ge::graphStatus InferShapeDistributeBarrier(gert::InferShapeContext* context) |
| 27 | { | 28 | { |
| 29 | + OP_CHECK_IF(context == nullptr, | ||
| 30 | + Mc2Error::ReportInferFailure("DistributeBarrier", | ||
| 31 | + "InferShape entry: context actual=null; expected materialized context"), | ||
| 32 | + return ge::GRAPH_FAILED); | ||
| 28 | OPS_LOG_D(context->GetNodeName(), "Begin to do InferShapeDistributeBarrier."); | 33 | OPS_LOG_D(context->GetNodeName(), "Begin to do InferShapeDistributeBarrier."); |
| 29 | // 获取输入shape | 34 | // 获取输入shape |
| 30 | const gert::Shape* xRefInputShape = context->GetInputShape(BARRIER_INPUT_X_REF_INDEX); | 35 | const gert::Shape* xRefInputShape = context->GetInputShape(BARRIER_INPUT_X_REF_INDEX); |
| 31 | - OPS_CHECK_NULL_WITH_CONTEXT(context, xRefInputShape); | 36 | + OP_CHECK_IF(xRefInputShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "x_ref"), |
| 37 | + return ge::GRAPH_FAILED); | ||
| 32 | gert::Shape* xRefOutputShape = context->GetOutputShape(BARRIER_OUTPUT_X_REF_INDEX); | 38 | gert::Shape* xRefOutputShape = context->GetOutputShape(BARRIER_OUTPUT_X_REF_INDEX); |
| 33 | - OPS_CHECK_NULL_WITH_CONTEXT(context, xRefOutputShape); | 39 | + OP_CHECK_IF( |
| 40 | + xRefOutputShape == nullptr, | ||
| 41 | + Mc2Error::ReportInferFailure(context->GetNodeName(), | ||
| 42 | + "Output x_ref shape holder actual=null; expected materialized output holder"), | ||
| 43 | + return ge::GRAPH_FAILED); | ||
| 34 | 44 | ||
| 35 | // 这里要获取输入的dim,然后循环给输出赋值 | 45 | // 这里要获取输入的dim,然后循环给输出赋值 |
| 36 | 46 | ||
| @@ -43,6 +53,10 @@ static ge::graphStatus InferShapeDistributeBarrier(gert::InferShapeContext* cont | |||
| 43 | 53 | ||
| 44 | static ge::graphStatus InferDataTypeDistributeBarrier(gert::InferDataTypeContext* context) | 54 | static ge::graphStatus InferDataTypeDistributeBarrier(gert::InferDataTypeContext* context) |
| 45 | { | 55 | { |
| 56 | + OP_CHECK_IF(context == nullptr, | ||
| 57 | + Mc2Error::ReportDataTypeMetadataFailure( | ||
| 58 | + "DistributeBarrier", "InferDataType entry: context actual=null; expected materialized context"), | ||
| 59 | + return ge::GRAPH_FAILED); | ||
| 46 | OPS_LOG_D(context->GetNodeName(), "Begin to do InferDataTypeDistributeBarrier."); | 60 | OPS_LOG_D(context->GetNodeName(), "Begin to do InferDataTypeDistributeBarrier."); |
| 47 | auto xRefDtype = context->GetInputDataType(BARRIER_INPUT_X_REF_INDEX); | 61 | auto xRefDtype = context->GetInputDataType(BARRIER_INPUT_X_REF_INDEX); |
| 48 | context->SetOutputDataType(BARRIER_OUTPUT_X_REF_INDEX, xRefDtype); | 62 | context->SetOutputDataType(BARRIER_OUTPUT_X_REF_INDEX, xRefDtype); |
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "../../op_kernel/distribute_barrier_tiling.h" | 29 | #include "../../op_kernel/distribute_barrier_tiling.h" |
| 30 | // #include "graph/utils/op_desc_utils.h" // 依赖 ge | 30 | // #include "graph/utils/op_desc_utils.h" // 依赖 ge |
| 31 | #include "graph/utils/type_utils.h" | 31 | #include "graph/utils/type_utils.h" |
| 32 | +#include "mc2/common/utils/mc2_hccl_tiling_report.h" | ||
| 32 | #include "mc2_hcom_topo_info.h" | 33 | #include "mc2_hcom_topo_info.h" |
| 33 | #include "mc2_log.h" | 34 | #include "mc2_log.h" |
| 34 | #include "register/op_def_registry.h" | 35 | #include "register/op_def_registry.h" |
| @@ -60,7 +61,10 @@ static bool CheckTimeOut(const gert::TilingContext* context, const DistributeBar | |||
| 60 | (std::to_string(timeOutStorageShape->GetStorageShape().GetDimNum()) + "D").c_str(), "1D"), | 61 | (std::to_string(timeOutStorageShape->GetStorageShape().GetDimNum()) + "D").c_str(), "1D"), |
| 61 | return false); | 62 | return false); |
| 62 | auto timeOutDesc = context->GetOptionalInputDesc(config.timeOutIndex); | 63 | auto timeOutDesc = context->GetOptionalInputDesc(config.timeOutIndex); |
| 63 | - OP_TILING_CHECK(timeOutDesc == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "timeOutDesc"), return false); | 64 | + OP_TILING_CHECK( |
| 65 | + timeOutDesc == nullptr, | ||
| 66 | + Mc2Error::ReportTilingFailure(nodeName, "timeOutDesc descriptor is absent while its input shape is present"), | ||
| 67 | + return false); | ||
| 64 | OP_TILING_CHECK(timeOutDesc->GetDataType() != ge::DT_INT32, | 68 | OP_TILING_CHECK(timeOutDesc->GetDataType() != ge::DT_INT32, |
| 65 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "timeOut", | 69 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "timeOut", |
| 66 | Ops::Base::ToString(timeOutDesc->GetDataType()).c_str(), "INT32"), | 70 | Ops::Base::ToString(timeOutDesc->GetDataType()).c_str(), "INT32"), |
| @@ -90,7 +94,10 @@ static bool CheckElasticInfo(const gert::TilingContext* context, const uint32_t | |||
| 90 | (std::to_string(elasticInfoStorageShape->GetStorageShape().GetDimNum()) + "D").c_str(), "1D"), | 94 | (std::to_string(elasticInfoStorageShape->GetStorageShape().GetDimNum()) + "D").c_str(), "1D"), |
| 91 | return false); | 95 | return false); |
| 92 | auto elasticInfoDesc = context->GetOptionalInputDesc(config.elasticInfoIndex); | 96 | auto elasticInfoDesc = context->GetOptionalInputDesc(config.elasticInfoIndex); |
| 93 | - OP_TILING_CHECK(elasticInfoDesc == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "elasticInfoDesc"), return false); | 97 | + OP_TILING_CHECK(elasticInfoDesc == nullptr, |
| 98 | + Mc2Error::ReportTilingFailure( | ||
| 99 | + nodeName, "elasticInfoDesc descriptor is absent while its input shape is present"), | ||
| 100 | + return false); | ||
| 94 | OP_TILING_CHECK(elasticInfoDesc->GetDataType() != ge::DT_INT32, | 101 | OP_TILING_CHECK(elasticInfoDesc->GetDataType() != ge::DT_INT32, |
| 95 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "elasticInfo", | 102 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "elasticInfo", |
| 96 | Ops::Base::ToString(elasticInfoDesc->GetDataType()).c_str(), "INT32"), | 103 | Ops::Base::ToString(elasticInfoDesc->GetDataType()).c_str(), "INT32"), |
| @@ -117,7 +124,9 @@ static bool CheckAndSetAttrs(const gert::TilingContext* context, DistributeBarri | |||
| 117 | const DistributeBarrierConfig& config) | 124 | const DistributeBarrierConfig& config) |
| 118 | { | 125 | { |
| 119 | auto attrs = context->GetAttrs(); | 126 | auto attrs = context->GetAttrs(); |
| 120 | - OP_TILING_CHECK(attrs == nullptr, OPS_LOG_E(A_INNER_DEBUG_BARRIER, "GetAttrs returned nullptr!"), return false); | 127 | + OP_TILING_CHECK(attrs == nullptr, |
| 128 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "RuntimeAttrs holder is absent"), | ||
| 129 | + return false); | ||
| 121 | NpuArch npuArch = mc2tiling::GetNpuArch(context); | 130 | NpuArch npuArch = mc2tiling::GetNpuArch(context); |
| 122 | int64_t MAX_WORLD_SIZE = 0; | 131 | int64_t MAX_WORLD_SIZE = 0; |
| 123 | if (npuArch == Ops::Base::DAV_3510 || npuArch == Ops::Base::DAV_9201 || npuArch == Ops::Base::DAV_9202) { | 132 | if (npuArch == Ops::Base::DAV_3510 || npuArch == Ops::Base::DAV_9201 || npuArch == Ops::Base::DAV_9202) { |
| @@ -130,28 +139,39 @@ static bool CheckAndSetAttrs(const gert::TilingContext* context, DistributeBarri | |||
| 130 | auto worldSizePtr = attrs->GetAttrPointer<int64_t>(config.attrWorldSizeIndex); | 139 | auto worldSizePtr = attrs->GetAttrPointer<int64_t>(config.attrWorldSizeIndex); |
| 131 | 140 | ||
| 132 | // 当前仅对必选属性进行校空 | 141 | // 当前仅对必选属性进行校空 |
| 133 | - OP_TILING_CHECK(groupPtr == nullptr, OPS_LOG_E(A_INNER_DEBUG_BARRIER, "groupPtr is null!"), return false); | 142 | + OP_TILING_CHECK( |
| 134 | - OP_TILING_CHECK(worldSizePtr == nullptr, OPS_LOG_E(A_INNER_DEBUG_BARRIER, "worldSizePtr is null!"), return false); | 143 | + groupPtr == nullptr, |
| 144 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "group", "Required attribute is absent"), | ||
| 145 | + return false); | ||
| 146 | + OP_TILING_CHECK( | ||
| 147 | + worldSizePtr == nullptr, | ||
| 148 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "world_size", "Required attribute is absent"), | ||
| 149 | + return false); | ||
| 135 | 150 | ||
| 136 | - OP_TILING_CHECK((*worldSizePtr < MIN_WORLD_SIZE) || (*worldSizePtr > MAX_WORLD_SIZE), | 151 | + OP_TILING_CHECK( |
| 137 | - OPS_LOG_E(A_INNER_DEBUG_BARRIER, | 152 | + (*worldSizePtr < MIN_WORLD_SIZE) || (*worldSizePtr > MAX_WORLD_SIZE), |
| 138 | - "WorldSize is invalid, only support [%ld, %ld], " | 153 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 139 | - "but got worldSize=%ld.", | 154 | + context->GetNodeName(), "world_size", std::to_string(*worldSizePtr).c_str(), |
| 140 | - MIN_WORLD_SIZE, MAX_WORLD_SIZE, *worldSizePtr), | 155 | + ("Expected [" + std::to_string(MIN_WORLD_SIZE) + ", " + std::to_string(MAX_WORLD_SIZE) + "]").c_str()), |
| 141 | - return false); | 156 | + return false); |
| 142 | 157 | ||
| 143 | uint32_t worldSize = static_cast<uint32_t>(*worldSizePtr); | 158 | uint32_t worldSize = static_cast<uint32_t>(*worldSizePtr); |
| 144 | tilingData.distributeBarrierInfo.worldSize = worldSize; | 159 | tilingData.distributeBarrierInfo.worldSize = worldSize; |
| 145 | 160 | ||
| 146 | OPS_LOG_D(A_INNER_DEBUG_BARRIER, "group = %s", groupPtr); | 161 | OPS_LOG_D(A_INNER_DEBUG_BARRIER, "group = %s", groupPtr); |
| 147 | group = string(groupPtr); | 162 | group = string(groupPtr); |
| 163 | + OP_TILING_CHECK(group.empty() || group.size() >= 128, | ||
| 164 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 165 | + context->GetNodeName(), "group", | ||
| 166 | + ("Length=" + std::to_string(group.size()) + "; expected [1, 127]").c_str()), | ||
| 167 | + return false); | ||
| 148 | if (isInputTimeOut) { | 168 | if (isInputTimeOut) { |
| 149 | - OP_TILING_CHECK(CheckTimeOut(context, config) == false, OPS_LOG_E(A_INNER_DEBUG_BARRIER, "timeOut is invalid!"), | 169 | + OP_TILING_CHECK(CheckTimeOut(context, config) == false, |
| 150 | - return false); | 170 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "timeOut is invalid!"), return false); |
| 151 | } | 171 | } |
| 152 | if (isInputElasticInfo) { | 172 | if (isInputElasticInfo) { |
| 153 | OP_TILING_CHECK(CheckElasticInfo(context, worldSize, config) == false, | 173 | OP_TILING_CHECK(CheckElasticInfo(context, worldSize, config) == false, |
| 154 | - OPS_LOG_E(A_INNER_DEBUG_BARRIER, "elasticInfo is invalid!"), return false); | 174 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "elasticInfo is invalid!"), return false); |
| 155 | } | 175 | } |
| 156 | 176 | ||
| 157 | return true; | 177 | return true; |
| @@ -160,8 +180,10 @@ static bool CheckAndSetAttrs(const gert::TilingContext* context, DistributeBarri | |||
| 160 | static ge::graphStatus SetWorkSpace(gert::TilingContext* context) | 180 | static ge::graphStatus SetWorkSpace(gert::TilingContext* context) |
| 161 | { | 181 | { |
| 162 | size_t* workSpaces = context->GetWorkspaceSizes(1); | 182 | size_t* workSpaces = context->GetWorkspaceSizes(1); |
| 163 | - OP_TILING_CHECK(workSpaces == nullptr, OPS_LOG_E(A_INNER_DEBUG_BARRIER, "workSpaces is nullptr."), | 183 | + OP_TILING_CHECK( |
| 164 | - return ge::GRAPH_FAILED); | 184 | + workSpaces == nullptr, |
| 185 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "Workspace size holder is absent; required one slot"), | ||
| 186 | + return ge::GRAPH_FAILED); | ||
| 165 | workSpaces[0] = SYSTEM_NEED_WORKSPACE; | 187 | workSpaces[0] = SYSTEM_NEED_WORKSPACE; |
| 166 | return ge::GRAPH_SUCCESS; | 188 | return ge::GRAPH_SUCCESS; |
| 167 | } | 189 | } |
| @@ -175,13 +197,8 @@ static ge::graphStatus SetHcommCfg([[maybe_unused]] const gert::TilingContext* c | |||
| 175 | 197 | ||
| 176 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType1, algConfigAllToAllStr); | 198 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType1, algConfigAllToAllStr); |
| 177 | mc2CcTilingConfig.SetCommEngine(mc2tiling::AIV_ENGINE); // 通过不拉起AICPU,提高算子退出性能 | 199 | mc2CcTilingConfig.SetCommEngine(mc2tiling::AIV_ENGINE); // 通过不拉起AICPU,提高算子退出性能 |
| 178 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tiling->mc2InitTiling) != 0, | 200 | + return Mc2Error::GetValidatedHcclTiling(mc2CcTilingConfig, tiling->mc2InitTiling, tiling->mc2CcTiling1, |
| 179 | - OP_LOGE(context->GetNodeName(), "mc2CcTilingConfig mc2tiling GetTiling mc2InitTiling failed"), | 201 | + context->GetNodeName()); |
| 180 | - return ge::GRAPH_FAILED); | ||
| 181 | - OP_TILING_CHECK(mc2CcTilingConfig.GetTiling(tiling->mc2CcTiling1) != 0, | ||
| 182 | - OP_LOGE(context->GetNodeName(), "mc2CcTilingConfig mc2tiling GetTiling mc2CcTiling1 failed"), | ||
| 183 | - return ge::GRAPH_FAILED); | ||
| 184 | - return ge::GRAPH_SUCCESS; | ||
| 185 | } | 202 | } |
| 186 | 203 | ||
| 187 | static void DistributeBarrierConfigIndexSet(DistributeBarrierConfig& config) | 204 | static void DistributeBarrierConfigIndexSet(DistributeBarrierConfig& config) |
| @@ -201,7 +218,7 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 201 | const DistributeBarrierConfig& config) | 218 | const DistributeBarrierConfig& config) |
| 202 | { | 219 | { |
| 203 | const gert::StorageShape* contextStorageShape = context->GetInputShape(config.contextIndex); | 220 | const gert::StorageShape* contextStorageShape = context->GetInputShape(config.contextIndex); |
| 204 | - OP_TILING_CHECK(contextStorageShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "contextShape"), | 221 | + OP_TILING_CHECK(contextStorageShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "context"), |
| 205 | return ge::GRAPH_FAILED); | 222 | return ge::GRAPH_FAILED); |
| 206 | OP_TILING_CHECK(contextStorageShape->GetStorageShape().GetDimNum() != ONE_DIM, | 223 | OP_TILING_CHECK(contextStorageShape->GetStorageShape().GetDimNum() != ONE_DIM, |
| 207 | OP_LOGE_FOR_INVALID_SHAPEDIM( | 224 | OP_LOGE_FOR_INVALID_SHAPEDIM( |
| @@ -212,8 +229,10 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 212 | OP_LOGD(nodeName, "context dim0 = %ld", contextDim0); | 229 | OP_LOGD(nodeName, "context dim0 = %ld", contextDim0); |
| 213 | 230 | ||
| 214 | auto contextDesc = context->GetInputDesc(config.contextIndex); | 231 | auto contextDesc = context->GetInputDesc(config.contextIndex); |
| 215 | - OP_TILING_CHECK(contextDesc == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "contextDesc"), | 232 | + OP_TILING_CHECK( |
| 216 | - return ge::GRAPH_FAILED); | 233 | + contextDesc == nullptr, |
| 234 | + Mc2Error::ReportTilingFailure(nodeName, "contextDesc descriptor is absent while its input shape is present"), | ||
| 235 | + return ge::GRAPH_FAILED); | ||
| 217 | OP_TILING_CHECK(contextDesc->GetDataType() != ge::DT_INT32, | 236 | OP_TILING_CHECK(contextDesc->GetDataType() != ge::DT_INT32, |
| 218 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "context", | 237 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "context", |
| 219 | Ops::Base::ToString(contextDesc->GetDataType()).c_str(), "INT32"), | 238 | Ops::Base::ToString(contextDesc->GetDataType()).c_str(), "INT32"), |
| @@ -233,9 +252,18 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 233 | ge::graphStatus DistributeBarrierExtendTilingFuncNew(gert::TilingContext* context, | 252 | ge::graphStatus DistributeBarrierExtendTilingFuncNew(gert::TilingContext* context, |
| 234 | const DistributeBarrierConfig& config) | 253 | const DistributeBarrierConfig& config) |
| 235 | { | 254 | { |
| 255 | + OP_TILING_CHECK(context == nullptr, Mc2Error::ReportTilingFailure("DistributeBarrier", "Tiling context is null"), | ||
| 256 | + return ge::GRAPH_FAILED); | ||
| 257 | + OP_TILING_CHECK(context->GetPlatformInfo() == nullptr, | ||
| 258 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), "Platform resource metadata is absent"), | ||
| 259 | + return ge::GRAPH_FAILED); | ||
| 236 | const char* nodeName = context->GetNodeName(); | 260 | const char* nodeName = context->GetNodeName(); |
| 237 | DistributeBarrierTilingData* tilingData = context->GetTilingData<DistributeBarrierTilingData>(); | 261 | DistributeBarrierTilingData* tilingData = context->GetTilingData<DistributeBarrierTilingData>(); |
| 238 | - OP_TILING_CHECK(tilingData == nullptr, OPS_LOG_E(nodeName, "tilingData is nullptr."), return ge::GRAPH_FAILED); | 262 | + OP_TILING_CHECK( |
| 263 | + tilingData == nullptr, | ||
| 264 | + Mc2Error::ReportTilingFailure(nodeName, "Typed tiling buffer is absent or too small; required " + | ||
| 265 | + std::to_string(sizeof(DistributeBarrierTilingData)) + " bytes"), | ||
| 266 | + return ge::GRAPH_FAILED); | ||
| 239 | std::string group = ""; | 267 | std::string group = ""; |
| 240 | bool isInputTimeOut = false; | 268 | bool isInputTimeOut = false; |
| 241 | bool isInputElasticInfo = false; | 269 | bool isInputElasticInfo = false; |
| @@ -250,21 +278,23 @@ ge::graphStatus DistributeBarrierExtendTilingFuncNew(gert::TilingContext* contex | |||
| 250 | // 检查context输入 | 278 | // 检查context输入 |
| 251 | if (config.isMc2Context) { | 279 | if (config.isMc2Context) { |
| 252 | OP_TILING_CHECK(CheckMc2Context(context, nodeName, config) != ge::GRAPH_SUCCESS, | 280 | OP_TILING_CHECK(CheckMc2Context(context, nodeName, config) != ge::GRAPH_SUCCESS, |
| 253 | - OP_LOGE(nodeName, "Tiling check context failed."), return ge::GRAPH_FAILED); | 281 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Tiling check context failed."), return ge::GRAPH_FAILED); |
| 254 | } | 282 | } |
| 255 | 283 | ||
| 256 | // Function that get check and set Attrs | 284 | // Function that get check and set Attrs |
| 257 | OP_TILING_CHECK(!CheckAndSetAttrs(context, *tilingData, group, isInputTimeOut, isInputElasticInfo, config), | 285 | OP_TILING_CHECK(!CheckAndSetAttrs(context, *tilingData, group, isInputTimeOut, isInputElasticInfo, config), |
| 258 | - OPS_LOG_E(A_INNER_DEBUG_BARRIER, "Check and set attributes failed!"), return ge::GRAPH_FAILED); | 286 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "Check and set attributes failed!"), |
| 287 | + return ge::GRAPH_FAILED); | ||
| 259 | 288 | ||
| 260 | // Set WorkSpace | 289 | // Set WorkSpace |
| 261 | OP_TILING_CHECK(SetWorkSpace(context) != ge::GRAPH_SUCCESS, | 290 | OP_TILING_CHECK(SetWorkSpace(context) != ge::GRAPH_SUCCESS, |
| 262 | - OPS_LOG_E(A_INNER_DEBUG_BARRIER, "Tiling set workspace failed."), return ge::GRAPH_FAILED); | 291 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "Tiling set workspace failed."), |
| 292 | + return ge::GRAPH_FAILED); | ||
| 263 | 293 | ||
| 264 | if (!config.isMc2Context) { | 294 | if (!config.isMc2Context) { |
| 265 | // Set HcommCfg | 295 | // Set HcommCfg |
| 266 | OP_TILING_CHECK(SetHcommCfg(context, tilingData, group) != ge::GRAPH_SUCCESS, | 296 | OP_TILING_CHECK(SetHcommCfg(context, tilingData, group) != ge::GRAPH_SUCCESS, |
| 267 | - OP_LOGE(nodeName, "Tiling SetHcommCfg failed."), return ge::GRAPH_FAILED); | 297 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Tiling SetHcommCfg failed."), return ge::GRAPH_FAILED); |
| 268 | } | 298 | } |
| 269 | // Set numBlocks | 299 | // Set numBlocks |
| 270 | uint32_t numBlocks = 1U; | 300 | uint32_t numBlocks = 1U; |
| @@ -272,9 +302,20 @@ ge::graphStatus DistributeBarrierExtendTilingFuncNew(gert::TilingContext* contex | |||
| 272 | uint32_t aivNum = ascendcPlatform.GetCoreNumAiv(); | 302 | uint32_t aivNum = ascendcPlatform.GetCoreNumAiv(); |
| 273 | uint64_t ubSize = 0UL; | 303 | uint64_t ubSize = 0UL; |
| 274 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); | 304 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); |
| 305 | + OP_TILING_CHECK(aivNum < 2, | ||
| 306 | + Mc2Error::ReportTilingFailure( | ||
| 307 | + nodeName, "Available AIV core count=" + std::to_string(aivNum) + | ||
| 308 | + "; required at least 2 because one core receives while the remaining cores send"), | ||
| 309 | + return ge::GRAPH_FAILED); | ||
| 275 | numBlocks = ascendcPlatform.CalcTschBlockDim(aivNum, 0, aivNum); | 310 | numBlocks = ascendcPlatform.CalcTschBlockDim(aivNum, 0, aivNum); |
| 311 | + OP_TILING_CHECK( | ||
| 312 | + numBlocks == 0, | ||
| 313 | + Mc2Error::ReportTilingFailure(nodeName, "Calculated launch block count=0; check platform scheduling resources"), | ||
| 314 | + return ge::GRAPH_FAILED); | ||
| 276 | context->SetBlockDim(numBlocks); | 315 | context->SetBlockDim(numBlocks); |
| 277 | - context->SetScheduleMode(1); // 设置为batch mode模式,所有核同时启动 | 316 | + OP_TILING_CHECK(context->SetScheduleMode(1) != ge::GRAPH_SUCCESS, |
| 317 | + Mc2Error::ReportTilingFailure(nodeName, "Schedule mode output slot is absent"), | ||
| 318 | + return ge::GRAPH_FAILED); | ||
| 278 | tilingData->distributeBarrierInfo.totalUbSize = ubSize; | 319 | tilingData->distributeBarrierInfo.totalUbSize = ubSize; |
| 279 | tilingData->distributeBarrierInfo.aivNum = aivNum; | 320 | tilingData->distributeBarrierInfo.aivNum = aivNum; |
| 280 | OPS_LOG_D(A_INNER_DEBUG_BARRIER, "numBlocks=%u, aivNum=%u, ubSize=%lu", numBlocks, aivNum, ubSize); | 321 | OPS_LOG_D(A_INNER_DEBUG_BARRIER, "numBlocks=%u, aivNum=%u, ubSize=%lu", numBlocks, aivNum, ubSize); |
| @@ -11,3 +11,10 @@ | |||
| 11 | if(UT_TEST_ALL OR OP_HOST_UT) | 11 | if(UT_TEST_ALL OR OP_HOST_UT) |
| 12 | add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) | 12 | add_modules_ut_sources(UT_NAME ${OP_TILING_MODULE_NAME} MODE PRIVATE DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 13 | endif() | 13 | endif() |
| 14 | + | ||
| 15 | +if((UT_TEST_ALL OR OP_HOST_UT) AND TARGET ${OP_TILING_MODULE_NAME}_cases_obj) | ||
| 16 | + get_target_property(_mc2_case_sources ${OP_TILING_MODULE_NAME}_cases_obj SOURCES) | ||
| 17 | + if("${_mc2_case_sources}" MATCHES "test_distribute_barrier_tiling\\.cpp") | ||
| 18 | + target_link_libraries(${OP_TILING_MODULE_NAME}_cases_obj PRIVATE error_manager) | ||
| 19 | + endif() | ||
| 20 | +endif() | ||
| @@ -11,6 +11,8 @@ | |||
| 11 | #include <iostream> | 11 | #include <iostream> |
| 12 | #include <unordered_set> | 12 | #include <unordered_set> |
| 13 | #include <gtest/gtest.h> | 13 | #include <gtest/gtest.h> |
| 14 | +#include "mc2/common/tests/ut/internal_fallback_assertions.h" | ||
| 15 | +#include "mc2/common/tests/ut/formal_error_assertions.h" | ||
| 14 | #include "tiling_context_faker.h" | 16 | #include "tiling_context_faker.h" |
| 15 | #include "tiling_case_executor.h" | 17 | #include "tiling_case_executor.h" |
| 16 | #include "kernel_tiling/kernel_tiling.h" | 18 | #include "kernel_tiling/kernel_tiling.h" |
| @@ -379,4 +381,28 @@ TEST_F(DistributeBarrierArch22TilingTest, TestTilingElasticInfoFormatInvalid) | |||
| 379 | ASSERT_FALSE(ExecuteTiling(tilingContextPara, tilingInfo)); | 381 | ASSERT_FALSE(ExecuteTiling(tilingContextPara, tilingInfo)); |
| 380 | } | 382 | } |
| 381 | 383 | ||
| 384 | +TEST_F(DistributeBarrierArch22TilingTest, AivZeroAndOneFailBeforeKernelDivisionInternalFallback) | ||
| 385 | +{ | ||
| 386 | + for (uint32_t aiv : {0U, 1U}) { | ||
| 387 | + Mc2ErrorCodeUT::ExcelErrorReportScope reports; | ||
| 388 | + struct { | ||
| 389 | + } compileInfo; | ||
| 390 | + gert::TilingContextPara para("DistributeBarrier", {{{{3, 4}, {3, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND}}, | ||
| 391 | + {{{{3, 4}, {3, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND}}, | ||
| 392 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 393 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}}, | ||
| 394 | + &compileInfo, "Ascend910_93", 20, 196608); | ||
| 395 | + para.socInfoString_ = | ||
| 396 | + std::string(R"({"hardware_info":{"CORE_NUM":20,"cube_core_cnt":20,"vector_core_cnt":)") + | ||
| 397 | + std::to_string(aiv) + | ||
| 398 | + R"(,"UB_SIZE":196608,"L1_SIZE":524288,"L0A_SIZE":65536,"L0B_SIZE":65536,"L0C_SIZE":131072}})"; | ||
| 399 | + TilingInfo info; | ||
| 400 | + EXPECT_FALSE(ExecuteTiling(para, info)); | ||
| 401 | + Mc2ErrorCodeUT::ExpectInternalFallbackReport( | ||
| 402 | + ("Available AIV core count=" + std::to_string(aiv) + | ||
| 403 | + "; required at least 2 because one core receives while the remaining cores send") | ||
| 404 | + .c_str()); | ||
| 405 | + } | ||
| 406 | +} | ||
| 407 | + | ||
| 382 | } // namespace DistributeBarrierUT | 408 | } // namespace DistributeBarrierUT |
| @@ -31,6 +31,9 @@ | |||
| 31 | #include "register/tilingdata_base.h" | 31 | #include "register/tilingdata_base.h" |
| 32 | #include "tiling/tiling_api.h" | 32 | #include "tiling/tiling_api.h" |
| 33 | #include "mc2_log.h" | 33 | #include "mc2_log.h" |
| 34 | +#include "mc2_tiling_failure_report.h" | ||
| 35 | +#include <cstring> | ||
| 36 | +#include <cstdlib> | ||
| 34 | #include "ffn_to_attention_tiling_base.h" | 37 | #include "ffn_to_attention_tiling_base.h" |
| 35 | #include "../../op_kernel/ffn_to_attention_tiling.h" | 38 | #include "../../op_kernel/ffn_to_attention_tiling.h" |
| 36 | #include "../../op_kernel/ffn_to_attention_tilling_key.h" | 39 | #include "../../op_kernel/ffn_to_attention_tilling_key.h" |
| @@ -135,8 +138,8 @@ static bool CheckAttrLimits(const char* nodeName, const int64_t worldSize, const | |||
| 135 | { | 138 | { |
| 136 | OP_TILING_CHECK( | 139 | OP_TILING_CHECK( |
| 137 | (worldSize < MIN_WORLD_SIZE) || (worldSize > MAX_WORLD_SIZE), | 140 | (worldSize < MIN_WORLD_SIZE) || (worldSize > MAX_WORLD_SIZE), |
| 138 | - OP_LOGE_FOR_INVALID_VALUE( | 141 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 139 | - nodeName, "worldSize", std::to_string(worldSize).c_str(), | 142 | + nodeName, "world_size", std::to_string(worldSize).c_str(), |
| 140 | (std::string("[") + std::to_string(MIN_WORLD_SIZE) + ", " + std::to_string(MAX_WORLD_SIZE) + "]").c_str()), | 143 | (std::string("[") + std::to_string(MIN_WORLD_SIZE) + ", " + std::to_string(MAX_WORLD_SIZE) + "]").c_str()), |
| 141 | return false); | 144 | return false); |
| 142 | if (allowMultiMicroBatch) { | 145 | if (allowMultiMicroBatch) { |
| @@ -189,25 +192,46 @@ static bool CheckAndSetAttrs(const gert::TilingContext* context, const char* nod | |||
| 189 | const FFNToAttentionTilingConfig& config) | 192 | const FFNToAttentionTilingConfig& config) |
| 190 | { | 193 | { |
| 191 | auto attrs = context->GetAttrs(); | 194 | auto attrs = context->GetAttrs(); |
| 192 | - OP_TILING_CHECK(attrs == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "attrs"), return false); | 195 | + OP_TILING_CHECK( |
| 196 | + attrs == nullptr, | ||
| 197 | + Mc2Error::ReportTilingFailure(nodeName, "Attribute container actual=null; expected schema metadata"), | ||
| 198 | + return false); | ||
| 193 | 199 | ||
| 194 | auto groupPtr = attrs->GetAttrPointer<char>(config.attrGroupIndex); | 200 | auto groupPtr = attrs->GetAttrPointer<char>(config.attrGroupIndex); |
| 195 | - auto worldSizePtr = attrs->GetAttrPointer<int>(config.attrWorldSizeIndex); | 201 | + auto worldSizePtr = attrs->GetAttrPointer<int64_t>(config.attrWorldSizeIndex); |
| 196 | auto tokenInfoTable = attrs->GetListInt(config.attrTokenInfoTableShapeIndex); | 202 | auto tokenInfoTable = attrs->GetListInt(config.attrTokenInfoTableShapeIndex); |
| 197 | auto tokenData = attrs->GetListInt(config.attrTokenDataShapeIndex); | 203 | auto tokenData = attrs->GetListInt(config.attrTokenDataShapeIndex); |
| 198 | - auto tokenInfoTableShape = tokenInfoTable->GetData(); | ||
| 199 | - auto tokenDataShape = tokenData->GetData(); | ||
| 200 | 204 | ||
| 201 | // 当前仅对必选属性进行校空 | 205 | // 当前仅对必选属性进行校空 |
| 202 | - OP_TILING_CHECK(groupPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "group"), return false); | 206 | + OP_TILING_CHECK(groupPtr == nullptr, |
| 203 | - OP_TILING_CHECK((strnlen(groupPtr, MAX_GROUP_NAME_LENGTH) == 0) || | 207 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( |
| 204 | - (strnlen(groupPtr, MAX_GROUP_NAME_LENGTH) == MAX_GROUP_NAME_LENGTH), | 208 | + nodeName, "group", "Required attribute group is missing; provide this attribute"), |
| 205 | - OP_LOGE_FOR_INVALID_VALUE( | ||
| 206 | - nodeName, "group", | ||
| 207 | - (std::string("length=") + std::to_string(strnlen(groupPtr, MAX_GROUP_NAME_LENGTH))).c_str(), | ||
| 208 | - "valid group name length"), | ||
| 209 | return false); | 209 | return false); |
| 210 | - OP_TILING_CHECK(worldSizePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "worldSize"), return false); | 210 | + const size_t groupLength = strnlen(groupPtr, MAX_GROUP_NAME_LENGTH); |
| 211 | + OP_TILING_CHECK( | ||
| 212 | + groupLength == 0 || groupLength == MAX_GROUP_NAME_LENGTH, | ||
| 213 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 214 | + nodeName, "group", | ||
| 215 | + (std::string(groupLength == MAX_GROUP_NAME_LENGTH ? "length>=" : "length=") + std::to_string(groupLength)) | ||
| 216 | + .c_str(), | ||
| 217 | + (std::string("Group name length must be in [1, ") + std::to_string(MAX_GROUP_NAME_LENGTH - 1) + "]") | ||
| 218 | + .c_str()), | ||
| 219 | + return false); | ||
| 220 | + OP_TILING_CHECK(worldSizePtr == nullptr, | ||
| 221 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 222 | + nodeName, "world_size", "Required attribute world_size is missing; provide this attribute"), | ||
| 223 | + return false); | ||
| 224 | + OP_TILING_CHECK( | ||
| 225 | + tokenInfoTable == nullptr, | ||
| 226 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(nodeName, "token_info_table_shape", | ||
| 227 | + "Required list attribute token_info_table_shape is missing"), | ||
| 228 | + return false); | ||
| 229 | + OP_TILING_CHECK(tokenData == nullptr, | ||
| 230 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(nodeName, "token_data_shape", | ||
| 231 | + "Required list attribute token_data_shape is missing"), | ||
| 232 | + return false); | ||
| 233 | + auto tokenInfoTableShape = tokenInfoTable->GetData(); | ||
| 234 | + auto tokenDataShape = tokenData->GetData(); | ||
| 211 | OP_TILING_CHECK(!CheckAttrShapes(nodeName, tokenInfoTable, tokenData), static_cast<void>(0), return false); | 235 | OP_TILING_CHECK(!CheckAttrShapes(nodeName, tokenInfoTable, tokenData), static_cast<void>(0), return false); |
| 212 | // 判断是否满足其他限制 | 236 | // 判断是否满足其他限制 |
| 213 | int64_t worldSize = *worldSizePtr; | 237 | int64_t worldSize = *worldSizePtr; |
| @@ -345,7 +369,7 @@ static bool CheckInputDim(gert::TilingContext* context, const char* nodeName, FF | |||
| 345 | const FFNToAttentionTilingConfig& config) | 369 | const FFNToAttentionTilingConfig& config) |
| 346 | { | 370 | { |
| 347 | auto attrs = context->GetAttrs(); | 371 | auto attrs = context->GetAttrs(); |
| 348 | - auto worldSizePtr = attrs->GetAttrPointer<int>(config.attrWorldSizeIndex); | 372 | + auto worldSizePtr = attrs->GetAttrPointer<int64_t>(config.attrWorldSizeIndex); |
| 349 | int64_t worldSize = *worldSizePtr; | 373 | int64_t worldSize = *worldSizePtr; |
| 350 | const gert::StorageShape* xShape = context->GetInputShape(config.xIndex); | 374 | const gert::StorageShape* xShape = context->GetInputShape(config.xIndex); |
| 351 | const gert::StorageShape* sessionIdsShape = context->GetInputShape(config.sessionIdsIndex); | 375 | const gert::StorageShape* sessionIdsShape = context->GetInputShape(config.sessionIdsIndex); |
| @@ -361,7 +385,7 @@ static bool CheckInputDim(gert::TilingContext* context, const char* nodeName, FF | |||
| 361 | static_cast<void>(0), return false); | 385 | static_cast<void>(0), return false); |
| 362 | 386 | ||
| 363 | OP_TILING_CHECK(!CheckInputDim0Dim1(context, nodeName, tilingData, config), | 387 | OP_TILING_CHECK(!CheckInputDim0Dim1(context, nodeName, tilingData, config), |
| 364 | - OP_LOGE(nodeName, "Check Inputsdim0ordim1 failed!"), return false); | 388 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check Inputsdim0ordim1 failed!"), return false); |
| 365 | 389 | ||
| 366 | if (isInputRankTable) { | 390 | if (isInputRankTable) { |
| 367 | OP_TILING_CHECK(attnRankTableShape->GetStorageShape().GetDimNum() != ONE_DIM, | 391 | OP_TILING_CHECK(attnRankTableShape->GetStorageShape().GetDimNum() != ONE_DIM, |
| @@ -571,19 +595,22 @@ static bool CheckInputAndSetTilingData(gert::TilingContext* context, const char* | |||
| 571 | { | 595 | { |
| 572 | // 校验输入数据dim、format、dataType | 596 | // 校验输入数据dim、format、dataType |
| 573 | OP_TILING_CHECK(!CheckInputDim(context, nodeName, tilingData, config), | 597 | OP_TILING_CHECK(!CheckInputDim(context, nodeName, tilingData, config), |
| 574 | - OP_LOGE(nodeName, "Check Inputs dim failed!"), return false); | 598 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check Inputs dim failed!"), return false); |
| 575 | 599 | ||
| 576 | OP_TILING_CHECK(!CheckInputDataType(context, nodeName, config), | 600 | OP_TILING_CHECK(!CheckInputDataType(context, nodeName, config), |
| 577 | - OP_LOGE(nodeName, "Check Inputs dataType is invalid."), return false); | 601 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check Inputs dataType is invalid."), return false); |
| 578 | - OP_TILING_CHECK(!CheckInputFormat(context, nodeName, config), OP_LOGE(nodeName, "Check Inputs format is invalid."), | 602 | + OP_TILING_CHECK(!CheckInputFormat(context, nodeName, config), |
| 579 | - return false); | 603 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check Inputs format is invalid."), return false); |
| 580 | return true; | 604 | return true; |
| 581 | } | 605 | } |
| 582 | 606 | ||
| 583 | static ge::graphStatus SetWorkSpace(gert::TilingContext* context, const char* nodeName) | 607 | static ge::graphStatus SetWorkSpace(gert::TilingContext* context, const char* nodeName) |
| 584 | { | 608 | { |
| 585 | size_t* workSpaces = context->GetWorkspaceSizes(1); | 609 | size_t* workSpaces = context->GetWorkspaceSizes(1); |
| 586 | - OP_TILING_CHECK(workSpaces == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "workSpaces"), return ge::GRAPH_FAILED); | 610 | + OP_TILING_CHECK( |
| 611 | + workSpaces == nullptr, | ||
| 612 | + Mc2Error::ReportTilingFailure(nodeName, "SetWorkSpace: workspace holder actual=null; expected one size slot"), | ||
| 613 | + return ge::GRAPH_FAILED); | ||
| 587 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | 614 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); |
| 588 | workSpaces[0] = ascendcPlatform.GetLibApiWorkSpaceSize(); | 615 | workSpaces[0] = ascendcPlatform.GetLibApiWorkSpaceSize(); |
| 589 | return ge::GRAPH_SUCCESS; | 616 | return ge::GRAPH_SUCCESS; |
| @@ -619,9 +646,32 @@ static ge::graphStatus SetHcommCfg(const gert::TilingContext* context, FFNToAtte | |||
| 619 | OP_LOGD(nodeName, "ffnToAttention group = %s", group.c_str()); | 646 | OP_LOGD(nodeName, "ffnToAttention group = %s", group.c_str()); |
| 620 | uint32_t opType1 = OP_TYPE_ALL_TO_ALL; | 647 | uint32_t opType1 = OP_TYPE_ALL_TO_ALL; |
| 621 | std::string algConfigAllToAllStr = "AlltoAll=level0:fullmesh;level1:pairwise"; | 648 | std::string algConfigAllToAllStr = "AlltoAll=level0:fullmesh;level1:pairwise"; |
| 649 | + OP_TILING_CHECK( | ||
| 650 | + group.size() >= 128U, | ||
| 651 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 652 | + context->GetNodeName(), "group", | ||
| 653 | + ("Group length actual=" + std::to_string(group.size()) + "; expected fewer than 128 bytes").c_str()), | ||
| 654 | + return ge::GRAPH_FAILED); | ||
| 655 | + const char* ascendHome = std::getenv("ASCEND_HOME_PATH"); | ||
| 656 | + if (ascendHome == nullptr || ascendHome[0] == '\0') { | ||
| 657 | + OP_LOGE(context->GetNodeName(), | ||
| 658 | + "SetHcommCfg failed: required environment variable ASCEND_HOME_PATH is absent or empty"); | ||
| 659 | + return ge::GRAPH_FAILED; | ||
| 660 | + } | ||
| 622 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType1, algConfigAllToAllStr); | 661 | AscendC::Mc2CcTilingConfig mc2CcTilingConfig(group, opType1, algConfigAllToAllStr); |
| 623 | - mc2CcTilingConfig.GetTiling(tilingData.mc2InitTiling); | 662 | + const auto initStatus = mc2CcTilingConfig.GetTiling(tilingData.mc2InitTiling); |
| 624 | - mc2CcTilingConfig.GetTiling(tilingData.mc2CcTiling1); | 663 | + OP_TILING_CHECK(initStatus != 0, |
| 664 | + Mc2Error::ReportTilingFailure( | ||
| 665 | + context->GetNodeName(), | ||
| 666 | + "SetHcommCfg: GetTiling(init) failed obtaining required rtGetSocVersion from " + | ||
| 667 | + std::string(ascendHome) + "/lib64/libruntime.so; actual rc=" + std::to_string(initStatus) + | ||
| 668 | + ", expected 0 for validated group and fixed AlltoAll algorithm"), | ||
| 669 | + return ge::GRAPH_FAILED); | ||
| 670 | + const auto ccStatus = mc2CcTilingConfig.GetTiling(tilingData.mc2CcTiling1); | ||
| 671 | + OP_TILING_CHECK(ccStatus != 0, | ||
| 672 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "SetHcommCfg: GetTiling(CC) invariant failed, rc=%u", | ||
| 673 | + static_cast<unsigned>(ccStatus)), | ||
| 674 | + return ge::GRAPH_FAILED); | ||
| 625 | return ge::GRAPH_SUCCESS; | 675 | return ge::GRAPH_SUCCESS; |
| 626 | } | 676 | } |
| 627 | 677 | ||
| @@ -629,7 +679,7 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 629 | const FFNToAttentionTilingConfig& config) | 679 | const FFNToAttentionTilingConfig& config) |
| 630 | { | 680 | { |
| 631 | const gert::StorageShape* contextStorageShape = context->GetInputShape(config.contextIndex); | 681 | const gert::StorageShape* contextStorageShape = context->GetInputShape(config.contextIndex); |
| 632 | - OP_TILING_CHECK(contextStorageShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "contextShape"), | 682 | + OP_TILING_CHECK(contextStorageShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "context"), |
| 633 | return ge::GRAPH_FAILED); | 683 | return ge::GRAPH_FAILED); |
| 634 | OP_TILING_CHECK(contextStorageShape->GetStorageShape().GetDimNum() != ONE_DIM, | 684 | OP_TILING_CHECK(contextStorageShape->GetStorageShape().GetDimNum() != ONE_DIM, |
| 635 | OP_LOGE_FOR_INVALID_SHAPEDIM( | 685 | OP_LOGE_FOR_INVALID_SHAPEDIM( |
| @@ -638,7 +688,9 @@ static ge::graphStatus CheckMc2Context(const gert::TilingContext* context, const | |||
| 638 | return ge::GRAPH_FAILED); | 688 | return ge::GRAPH_FAILED); |
| 639 | 689 | ||
| 640 | auto contextDesc = context->GetInputDesc(config.contextIndex); | 690 | auto contextDesc = context->GetInputDesc(config.contextIndex); |
| 641 | - OP_TILING_CHECK(contextDesc == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "contextDesc"), | 691 | + OP_TILING_CHECK(contextDesc == nullptr, |
| 692 | + Mc2Error::ReportTilingFailure(nodeName, "CheckMc2Context: context descriptor actual=null after " | ||
| 693 | + "required shape was present; expected descriptor metadata"), | ||
| 642 | return ge::GRAPH_FAILED); | 694 | return ge::GRAPH_FAILED); |
| 643 | OP_TILING_CHECK(contextDesc->GetDataType() != ge::DT_INT32, | 695 | OP_TILING_CHECK(contextDesc->GetDataType() != ge::DT_INT32, |
| 644 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "context", | 696 | OP_LOGE_FOR_INVALID_DTYPE(nodeName, "context", |
| @@ -660,10 +712,16 @@ static ge::graphStatus CheckCclBufferSize(const gert::TilingContext* context, co | |||
| 660 | { | 712 | { |
| 661 | if (attrIndex != UINT32_MAX) { | 713 | if (attrIndex != UINT32_MAX) { |
| 662 | auto attrsPtr = context->GetAttrs(); | 714 | auto attrsPtr = context->GetAttrs(); |
| 663 | - OP_TILING_CHECK(attrsPtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "attrs"), return ge::GRAPH_FAILED); | 715 | + OP_TILING_CHECK( |
| 716 | + attrsPtr == nullptr, | ||
| 717 | + Mc2Error::ReportTilingFailure(nodeName, "Attribute container actual=null; expected schema metadata"), | ||
| 718 | + return ge::GRAPH_FAILED); | ||
| 664 | auto cclBufferSizePtr = attrsPtr->GetAttrPointer<int64_t>(attrIndex); | 719 | auto cclBufferSizePtr = attrsPtr->GetAttrPointer<int64_t>(attrIndex); |
| 665 | - OP_TILING_CHECK(cclBufferSizePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "ccl_buffer_size"), | 720 | + OP_TILING_CHECK( |
| 666 | - return ge::GRAPH_FAILED); | 721 | + cclBufferSizePtr == nullptr, |
| 722 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 723 | + nodeName, "ccl_buffer_size", "Required attribute ccl_buffer_size is missing; provide this attribute"), | ||
| 724 | + return ge::GRAPH_FAILED); | ||
| 667 | OP_TILING_CHECK(*cclBufferSizePtr <= 0, | 725 | OP_TILING_CHECK(*cclBufferSizePtr <= 0, |
| 668 | OP_LOGE_FOR_INVALID_VALUE(nodeName, "ccl_buffer_size", | 726 | OP_LOGE_FOR_INVALID_VALUE(nodeName, "ccl_buffer_size", |
| 669 | std::to_string(*cclBufferSizePtr).c_str(), "greater than 0"), | 727 | std::to_string(*cclBufferSizePtr).c_str(), "greater than 0"), |
| @@ -721,10 +779,34 @@ static ge::graphStatus CheckFFNWindowSize(gert::TilingContext* context, const ch | |||
| 721 | 779 | ||
| 722 | ge::graphStatus FFNToAttentionTilingFuncBase(gert::TilingContext* context, const FFNToAttentionTilingConfig& config) | 780 | ge::graphStatus FFNToAttentionTilingFuncBase(gert::TilingContext* context, const FFNToAttentionTilingConfig& config) |
| 723 | { | 781 | { |
| 782 | + OP_TILING_CHECK(context == nullptr, | ||
| 783 | + Mc2Error::ReportTilingFailure( | ||
| 784 | + "FFNToAttention", | ||
| 785 | + "FFNToAttentionTilingFuncBase: context actual=null; expected materialized tiling context"), | ||
| 786 | + return ge::GRAPH_FAILED); | ||
| 787 | + OP_TILING_CHECK( | ||
| 788 | + context->GetPlatformInfo() == nullptr, | ||
| 789 | + Mc2Error::ReportTilingFailure( | ||
| 790 | + context->GetNodeName(), | ||
| 791 | + "FFNToAttentionTilingFuncBase: platform metadata actual=null; expected CANN platform information"), | ||
| 792 | + return ge::GRAPH_FAILED); | ||
| 793 | + auto entryPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); | ||
| 794 | + const uint32_t entryAivNum = entryPlatform.GetCoreNumAiv(); | ||
| 795 | + OP_TILING_CHECK( | ||
| 796 | + entryAivNum == 0U, | ||
| 797 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), | ||
| 798 | + "FFNToAttentionTilingFuncBase: AIV core count actual=0; expected positive"), | ||
| 799 | + return ge::GRAPH_FAILED); | ||
| 800 | + | ||
| 724 | FFNToAttentionTilingData* tilingData = context->GetTilingData<FFNToAttentionTilingData>(); | 801 | FFNToAttentionTilingData* tilingData = context->GetTilingData<FFNToAttentionTilingData>(); |
| 725 | std::string group = ""; | 802 | std::string group = ""; |
| 726 | const char* nodeName = context->GetNodeName(); | 803 | const char* nodeName = context->GetNodeName(); |
| 727 | - OP_TILING_CHECK(tilingData == nullptr, OP_LOGE_WITH_INVALID_INPUT(nodeName, "tilingData"), return ge::GRAPH_FAILED); | 804 | + OP_TILING_CHECK( |
| 805 | + tilingData == nullptr, | ||
| 806 | + Mc2Error::ReportTilingFailure( | ||
| 807 | + nodeName, "FFNToAttentionTilingFuncBase: raw tilingData actual=null or capacity insufficient; required=" + | ||
| 808 | + std::to_string(sizeof(FFNToAttentionTilingData))), | ||
| 809 | + return ge::GRAPH_FAILED); | ||
| 728 | 810 | ||
| 729 | if (config.isMc2Context) { | 811 | if (config.isMc2Context) { |
| 730 | OP_TILING_CHECK(CheckMc2Context(context, nodeName, config) != ge::GRAPH_SUCCESS, | 812 | OP_TILING_CHECK(CheckMc2Context(context, nodeName, config) != ge::GRAPH_SUCCESS, |
| @@ -733,11 +815,11 @@ ge::graphStatus FFNToAttentionTilingFuncBase(gert::TilingContext* context, const | |||
| 733 | 815 | ||
| 734 | // Function that get check and set Attrs | 816 | // Function that get check and set Attrs |
| 735 | OP_TILING_CHECK(!CheckAndSetAttrs(context, nodeName, *tilingData, group, config), | 817 | OP_TILING_CHECK(!CheckAndSetAttrs(context, nodeName, *tilingData, group, config), |
| 736 | - OP_LOGE(nodeName, "Check and set attributes failed!"), return ge::GRAPH_FAILED); | 818 | + OP_LOGE_LIBOPAPI_REPORT(nodeName, "Check and set attributes failed!"), return ge::GRAPH_FAILED); |
| 737 | 819 | ||
| 738 | // Function that check input dim 、format、datatype | 820 | // Function that check input dim 、format、datatype |
| 739 | OP_TILING_CHECK(!CheckInputAndSetTilingData(context, nodeName, *tilingData, config), | 821 | OP_TILING_CHECK(!CheckInputAndSetTilingData(context, nodeName, *tilingData, config), |
| 740 | - OP_LOGE(nodeName, "Check Inputs and Outputs failed!"), return ge::GRAPH_FAILED); | 822 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Check Inputs and Outputs failed!"), return ge::GRAPH_FAILED); |
| 741 | 823 | ||
| 742 | // Check window Size | 824 | // Check window Size |
| 743 | uint64_t neededSize = 0; | 825 | uint64_t neededSize = 0; |
| @@ -757,11 +839,11 @@ ge::graphStatus FFNToAttentionTilingFuncBase(gert::TilingContext* context, const | |||
| 757 | 839 | ||
| 758 | // Set WorkSpace | 840 | // Set WorkSpace |
| 759 | OP_TILING_CHECK(SetWorkSpace(context, nodeName) != ge::GRAPH_SUCCESS, | 841 | OP_TILING_CHECK(SetWorkSpace(context, nodeName) != ge::GRAPH_SUCCESS, |
| 760 | - OP_LOGE(nodeName, "Tiling set workspace failed."), return ge::GRAPH_FAILED); | 842 | + OP_LOGE_WITHOUT_REPORT(nodeName, "Tiling set workspace failed."), return ge::GRAPH_FAILED); |
| 761 | 843 | ||
| 762 | // Set HcommCfg | 844 | // Set HcommCfg |
| 763 | OP_TILING_CHECK(SetHcommCfg(context, *tilingData, group) != ge::GRAPH_SUCCESS, | 845 | OP_TILING_CHECK(SetHcommCfg(context, *tilingData, group) != ge::GRAPH_SUCCESS, |
| 764 | - OP_LOGE(nodeName, "setHcommCfg failed."), return ge::GRAPH_FAILED); | 846 | + OP_LOGE_WITHOUT_REPORT(nodeName, "setHcommCfg failed."), return ge::GRAPH_FAILED); |
| 765 | 847 | ||
| 766 | // Set TilingKey | 848 | // Set TilingKey |
| 767 | bool rankTableMode = tilingData->ffnToAttentionInfo.isInputRankTable; | 849 | bool rankTableMode = tilingData->ffnToAttentionInfo.isInputRankTable; |
| @@ -11,9 +11,13 @@ BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULA | |||
| 11 | 11 | ||
| 12 | #include <iostream> | 12 | #include <iostream> |
| 13 | #include <gtest/gtest.h> | 13 | #include <gtest/gtest.h> |
| 14 | +#include "mc2/common/tests/ut/formal_error_assertions.h" | ||
| 14 | #include "../../../../op_kernel/ffn_to_attention_tiling.h" | 15 | #include "../../../../op_kernel/ffn_to_attention_tiling.h" |
| 15 | #include "mc2_tiling_case_executor.h" | 16 | #include "mc2_tiling_case_executor.h" |
| 16 | 17 | ||
| 18 | +using Mc2ErrorCodeUT::ExcelErrorReportScope; | ||
| 19 | +using Mc2ErrorCodeUT::ExpectExcelFormalError; | ||
| 20 | + | ||
| 17 | namespace FFNToAttentionUT { | 21 | namespace FFNToAttentionUT { |
| 18 | 22 | ||
| 19 | class FFNToAttentionArch22TilingTest : public testing::Test { | 23 | class FFNToAttentionArch22TilingTest : public testing::Test { |
| @@ -354,4 +358,170 @@ TEST_F(FFNToAttentionArch22TilingTest, RankTableXformatInvalid) | |||
| 354 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | 358 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; |
| 355 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); | 359 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); |
| 356 | } | 360 | } |
| 361 | + | ||
| 362 | +TEST_F(FFNToAttentionArch22TilingTest, InvalidWorldSizeReportsSingleFormalError) | ||
| 363 | +{ | ||
| 364 | + ExcelErrorReportScope reportScope; | ||
| 365 | + struct FFNToAttentionCompileInfo { | ||
| 366 | + } compileInfo; | ||
| 367 | + | ||
| 368 | + gert::TilingContextPara tilingContextPara( | ||
| 369 | + "FFNToAttention", | ||
| 370 | + {{{{1584, 7168}, {1584, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 371 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 372 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 373 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 374 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 375 | + {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 376 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 377 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 378 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 379 | + {"token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 380 | + {"token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9, 7168})}}, | ||
| 381 | + &compileInfo); | ||
| 382 | + | ||
| 383 | + uint64_t expectTilingKey = 2; | ||
| 384 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 385 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 386 | + ExpectExcelFormalError("EZ0026", "world_size", "0"); | ||
| 387 | +} | ||
| 388 | + | ||
| 389 | +TEST_F(FFNToAttentionArch22TilingTest, InvalidGroupReportsSingleFormalError) | ||
| 390 | +{ | ||
| 391 | + ExcelErrorReportScope reportScope; | ||
| 392 | + struct FFNToAttentionCompileInfo { | ||
| 393 | + } compileInfo; | ||
| 394 | + | ||
| 395 | + gert::TilingContextPara tilingContextPara( | ||
| 396 | + "FFNToAttention", | ||
| 397 | + {{{{1584, 7168}, {1584, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 398 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 399 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 400 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 401 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 402 | + {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 403 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 404 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("")}, | ||
| 405 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 406 | + {"token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 407 | + {"token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9, 7168})}}, | ||
| 408 | + &compileInfo); | ||
| 409 | + | ||
| 410 | + uint64_t expectTilingKey = 2; | ||
| 411 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 412 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 413 | + ExpectExcelFormalError("EZ0026", "group", "length=0", "Group name length must be in [1, 127]"); | ||
| 414 | +} | ||
| 415 | +TEST_F(FFNToAttentionArch22TilingTest, GroupLength127ReportsKnownBoundary) | ||
| 416 | +{ | ||
| 417 | + ExcelErrorReportScope reportScope; | ||
| 418 | + struct FFNToAttentionCompileInfo { | ||
| 419 | + } compileInfo; | ||
| 420 | + | ||
| 421 | + gert::TilingContextPara tilingContextPara( | ||
| 422 | + "FFNToAttention", | ||
| 423 | + {{{{1584, 7168}, {1584, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 424 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 425 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 426 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 427 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 428 | + {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 429 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 430 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>(std::string(127, 'g'))}, | ||
| 431 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 432 | + {"token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 433 | + {"token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9, 7168})}}, | ||
| 434 | + &compileInfo); | ||
| 435 | + | ||
| 436 | + uint64_t expectTilingKey = 2; | ||
| 437 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 438 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_SUCCESS, expectTilingKey); | ||
| 439 | + EXPECT_TRUE(ErrorManager::GetInstance().GetRawErrorMessages().empty()); | ||
| 440 | +} | ||
| 441 | + | ||
| 442 | +TEST_F(FFNToAttentionArch22TilingTest, GroupLength128ReportsKnownBoundary) | ||
| 443 | +{ | ||
| 444 | + ExcelErrorReportScope reportScope; | ||
| 445 | + struct FFNToAttentionCompileInfo { | ||
| 446 | + } compileInfo; | ||
| 447 | + | ||
| 448 | + gert::TilingContextPara tilingContextPara( | ||
| 449 | + "FFNToAttention", | ||
| 450 | + {{{{1584, 7168}, {1584, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 451 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 452 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 453 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 454 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 455 | + {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 456 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 457 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>(std::string(128, 'g'))}, | ||
| 458 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 459 | + {"token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 460 | + {"token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9, 7168})}}, | ||
| 461 | + &compileInfo); | ||
| 462 | + | ||
| 463 | + uint64_t expectTilingKey = 2; | ||
| 464 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 465 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 466 | + ExpectExcelFormalError("EZ0026", "group", "length>=128", "Group name length must be in [1, 127]"); | ||
| 467 | +} | ||
| 468 | + | ||
| 469 | +TEST_F(FFNToAttentionArch22TilingTest, GroupLength129ReportsKnownBoundary) | ||
| 470 | +{ | ||
| 471 | + ExcelErrorReportScope reportScope; | ||
| 472 | + struct FFNToAttentionCompileInfo { | ||
| 473 | + } compileInfo; | ||
| 474 | + | ||
| 475 | + gert::TilingContextPara tilingContextPara( | ||
| 476 | + "FFNToAttention", | ||
| 477 | + {{{{1584, 7168}, {1584, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 478 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 479 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 480 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 481 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 482 | + {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 483 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 484 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>(std::string(129, 'g'))}, | ||
| 485 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(16)}, | ||
| 486 | + {"token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 487 | + {"token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9, 7168})}}, | ||
| 488 | + &compileInfo); | ||
| 489 | + | ||
| 490 | + uint64_t expectTilingKey = 2; | ||
| 491 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 492 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 493 | + ExpectExcelFormalError("EZ0026", "group", "length>=128", "Group name length must be in [1, 127]"); | ||
| 494 | +} | ||
| 495 | + | ||
| 496 | +TEST_F(FFNToAttentionArch22TilingTest, MissingWorldSizeUsesPublicAttributeName) | ||
| 497 | +{ | ||
| 498 | + ExcelErrorReportScope reportScope; | ||
| 499 | + struct FFNToAttentionCompileInfo { | ||
| 500 | + } compileInfo; | ||
| 501 | + | ||
| 502 | + gert::TilingContextPara tilingContextPara( | ||
| 503 | + "FFNToAttention", | ||
| 504 | + {{{{1584, 7168}, {1584, 7168}}, ge::DT_FLOAT16, ge::FORMAT_ND}, | ||
| 505 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 506 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 507 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 508 | + {{{1584}, {1584}}, ge::DT_INT32, ge::FORMAT_ND}, | ||
| 509 | + {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 510 | + {{{}, ge::DT_INT64, ge::FORMAT_ND}}, | ||
| 511 | + {{"group", Ops::Transformer::AnyValue::CreateFrom<std::string>("group")}, | ||
| 512 | + {"world_size", Ops::Transformer::AnyValue::CreateFrom<int64_t>(0)}, | ||
| 513 | + {"token_info_table_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9})}, | ||
| 514 | + {"token_data_shape", Ops::Transformer::AnyValue::CreateFrom<std::vector<int64_t>>({1, 16, 9, 7168})}}, | ||
| 515 | + &compileInfo); | ||
| 516 | + | ||
| 517 | + tilingContextPara.attrs_.erase(tilingContextPara.attrs_.begin() + 1, tilingContextPara.attrs_.end()); | ||
| 518 | + Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | ||
| 519 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_FAILED, UINT64_MAX); | ||
| 520 | + const auto errors = ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 521 | + ASSERT_EQ(errors.size(), 1U); | ||
| 522 | + EXPECT_EQ(errors[0].error_id, "EZ0037"); | ||
| 523 | + EXPECT_EQ(errors[0].args_map.at("param_name"), "world_size"); | ||
| 524 | + EXPECT_EQ(errors[0].args_map.at("reason"), "Required attribute world_size is missing; provide this attribute"); | ||
| 525 | +} | ||
| 526 | + | ||
| 357 | } // namespace FFNToAttentionUT | 527 | } // namespace FFNToAttentionUT |
| @@ -137,7 +137,8 @@ static ge::graphStatus GroupedMatMulAlltoAllvExecuteFunc(gert::OpExecuteContext* | |||
| 137 | aclnnGroupedMatMulAlltoAllvV2, gmmX, gmmWeight, sendCountsTensor, recvCountsTensor, mmX, mmWeight, group, | 137 | aclnnGroupedMatMulAlltoAllvV2, gmmX, gmmWeight, sendCountsTensor, recvCountsTensor, mmX, mmWeight, group, |
| 138 | commMode, *epWorldSize, actSendCountsSeqArray, actRecvCountsSeqArray, *transGmmWeight, *transMmWeight, y, mmY); | 138 | commMode, *epWorldSize, actSendCountsSeqArray, actRecvCountsSeqArray, *transGmmWeight, *transMmWeight, y, mmY); |
| 139 | OPS_ERR_IF(apiRet != ge::GRAPH_SUCCESS, | 139 | OPS_ERR_IF(apiRet != ge::GRAPH_SUCCESS, |
| 140 | - OP_LOGE("GroupedMatMulAlltoAllvFallback", "Aclnn api error code %u", apiRet), return ge::GRAPH_FAILED); | 140 | + OP_LOGE_WITHOUT_REPORT("GroupedMatMulAlltoAllvFallback", "Aclnn api error code %u", apiRet), |
| 141 | + return ge::GRAPH_FAILED); | ||
| 141 | return ge::GRAPH_SUCCESS; | 142 | return ge::GRAPH_SUCCESS; |
| 142 | } | 143 | } |
| 143 | 144 | ||
| @@ -13,12 +13,24 @@ | |||
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | +#include <limits> | ||
| 17 | +#include <string> | ||
| 18 | +#include <vector> | ||
| 16 | #include "mc2_log.h" | 19 | #include "mc2_log.h" |
| 17 | #include "register/op_impl_registry.h" | 20 | #include "register/op_impl_registry.h" |
| 18 | #include "common/utils/op_mc2.h" | 21 | #include "common/utils/op_mc2.h" |
| 19 | #include "mc2_moe_utils.h" | 22 | #include "mc2_moe_utils.h" |
| 20 | using namespace ge; | 23 | using namespace ge; |
| 21 | namespace ops { | 24 | namespace ops { |
| 25 | + | ||
| 26 | +static void ReportGroupedInferMetadata(const char* opName, const std::string& reason, const char* code) | ||
| 27 | +{ | ||
| 28 | + // Requested metadata codes need a registration dependency outside this scope. | ||
| 29 | + (void)code; | ||
| 30 | + const char* name = opName == nullptr ? "GroupedMatMulAlltoAllv" : opName; | ||
| 31 | + OP_LOGE(name, "%s", reason.c_str()); | ||
| 32 | +} | ||
| 33 | + | ||
| 22 | static constexpr int64_t FIRST_ELE_SIZE = -1; | 34 | static constexpr int64_t FIRST_ELE_SIZE = -1; |
| 23 | 35 | ||
| 24 | static const size_t INDEX_IN_GMM_X = 0; | 36 | static const size_t INDEX_IN_GMM_X = 0; |
| @@ -46,14 +58,14 @@ static graphStatus CheckDims(const gert::InferShapeContext* context, const gert: | |||
| 46 | { | 58 | { |
| 47 | auto gmmXDimNum = gmmXShape->GetDimNum(); | 59 | auto gmmXDimNum = gmmXShape->GetDimNum(); |
| 48 | auto gmmWeightDimNum = gmmWeightShape->GetDimNum(); | 60 | auto gmmWeightDimNum = gmmWeightShape->GetDimNum(); |
| 49 | - auto result = ge::GRAPH_SUCCESS; | ||
| 50 | if (gmmXDimNum != DIM_NUM_2) { | 61 | if (gmmXDimNum != DIM_NUM_2) { |
| 51 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "Only gmmX with dim 2 is supported."); | 62 | + OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "gmm_x", std::to_string(gmmXDimNum).c_str(), "2"); |
| 52 | - result = ge::GRAPH_FAILED; | 63 | + return ge::GRAPH_FAILED; |
| 53 | } | 64 | } |
| 54 | if (gmmWeightDimNum != DIM_NUM_3) { | 65 | if (gmmWeightDimNum != DIM_NUM_3) { |
| 55 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "Only gmmWeight with dim 3 is supported."); | 66 | + OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "gmm_weight", std::to_string(gmmWeightDimNum).c_str(), |
| 56 | - result = ge::GRAPH_FAILED; | 67 | + "3"); |
| 68 | + return ge::GRAPH_FAILED; | ||
| 57 | } | 69 | } |
| 58 | 70 | ||
| 59 | auto k2 = gmmWeightShape->GetDim(DIM_1); | 71 | auto k2 = gmmWeightShape->GetDim(DIM_1); |
| @@ -61,12 +73,13 @@ static graphStatus CheckDims(const gert::InferShapeContext* context, const gert: | |||
| 61 | if (transGmmWeight) { | 73 | if (transGmmWeight) { |
| 62 | k2 = gmmWeightShape->GetDim(DIM_2); | 74 | k2 = gmmWeightShape->GetDim(DIM_2); |
| 63 | } | 75 | } |
| 64 | - if (k2 != k1) { | 76 | + if (k2 >= 0 && k1 >= 0 && k2 != k1) { |
| 65 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), | 77 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context->GetNodeName(), "gmm_x, gmm_weight", |
| 66 | - "Dim of gmmX and dim of gmmWeight do not match for MatMul"); | 78 | + (std::to_string(k1) + ", " + std::to_string(k2)).c_str(), |
| 67 | - result = ge::GRAPH_FAILED; | 79 | + "Contraction dimensions must match"); |
| 80 | + return ge::GRAPH_FAILED; | ||
| 68 | } | 81 | } |
| 69 | - return result; | 82 | + return ge::GRAPH_SUCCESS; |
| 70 | } | 83 | } |
| 71 | 84 | ||
| 72 | static graphStatus CheckDimsOptional(const gert::InferShapeContext* context, const gert::Shape* mmXShape, | 85 | static graphStatus CheckDimsOptional(const gert::InferShapeContext* context, const gert::Shape* mmXShape, |
| @@ -74,14 +87,13 @@ static graphStatus CheckDimsOptional(const gert::InferShapeContext* context, con | |||
| 74 | { | 87 | { |
| 75 | auto xDimNum = mmXShape->GetDimNum(); | 88 | auto xDimNum = mmXShape->GetDimNum(); |
| 76 | auto mmWeightDimNum = mmWeightShape->GetDimNum(); | 89 | auto mmWeightDimNum = mmWeightShape->GetDimNum(); |
| 77 | - auto result = ge::GRAPH_SUCCESS; | ||
| 78 | if (xDimNum != DIM_NUM_2) { | 90 | if (xDimNum != DIM_NUM_2) { |
| 79 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "Only x with dim 2 is supported."); | 91 | + OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "mm_x", std::to_string(xDimNum).c_str(), "2"); |
| 80 | - result = ge::GRAPH_FAILED; | 92 | + return ge::GRAPH_FAILED; |
| 81 | } | 93 | } |
| 82 | if (mmWeightDimNum != DIM_NUM_2) { | 94 | if (mmWeightDimNum != DIM_NUM_2) { |
| 83 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "Only mmWeight with dim 2 is supported."); | 95 | + OP_LOGE_FOR_INVALID_SHAPEDIM(context->GetNodeName(), "mm_weight", std::to_string(mmWeightDimNum).c_str(), "2"); |
| 84 | - result = ge::GRAPH_FAILED; | 96 | + return ge::GRAPH_FAILED; |
| 85 | } | 97 | } |
| 86 | 98 | ||
| 87 | auto k2 = mmWeightShape->GetDim(DIM_0); | 99 | auto k2 = mmWeightShape->GetDim(DIM_0); |
| @@ -89,12 +101,13 @@ static graphStatus CheckDimsOptional(const gert::InferShapeContext* context, con | |||
| 89 | if (transMmWeight) { | 101 | if (transMmWeight) { |
| 90 | k2 = mmWeightShape->GetDim(DIM_1); | 102 | k2 = mmWeightShape->GetDim(DIM_1); |
| 91 | } | 103 | } |
| 92 | - if (k2 != k1) { | 104 | + if (k2 >= 0 && k1 >= 0 && k2 != k1) { |
| 93 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), | 105 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context->GetNodeName(), "mm_x, mm_weight", |
| 94 | - "Dim of x and dim of mmWeight do not match for MatMul"); | 106 | + (std::to_string(k1) + ", " + std::to_string(k2)).c_str(), |
| 95 | - result = ge::GRAPH_FAILED; | 107 | + "Contraction dimensions must match"); |
| 108 | + return ge::GRAPH_FAILED; | ||
| 96 | } | 109 | } |
| 97 | - return result; | 110 | + return ge::GRAPH_SUCCESS; |
| 98 | } | 111 | } |
| 99 | 112 | ||
| 100 | static ge::graphStatus InferGMMOutputShape(const gert::InferShapeContext* context, gert::Shape* gmmYShape, | 113 | static ge::graphStatus InferGMMOutputShape(const gert::InferShapeContext* context, gert::Shape* gmmYShape, |
| @@ -106,20 +119,40 @@ static ge::graphStatus InferGMMOutputShape(const gert::InferShapeContext* contex | |||
| 106 | gmmYShape->SetDim(DIM_0, FIRST_ELE_SIZE); | 119 | gmmYShape->SetDim(DIM_0, FIRST_ELE_SIZE); |
| 107 | gmmYShape->SetDim(DIM_1, FIRST_ELE_SIZE); | 120 | gmmYShape->SetDim(DIM_1, FIRST_ELE_SIZE); |
| 108 | if (e != FIRST_ELE_SIZE) { | 121 | if (e != FIRST_ELE_SIZE) { |
| 122 | + OPS_CHECK(e < 0 || e > std::numeric_limits<int64_t>::max() / *epWorldSizePtr, | ||
| 123 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( | ||
| 124 | + context->GetNodeName(), "gmm_weight", std::to_string(e).c_str(), | ||
| 125 | + "Expert count must be nonnegative and its product with ep_world_size must fit int64"), | ||
| 126 | + return ge::GRAPH_FAILED); | ||
| 109 | int64_t arraySize = e * (*epWorldSizePtr); | 127 | int64_t arraySize = e * (*epWorldSizePtr); |
| 110 | - OPS_ERR_IF(sendCountsPtr->GetSize() < static_cast<size_t>(arraySize), | 128 | + OPS_ERR_IF( |
| 111 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), | 129 | + sendCountsPtr->GetSize() < static_cast<size_t>(arraySize), |
| 112 | - "sendCounts size should not be smaller than epWorldSize * e."), | 130 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "send_counts", |
| 113 | - return ge::GRAPH_FAILED); | 131 | + ("element count=" + std::to_string(sendCountsPtr->GetSize()) + |
| 114 | - OPS_ERR_IF(recvCountsPtr->GetSize() < static_cast<size_t>(arraySize), | 132 | + ", required at least=" + std::to_string(arraySize)) |
| 115 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), | 133 | + .c_str()), |
| 116 | - "recvCounts size should not be smaller than epWorldSize * e."), | 134 | + return ge::GRAPH_FAILED); |
| 117 | - return ge::GRAPH_FAILED); | 135 | + OPS_ERR_IF( |
| 136 | + recvCountsPtr->GetSize() < static_cast<size_t>(arraySize), | ||
| 137 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "recv_counts", | ||
| 138 | + ("element count=" + std::to_string(recvCountsPtr->GetSize()) + | ||
| 139 | + ", required at least=" + std::to_string(arraySize)) | ||
| 140 | + .c_str()), | ||
| 141 | + return ge::GRAPH_FAILED); | ||
| 118 | OPS_ERR_IF(recvCountsPtr->GetData() == nullptr, | 142 | OPS_ERR_IF(recvCountsPtr->GetData() == nullptr, |
| 119 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "recvCounts data is nullptr."), | 143 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), |
| 144 | + "ContinuousVector inline recv_counts storage is unexpectedly null"), | ||
| 120 | return ge::GRAPH_FAILED); | 145 | return ge::GRAPH_FAILED); |
| 121 | for (int64_t i = 0UL; i < arraySize; i++) { | 146 | for (int64_t i = 0UL; i < arraySize; i++) { |
| 122 | - bsk += static_cast<const int64_t*>(recvCountsPtr->GetData())[i]; | 147 | + const int64_t count = static_cast<const int64_t*>(recvCountsPtr->GetData())[i]; |
| 148 | + OPS_CHECK(count < 0 || count > std::numeric_limits<int64_t>::max() - bsk, | ||
| 149 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 150 | + context->GetNodeName(), "recv_counts", | ||
| 151 | + ("index=" + std::to_string(i) + ", actual=" + std::to_string(count) + | ||
| 152 | + ", prior sum=" + std::to_string(bsk) + "; expected nonnegative counts with int64 sum") | ||
| 153 | + .c_str()), | ||
| 154 | + return ge::GRAPH_FAILED); | ||
| 155 | + bsk += count; | ||
| 123 | } | 156 | } |
| 124 | gmmYShape->SetDim(DIM_0, bsk); | 157 | gmmYShape->SetDim(DIM_0, bsk); |
| 125 | gmmYShape->SetDim(DIM_1, n1); | 158 | gmmYShape->SetDim(DIM_1, n1); |
| @@ -131,13 +164,16 @@ static ge::graphStatus InferMMOutputShape(const gert::InferShapeContext* context | |||
| 131 | const gert::Shape* mmWeightShape, const bool* transMmWeightPtr, | 164 | const gert::Shape* mmWeightShape, const bool* transMmWeightPtr, |
| 132 | gert::Shape* mmYShape) | 165 | gert::Shape* mmYShape) |
| 133 | { | 166 | { |
| 167 | + if (mmXShape == nullptr && mmWeightShape == nullptr && mmYShape == nullptr) { | ||
| 168 | + return ge::GRAPH_SUCCESS; | ||
| 169 | + } | ||
| 134 | OPS_ERR_IF(mmYShape == nullptr, | 170 | OPS_ERR_IF(mmYShape == nullptr, |
| 135 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "The shape of mm_y is nullptr."), | 171 | + ReportGroupedInferMetadata(context->GetNodeName(), "Output shape holder mm_y is absent", "EZ1014"), |
| 136 | return ge::GRAPH_FAILED); | 172 | return ge::GRAPH_FAILED); |
| 137 | mmYShape->SetDimNum(DIM_NUM_0); | 173 | mmYShape->SetDimNum(DIM_NUM_0); |
| 138 | if ((mmWeightShape != nullptr) && (mmXShape != nullptr) && (mmYShape != nullptr) && (transMmWeightPtr != nullptr)) { | 174 | if ((mmWeightShape != nullptr) && (mmXShape != nullptr) && (mmYShape != nullptr) && (transMmWeightPtr != nullptr)) { |
| 139 | OPS_ERR_IF(CheckDimsOptional(context, mmXShape, mmWeightShape, *transMmWeightPtr) != ge::GRAPH_SUCCESS, | 175 | OPS_ERR_IF(CheckDimsOptional(context, mmXShape, mmWeightShape, *transMmWeightPtr) != ge::GRAPH_SUCCESS, |
| 140 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "CheckDimsOptional failed."), | 176 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "CheckDimsOptional failed."), |
| 141 | return ge::GRAPH_FAILED); | 177 | return ge::GRAPH_FAILED); |
| 142 | int64_t bs = mmXShape->GetDim(DIM_0); | 178 | int64_t bs = mmXShape->GetDim(DIM_0); |
| 143 | mmYShape->SetDimNum(DIM_NUM_2); | 179 | mmYShape->SetDimNum(DIM_NUM_2); |
| @@ -154,6 +190,10 @@ static ge::graphStatus InferMMOutputShape(const gert::InferShapeContext* context | |||
| 154 | 190 | ||
| 155 | static ge::graphStatus InferShapeGroupedMatMulAlltoAllv(gert::InferShapeContext* context) | 191 | static ge::graphStatus InferShapeGroupedMatMulAlltoAllv(gert::InferShapeContext* context) |
| 156 | { | 192 | { |
| 193 | + if (context == nullptr) { | ||
| 194 | + ReportGroupedInferMetadata("grouped_mat_mul_allto_allv", "Inference context is null", "EZ1014"); | ||
| 195 | + return GRAPH_FAILED; | ||
| 196 | + } | ||
| 157 | auto* gmmXShape = context->GetInputShape(INDEX_IN_GMM_X); | 197 | auto* gmmXShape = context->GetInputShape(INDEX_IN_GMM_X); |
| 158 | auto* gmmWeightShape = context->GetInputShape(INDEX_IN_GMM_WEIGHT); | 198 | auto* gmmWeightShape = context->GetInputShape(INDEX_IN_GMM_WEIGHT); |
| 159 | auto* mmXShape = context->GetOptionalInputShape(INDEX_IN_MM_X); | 199 | auto* mmXShape = context->GetOptionalInputShape(INDEX_IN_MM_X); |
| @@ -161,24 +201,50 @@ static ge::graphStatus InferShapeGroupedMatMulAlltoAllv(gert::InferShapeContext* | |||
| 161 | auto* gmmYShape = context->GetOutputShape(INDEX_OUT_GMM_Y); | 201 | auto* gmmYShape = context->GetOutputShape(INDEX_OUT_GMM_Y); |
| 162 | auto* mmYShape = context->GetOutputShape(INDEX_OUT_MM_Y); | 202 | auto* mmYShape = context->GetOutputShape(INDEX_OUT_MM_Y); |
| 163 | 203 | ||
| 164 | - OPS_CHECK_NULL_WITH_CONTEXT(context, gmmXShape); | 204 | + OPS_CHECK(gmmXShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "gmm_x"), return GRAPH_FAILED); |
| 165 | - OPS_CHECK_NULL_WITH_CONTEXT(context, gmmWeightShape); | 205 | + OPS_CHECK(gmmWeightShape == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "gmm_weight"), |
| 166 | - OPS_CHECK_NULL_WITH_CONTEXT(context, gmmYShape); | 206 | + return GRAPH_FAILED); |
| 207 | + OPS_CHECK(gmmYShape == nullptr, | ||
| 208 | + ReportGroupedInferMetadata(context->GetNodeName(), "Output shape holder y is absent", "EZ1014"), | ||
| 209 | + return GRAPH_FAILED); | ||
| 167 | 210 | ||
| 168 | auto* attrs = context->GetAttrs(); | 211 | auto* attrs = context->GetAttrs(); |
| 212 | + OPS_CHECK(attrs == nullptr, | ||
| 213 | + ReportGroupedInferMetadata(context->GetNodeName(), "RuntimeAttrs holder is absent", "EZ1014"), | ||
| 214 | + return GRAPH_FAILED); | ||
| 169 | auto* epWorldSizePtr = attrs->GetAttrPointer<int64_t>(INDEX_ATTR_EP_WORLD_SIZE); | 215 | auto* epWorldSizePtr = attrs->GetAttrPointer<int64_t>(INDEX_ATTR_EP_WORLD_SIZE); |
| 170 | auto* recvCountsPtr = attrs->GetAttrPointer<gert::ContinuousVector>(INDEX_ATTR_RECV_COUNTS); | 216 | auto* recvCountsPtr = attrs->GetAttrPointer<gert::ContinuousVector>(INDEX_ATTR_RECV_COUNTS); |
| 171 | auto* sendCountsPtr = attrs->GetAttrPointer<gert::ContinuousVector>(INDEX_ATTR_SEND_COUNTS); | 217 | auto* sendCountsPtr = attrs->GetAttrPointer<gert::ContinuousVector>(INDEX_ATTR_SEND_COUNTS); |
| 172 | auto* transGmmWeightPtr = attrs->GetAttrPointer<bool>(INDEX_ATTR_TRANS_GMM_WEIGHT_INDEX); | 218 | auto* transGmmWeightPtr = attrs->GetAttrPointer<bool>(INDEX_ATTR_TRANS_GMM_WEIGHT_INDEX); |
| 173 | auto* transMmWeightPtr = attrs->GetAttrPointer<bool>(INDEX_ATTR_TRANS_MM_WEIGHT_INDEX); | 219 | auto* transMmWeightPtr = attrs->GetAttrPointer<bool>(INDEX_ATTR_TRANS_MM_WEIGHT_INDEX); |
| 174 | 220 | ||
| 175 | - OPS_CHECK_NULL_WITH_CONTEXT(context, epWorldSizePtr); | 221 | + OPS_CHECK(epWorldSizePtr == nullptr, |
| 176 | - OPS_CHECK_NULL_WITH_CONTEXT(context, recvCountsPtr); | 222 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "ep_world_size", |
| 177 | - OPS_CHECK_NULL_WITH_CONTEXT(context, sendCountsPtr); | 223 | + "Required attribute is absent"), |
| 178 | - OPS_CHECK_NULL_WITH_CONTEXT(context, transGmmWeightPtr); | 224 | + return GRAPH_FAILED); |
| 225 | + OPS_CHECK( | ||
| 226 | + recvCountsPtr == nullptr, | ||
| 227 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "recv_counts", "Required attribute is absent"), | ||
| 228 | + return GRAPH_FAILED); | ||
| 229 | + OPS_CHECK( | ||
| 230 | + sendCountsPtr == nullptr, | ||
| 231 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(context->GetNodeName(), "send_counts", "Required attribute is absent"), | ||
| 232 | + return GRAPH_FAILED); | ||
| 233 | + OPS_CHECK(transGmmWeightPtr == nullptr, | ||
| 234 | + ReportGroupedInferMetadata(context->GetNodeName(), "Default trans_gmm_weight is absent from RuntimeAttrs", | ||
| 235 | + "EZ1014"), | ||
| 236 | + return GRAPH_FAILED); | ||
| 237 | + OPS_CHECK(*epWorldSizePtr <= 0, | ||
| 238 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON( | ||
| 239 | + context->GetNodeName(), "ep_world_size", | ||
| 240 | + ("actual=" + std::to_string(*epWorldSizePtr) + "; expected positive world size").c_str()), | ||
| 241 | + return GRAPH_FAILED); | ||
| 242 | + OPS_CHECK(mmXShape != nullptr && mmWeightShape != nullptr && transMmWeightPtr == nullptr, | ||
| 243 | + ReportGroupedInferMetadata(context->GetNodeName(), "Default trans_mm_weight is absent from RuntimeAttrs", | ||
| 244 | + "EZ1014"), | ||
| 245 | + return GRAPH_FAILED); | ||
| 179 | OPS_ERR_IF(CheckDims(context, gmmXShape, gmmWeightShape, *transGmmWeightPtr) != ge::GRAPH_SUCCESS, | 246 | OPS_ERR_IF(CheckDims(context, gmmXShape, gmmWeightShape, *transGmmWeightPtr) != ge::GRAPH_SUCCESS, |
| 180 | - VECTOR_INFER_SHAPE_INNER_ERR_REPORT(context->GetNodeName(), "CheckDims failed."), | 247 | + OP_LOGE_WITHOUT_REPORT(context->GetNodeName(), "CheckDims failed."), return ge::GRAPH_FAILED); |
| 181 | - return ge::GRAPH_FAILED); | ||
| 182 | 248 | ||
| 183 | int64_t bsk = 0; | 249 | int64_t bsk = 0; |
| 184 | int64_t e = gmmWeightShape->GetDim(DIM_0); | 250 | int64_t e = gmmWeightShape->GetDim(DIM_0); |
| @@ -198,9 +264,24 @@ static ge::graphStatus InferShapeGroupedMatMulAlltoAllv(gert::InferShapeContext* | |||
| 198 | 264 | ||
| 199 | static ge::graphStatus InferDataTypeGroupedMatMulAlltoAllv(gert::InferDataTypeContext* context) | 265 | static ge::graphStatus InferDataTypeGroupedMatMulAlltoAllv(gert::InferDataTypeContext* context) |
| 200 | { | 266 | { |
| 267 | + if (context == nullptr) { | ||
| 268 | + ReportGroupedInferMetadata("grouped_mat_mul_allto_allv", "Inference context is null", "EZ1009"); | ||
| 269 | + return GRAPH_FAILED; | ||
| 270 | + } | ||
| 201 | auto dType = context->GetInputDataType(INDEX_IN_GMM_X); | 271 | auto dType = context->GetInputDataType(INDEX_IN_GMM_X); |
| 202 | - context->SetOutputDataType(INDEX_OUT_GMM_Y, dType); | 272 | + OPS_CHECK(dType == DT_UNDEFINED, |
| 203 | - context->SetOutputDataType(INDEX_OUT_MM_Y, dType); | 273 | + ReportGroupedInferMetadata(context->GetNodeName(), "gmm_x dtype metadata is absent", "EZ1009"), |
| 274 | + return GRAPH_FAILED); | ||
| 275 | + OPS_CHECK(context->SetOutputDataType(INDEX_OUT_GMM_Y, dType) != GRAPH_SUCCESS, | ||
| 276 | + ReportGroupedInferMetadata(context->GetNodeName(), "Output dtype slot y is absent", "EZ1009"), | ||
| 277 | + return GRAPH_FAILED); | ||
| 278 | + const bool hasSharedMm = context->GetOptionalInputDataType(INDEX_IN_MM_X) != DT_UNDEFINED && | ||
| 279 | + context->GetOptionalInputDataType(INDEX_IN_MM_WEIGHT) != DT_UNDEFINED; | ||
| 280 | + if (hasSharedMm || context->GetComputeNodeOutputNum() > INDEX_OUT_MM_Y) { | ||
| 281 | + OPS_CHECK(context->SetOutputDataType(INDEX_OUT_MM_Y, dType) != GRAPH_SUCCESS, | ||
| 282 | + ReportGroupedInferMetadata(context->GetNodeName(), "Output dtype slot mm_y is absent", "EZ1009"), | ||
| 283 | + return GRAPH_FAILED); | ||
| 284 | + } | ||
| 204 | return ge::GRAPH_SUCCESS; | 285 | return ge::GRAPH_SUCCESS; |
| 205 | } | 286 | } |
| 206 | 287 | ||
Mmc2/grouped_mat_mul_allto_allv/op_host/op_tiling/arch22/grouped_mat_mul_allto_allv_mte_tiling.cpp+94-31
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "../../../op_kernel/arch22/grouped_mat_mul_allto_allv_mte_tiling.h" | 16 | #include "../../../op_kernel/arch22/grouped_mat_mul_allto_allv_mte_tiling.h" |
| 17 | #include "op_mc2.h" | 17 | #include "op_mc2.h" |
| 18 | #include "mc2_log.h" | 18 | #include "mc2_log.h" |
| 19 | +#include "mc2_tiling_failure_report.h" | ||
| 19 | #include "op_host/tiling_templates_registry.h" | 20 | #include "op_host/tiling_templates_registry.h" |
| 20 | #include "op_host/op_tiling/mc2_tiling_utils.h" | 21 | #include "op_host/op_tiling/mc2_tiling_utils.h" |
| 21 | #include "mc2_comm_utils.h" | 22 | #include "mc2_comm_utils.h" |
| @@ -72,7 +73,13 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::DoOpTiling() | |||
| 72 | // AllToAllMatmul/MatmulAlltoAll scheduling contract so every participating | 73 | // AllToAllMatmul/MatmulAlltoAll scheduling contract so every participating |
| 73 | // core is launched as one batch. | 74 | // core is launched as one batch. |
| 74 | constexpr uint32_t batchMode = 1U; | 75 | constexpr uint32_t batchMode = 1U; |
| 75 | - MC2_CHECK_LOG_RET(opName_, context_->SetScheduleMode(batchMode)); | 76 | + const auto scheduleRet = context_->SetScheduleMode(batchMode); |
| 77 | + if (scheduleRet != ge::GRAPH_SUCCESS) { | ||
| 78 | + Mc2Error::ReportTilingFailure( | ||
| 79 | + opName_, | ||
| 80 | + "SetScheduleMode(1) failed; expected writable schedule output slot; rc=" + std::to_string(scheduleRet)); | ||
| 81 | + return ge::GRAPH_FAILED; | ||
| 82 | + } | ||
| 76 | { | 83 | { |
| 77 | const ge::graphStatus status = CheckAndSetInputOutputInfo(); | 84 | const ge::graphStatus status = CheckAndSetInputOutputInfo(); |
| 78 | if (status != ge::GRAPH_SUCCESS) { | 85 | if (status != ge::GRAPH_SUCCESS) { |
| @@ -565,12 +572,28 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::GetPlatformInfo() | |||
| 565 | return status; | 572 | return status; |
| 566 | } | 573 | } |
| 567 | auto platformInfo = context_->GetPlatformInfo(); | 574 | auto platformInfo = context_->GetPlatformInfo(); |
| 568 | - OP_TILING_CHECK(platformInfo == nullptr, OP_LOGE(opName_, "Failed to get platform info."), return ge::GRAPH_FAILED); | 575 | + // The shared GetPlatformInfo above guarantees a non-null platform. |
| 576 | + | ||
| 569 | platform_ascendc::PlatformAscendC ascendcPlatform(platformInfo); | 577 | platform_ascendc::PlatformAscendC ascendcPlatform(platformInfo); |
| 570 | npuArch_ = ascendcPlatform.GetCurNpuArch(); | 578 | npuArch_ = ascendcPlatform.GetCurNpuArch(); |
| 571 | std::string socVersion; | 579 | std::string socVersion; |
| 572 | (void)platformInfo->GetPlatformResWithLock("version", "Short_SoC_version", socVersion); | 580 | (void)platformInfo->GetPlatformResWithLock("version", "Short_SoC_version", socVersion); |
| 573 | isA3_ = socVersion == "Ascend910_93"; | 581 | isA3_ = socVersion == "Ascend910_93"; |
| 582 | + const auto* attrs = context_->GetAttrs(); | ||
| 583 | + if (attrs == nullptr) { | ||
| 584 | + Mc2Error::ReportTilingFailure(opName_, "GetAttrs returned null; expected materialized RuntimeAttrs"); | ||
| 585 | + return ge::GRAPH_FAILED; | ||
| 586 | + } | ||
| 587 | + const char* commMode = attrs->GetAttrPointer<char>(ATTR_COMM_MODE); | ||
| 588 | + if (commMode == nullptr) { | ||
| 589 | + Mc2Error::ReportTilingFailure(opName_, "GetAttrPointer(comm_mode) returned null; expected default storage"); | ||
| 590 | + return ge::GRAPH_FAILED; | ||
| 591 | + } | ||
| 592 | + if (std::strcmp(commMode, "aiv") == 0 && (npuArch_ == Ops::Base::DAV_3510 || npuArch_ == Ops::Base::DAV_9201)) { | ||
| 593 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(opName_, "comm_mode", commMode, | ||
| 594 | + ("aiv requires Atlas A2/A3; actual SoC=" + socVersion).c_str()); | ||
| 595 | + return ge::GRAPH_FAILED; | ||
| 596 | + } | ||
| 574 | return ge::GRAPH_SUCCESS; | 597 | return ge::GRAPH_SUCCESS; |
| 575 | } | 598 | } |
| 576 | 599 | ||
| @@ -601,19 +624,39 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::FillCommTiling( | |||
| 601 | MC2KernelTemplate::GroupedMatMulAlltoAllvMteTilingData& outData) const | 624 | MC2KernelTemplate::GroupedMatMulAlltoAllvMteTilingData& outData) const |
| 602 | { | 625 | { |
| 603 | const gert::RuntimeAttrs* attrs = context_->GetAttrs(); | 626 | const gert::RuntimeAttrs* attrs = context_->GetAttrs(); |
| 604 | - OP_TILING_CHECK(attrs == nullptr, OP_LOGE_WITH_INVALID_INPUT(opName_, "attrs"), return ge::GRAPH_FAILED); | 627 | + OP_TILING_CHECK(attrs == nullptr, Mc2Error::ReportTilingFailure(opName_, "FillCommTiling: missing RuntimeAttrs"), |
| 628 | + return ge::GRAPH_FAILED); | ||
| 605 | const char* group = attrs->GetAttrPointer<char>(ATTR_GROUP_INDEX); | 629 | const char* group = attrs->GetAttrPointer<char>(ATTR_GROUP_INDEX); |
| 606 | - OP_TILING_CHECK(group == nullptr, OP_LOGE_WITH_INVALID_INPUT(opName_, "group"), return ge::GRAPH_FAILED); | 630 | + if (group == nullptr || strnlen(group, 128) >= 128) { |
| 631 | + OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON(opName_, "group", | ||
| 632 | + "required group name must be present and shorter than 128 bytes"); | ||
| 633 | + return ge::GRAPH_FAILED; | ||
| 634 | + } | ||
| 635 | + const char* ascendHome = std::getenv("ASCEND_HOME_PATH"); | ||
| 636 | + if (ascendHome == nullptr || ascendHome[0] == '\0') { | ||
| 637 | + OP_LOGE(opName_, "FillCommTiling failed: required environment variable ASCEND_HOME_PATH is absent or empty"); | ||
| 638 | + return ge::GRAPH_FAILED; | ||
| 639 | + } | ||
| 607 | outData.isA3 = static_cast<uint32_t>(isA3_); | 640 | outData.isA3 = static_cast<uint32_t>(isA3_); |
| 608 | const uint32_t opType = isA3_ ? OP_TYPE_ALL_TO_ALL : OP_TYPE_MULTI_PUT; | 641 | const uint32_t opType = isA3_ ? OP_TYPE_ALL_TO_ALL : OP_TYPE_MULTI_PUT; |
| 609 | const std::string& algConfig = isA3_ ? A3_MTE_HCCL_ALG_CONFIG : A2_MTE_HCCL_ALG_CONFIG; | 642 | const std::string& algConfig = isA3_ ? A3_MTE_HCCL_ALG_CONFIG : A2_MTE_HCCL_ALG_CONFIG; |
| 610 | Mc2CcTilingConfig mc2InitConfig(group, opType, algConfig); | 643 | Mc2CcTilingConfig mc2InitConfig(group, opType, algConfig); |
| 611 | - OP_TILING_CHECK(mc2InitConfig.SetCommEngine(Mc2Comm::ENGINE_MTE) != 0, | 644 | + OP_TILING_CHECK( |
| 612 | - OP_LOGE(opName_, "Failed to select the MTE communication engine."), return ge::GRAPH_FAILED); | 645 | + mc2InitConfig.SetCommEngine(Mc2Comm::ENGINE_MTE) != 0, |
| 613 | - OP_TILING_CHECK(mc2InitConfig.GetTiling(outData.mc2InitTiling) != 0, | 646 | + OP_LOGE_WITHOUT_REPORT( |
| 614 | - OP_LOGE(opName_, "Failed to generate the MTE Mc2InitTiling header."), return ge::GRAPH_FAILED); | 647 | + opName_, "SetCommEngine invariant failed; SDK implementation only assigns ENGINE_MTE and returns success"), |
| 615 | - OP_TILING_CHECK(mc2InitConfig.GetTiling(outData.mc2CcTiling) != 0, | 648 | + return ge::GRAPH_FAILED); |
| 616 | - OP_LOGE(opName_, "Failed to generate the MTE Mc2CcTiling descriptor."), return ge::GRAPH_FAILED); | 649 | + const auto initRet = mc2InitConfig.GetTiling(outData.mc2InitTiling); |
| 650 | + if (initRet != 0) { | ||
| 651 | + Mc2Error::ReportTilingFailure(opName_, "Mc2InitTiling could not obtain required rtGetSocVersion from " + | ||
| 652 | + std::string(ascendHome) + | ||
| 653 | + "/lib64/libruntime.so; rc=" + std::to_string(initRet)); | ||
| 654 | + return ge::GRAPH_FAILED; | ||
| 655 | + } | ||
| 656 | + OP_TILING_CHECK( | ||
| 657 | + mc2InitConfig.GetTiling(outData.mc2CcTiling) != 0, | ||
| 658 | + OP_LOGE_WITHOUT_REPORT(opName_, "Mc2CcTiling invariant failed after group and fixed-algorithm validation"), | ||
| 659 | + return ge::GRAPH_FAILED); | ||
| 617 | OP_TILING_CHECK(mc2tiling::GetCclBufferSize(group, &outData.commBufferSize, opName_) != ge::GRAPH_SUCCESS, | 660 | OP_TILING_CHECK(mc2tiling::GetCclBufferSize(group, &outData.commBufferSize, opName_) != ge::GRAPH_SUCCESS, |
| 618 | OP_LOGE_WITHOUT_REPORT(opName_, "Failed to get CCL buffer size for MTE communication."), | 661 | OP_LOGE_WITHOUT_REPORT(opName_, "Failed to get CCL buffer size for MTE communication."), |
| 619 | return ge::GRAPH_FAILED); | 662 | return ge::GRAPH_FAILED); |
| @@ -628,14 +671,16 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::CheckCommBuffer( | |||
| 628 | MC2KernelTemplate::Gmma2avMteTiling::COUNT_TABLE_ALIGNMENT_BYTES); | 671 | MC2KernelTemplate::Gmma2avMteTiling::COUNT_TABLE_ALIGNMENT_BYTES); |
| 629 | const uint64_t sendCountStagingBytes = MC2KernelTemplate::Gmma2avMteTiling::SEND_COUNT_STAGING_FROM_TAIL - | 672 | const uint64_t sendCountStagingBytes = MC2KernelTemplate::Gmma2avMteTiling::SEND_COUNT_STAGING_FROM_TAIL - |
| 630 | MC2KernelTemplate::Gmma2avMteTiling::SYNC_REGION_FROM_TAIL; | 673 | MC2KernelTemplate::Gmma2avMteTiling::SYNC_REGION_FROM_TAIL; |
| 631 | - OP_TILING_CHECK(countMatrixBytes > sendCountStagingBytes, | 674 | + OP_TILING_CHECK( |
| 632 | - OP_LOGE(opName_, "MTE send-count staging requires %lu bytes, but its CCL region has %lu bytes.", | 675 | + countMatrixBytes > sendCountStagingBytes, |
| 633 | - countMatrixBytes, sendCountStagingBytes), | 676 | + OP_LOGE_WITHOUT_REPORT(opName_, "MTE send-count staging requires %lu bytes, but its CCL region has %lu bytes.", |
| 634 | - return ge::GRAPH_FAILED); | 677 | + countMatrixBytes, sendCountStagingBytes), |
| 678 | + return ge::GRAPH_FAILED); | ||
| 635 | const uint64_t syncBytes = MC2KernelTemplate::Gmma2avMteTiling::FIXED_SYNC_BYTES; | 679 | const uint64_t syncBytes = MC2KernelTemplate::Gmma2avMteTiling::FIXED_SYNC_BYTES; |
| 636 | OP_TILING_CHECK(syncBytes > MC2KernelTemplate::Gmma2avMteTiling::CCL_TAIL_SAFETY_BYTES, | 680 | OP_TILING_CHECK(syncBytes > MC2KernelTemplate::Gmma2avMteTiling::CCL_TAIL_SAFETY_BYTES, |
| 637 | - OP_LOGE(opName_, "MTE fixed sync layout requires %lu bytes, but the CCL tail region has %lu bytes.", | 681 | + OP_LOGE_WITHOUT_REPORT( |
| 638 | - syncBytes, MC2KernelTemplate::Gmma2avMteTiling::CCL_TAIL_SAFETY_BYTES), | 682 | + opName_, "MTE fixed sync layout requires %lu bytes, but the CCL tail region has %lu bytes.", |
| 683 | + syncBytes, MC2KernelTemplate::Gmma2avMteTiling::CCL_TAIL_SAFETY_BYTES), | ||
| 639 | return ge::GRAPH_FAILED); | 684 | return ge::GRAPH_FAILED); |
| 640 | const uint64_t dtypeSize = mc2tiling::GetDataTypeSize(opName_, localParams_.gmmYDtype); | 685 | const uint64_t dtypeSize = mc2tiling::GetDataTypeSize(opName_, localParams_.gmmYDtype); |
| 641 | const uint64_t sendBytes = localParams_.A * localParams_.N1 * dtypeSize; | 686 | const uint64_t sendBytes = localParams_.A * localParams_.N1 * dtypeSize; |
| @@ -693,17 +738,31 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::FinishPostTiling( | |||
| 693 | outData.cocTiling.swizzlCount = MC2KernelTemplate::Gmma2avMteTiling::SWIZZLE_COUNT; | 738 | outData.cocTiling.swizzlCount = MC2KernelTemplate::Gmma2avMteTiling::SWIZZLE_COUNT; |
| 694 | outData.cocTiling.swizzlDirect = MC2KernelTemplate::Gmma2avMteTiling::SWIZZLE_DIRECTION; | 739 | outData.cocTiling.swizzlDirect = MC2KernelTemplate::Gmma2avMteTiling::SWIZZLE_DIRECTION; |
| 695 | 740 | ||
| 741 | + auto* raw = context_->GetRawTilingData(); | ||
| 742 | + if (raw == nullptr || raw->GetData() == nullptr) { | ||
| 743 | + Mc2Error::ReportTilingFailure(opName_, | ||
| 744 | + "FinishPostTiling: missing raw tiling holder/data; expected writable storage"); | ||
| 745 | + return ge::GRAPH_FAILED; | ||
| 746 | + } | ||
| 747 | + size_t tilingBufCap = raw->GetCapacity(); | ||
| 748 | + if (tilingBufCap < sizeof(outData)) { | ||
| 749 | + Mc2Error::ReportTilingFailure(opName_, "FinishPostTiling capacity=" + std::to_string(tilingBufCap) + | ||
| 750 | + "; required=" + std::to_string(sizeof(outData)) + " bytes"); | ||
| 751 | + return ge::GRAPH_FAILED; | ||
| 752 | + } | ||
| 696 | auto* outTilingData = context_->GetTilingData<MC2KernelTemplate::GroupedMatMulAlltoAllvMteTilingData>(); | 753 | auto* outTilingData = context_->GetTilingData<MC2KernelTemplate::GroupedMatMulAlltoAllvMteTilingData>(); |
| 697 | - size_t tilingBufCap = context_->GetRawTilingData()->GetCapacity(); | ||
| 698 | - OP_TILING_CHECK(outTilingData == nullptr, OP_LOGE(opName_, "Failed to get MTE tiling data from context"), | ||
| 699 | - return ge::GRAPH_FAILED); | ||
| 700 | OP_TILING_CHECK( | 754 | OP_TILING_CHECK( |
| 701 | - tilingBufCap < sizeof(outData), | 755 | + outTilingData == nullptr, |
| 702 | - OP_LOGE(opName_, "TilingBuffer too small, capacity = %zu, need = %zu.", tilingBufCap, sizeof(outData)), | 756 | + Mc2Error::ReportTilingFailure( |
| 757 | + opName_, "GetTilingData returned null after holder/capacity validation; expected writable MTE storage"), | ||
| 703 | return ge::GRAPH_FAILED); | 758 | return ge::GRAPH_FAILED); |
| 759 | + | ||
| 704 | static_assert(sizeof(outData) % sizeof(uint64_t) == 0U, "MTE tiling data must be 8-byte aligned"); | 760 | static_assert(sizeof(outData) % sizeof(uint64_t) == 0U, "MTE tiling data must be 8-byte aligned"); |
| 705 | errno_t ret = memcpy_s(outTilingData, tilingBufCap, &outData, sizeof(outData)); | 761 | errno_t ret = memcpy_s(outTilingData, tilingBufCap, &outData, sizeof(outData)); |
| 706 | - OP_TILING_CHECK(ret != EOK, OP_LOGE(opName_, "postTiling: memcpy_s failed with ret=%d.", ret), | 762 | + OP_TILING_CHECK(ret != EOK, |
| 763 | + Mc2Error::ReportTilingFailure( | ||
| 764 | + opName_, "FinishPostTiling memcpy_s failed; rc=" + std::to_string(ret) + "; capacity=" + | ||
| 765 | + std::to_string(tilingBufCap) + "; required=" + std::to_string(sizeof(outData))), | ||
| 707 | return ge::GRAPH_FAILED); | 766 | return ge::GRAPH_FAILED); |
| 708 | context_->GetRawTilingData()->SetDataSize(sizeof(outData)); | 767 | context_->GetRawTilingData()->SetDataSize(sizeof(outData)); |
| 709 | return ge::GRAPH_SUCCESS; | 768 | return ge::GRAPH_SUCCESS; |
| @@ -745,10 +804,11 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::CheckExpertPipeline() const | |||
| 745 | "; rank size must be <= " + std::to_string(MC2KernelTemplate::Gmma2avMteTiling::MAX_RANK_SIZE) + | 804 | "; rank size must be <= " + std::to_string(MC2KernelTemplate::Gmma2avMteTiling::MAX_RANK_SIZE) + |
| 746 | " and their product <= " + std::to_string(MC2KernelTemplate::Gmma2avMteTiling::MAX_COUNT_NUM)), | 805 | " and their product <= " + std::to_string(MC2KernelTemplate::Gmma2avMteTiling::MAX_COUNT_NUM)), |
| 747 | return ge::GRAPH_FAILED); | 806 | return ge::GRAPH_FAILED); |
| 748 | - OP_TILING_CHECK(MC2KernelTemplate::Gmma2avMteTiling::FIXED_SYNC_BYTES > | 807 | + OP_TILING_CHECK( |
| 749 | - MC2KernelTemplate::Gmma2avMteTiling::SYNC_REGION_FROM_TAIL, | 808 | + MC2KernelTemplate::Gmma2avMteTiling::FIXED_SYNC_BYTES > |
| 750 | - OP_LOGE(opName_, "Expert-overlap fixed sync layout does not fit its reserved CCL region."), | 809 | + MC2KernelTemplate::Gmma2avMteTiling::SYNC_REGION_FROM_TAIL, |
| 751 | - return ge::GRAPH_FAILED); | 810 | + OP_LOGE_WITHOUT_REPORT(opName_, "Expert-overlap fixed sync layout does not fit its reserved CCL region."), |
| 811 | + return ge::GRAPH_FAILED); | ||
| 752 | 812 | ||
| 753 | return ge::GRAPH_SUCCESS; | 813 | return ge::GRAPH_SUCCESS; |
| 754 | } | 814 | } |
| @@ -791,7 +851,10 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::SetExpertChunkRows(uint32_t& ex | |||
| 791 | ge::graphStatus GroupedMatmulAllToAllvMteTiling::GetWorkspaceSize() | 851 | ge::graphStatus GroupedMatmulAllToAllvMteTiling::GetWorkspaceSize() |
| 792 | { | 852 | { |
| 793 | size_t* workspaces = context_->GetWorkspaceSizes(1); | 853 | size_t* workspaces = context_->GetWorkspaceSizes(1); |
| 794 | - OP_TILING_CHECK(workspaces == nullptr, OP_LOGE(opName_, "Failed to get workspace."), return ge::GRAPH_FAILED); | 854 | + OP_TILING_CHECK(workspaces == nullptr, |
| 855 | + Mc2Error::ReportTilingFailure( | ||
| 856 | + opName_, "GetWorkspaceSizes(1) returned null; expected one writable workspace slot"), | ||
| 857 | + return ge::GRAPH_FAILED); | ||
| 795 | workspaces[0] = mteWorkspaceSize_; | 858 | workspaces[0] = mteWorkspaceSize_; |
| 796 | OP_LOGD(opName_, "MTE workspace size=%lu", mteWorkspaceSize_); | 859 | OP_LOGD(opName_, "MTE workspace size=%lu", mteWorkspaceSize_); |
| 797 | return ge::GRAPH_SUCCESS; | 860 | return ge::GRAPH_SUCCESS; |
| @@ -812,10 +875,10 @@ ge::graphStatus GroupedMatmulAllToAllvMteTiling::GetAndConvertCommMode(gert::Til | |||
| 812 | OP_TILING_CHECK(commModeStr == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "comm_mode"), | 875 | OP_TILING_CHECK(commModeStr == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "comm_mode"), |
| 813 | return ge::GRAPH_FAILED); | 876 | return ge::GRAPH_FAILED); |
| 814 | constexpr size_t maxLength = 7UL; | 877 | constexpr size_t maxLength = 7UL; |
| 815 | - OP_TILING_CHECK( | 878 | + OP_TILING_CHECK(npuArch_ == Ops::Base::DAV_3510, |
| 816 | - npuArch_ == Ops::Base::DAV_3510, | 879 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "comm_mode", commModeStr, |
| 817 | - OP_LOGE(context->GetNodeName(), "GroupedMatMulAlltoAllv AIV-driven MTE mode only supports Atlas A2/A3."), | 880 | + "aiv communication requires Atlas A2/A3"), |
| 818 | - return ge::GRAPH_FAILED); | 881 | + return ge::GRAPH_FAILED); |
| 819 | OP_TILING_CHECK(strncmp(commModeStr, "aiv", maxLength) != 0, | 882 | OP_TILING_CHECK(strncmp(commModeStr, "aiv", maxLength) != 0, |
| 820 | OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "comm_mode", commModeStr, "aiv"), | 883 | OP_LOGE_FOR_INVALID_VALUE(context->GetNodeName(), "comm_mode", commModeStr, "aiv"), |
| 821 | return ge::GRAPH_FAILED); | 884 | return ge::GRAPH_FAILED); |
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "grouped_mat_mul_allto_allv_tiling.h" | 15 | #include "grouped_mat_mul_allto_allv_tiling.h" |
| 16 | #include "op_mc2.h" | 16 | #include "op_mc2.h" |
| 17 | #include "mc2_log.h" | 17 | #include "mc2_log.h" |
| 18 | +#include "mc2_tiling_failure_report.h" | ||
| 18 | #include "op_host/tiling_templates_registry.h" | 19 | #include "op_host/tiling_templates_registry.h" |
| 19 | #include "op_host/op_tiling/mc2_tiling_utils.h" | 20 | #include "op_host/op_tiling/mc2_tiling_utils.h" |
| 20 | #include "mc2_comm_utils.h" | 21 | #include "mc2_comm_utils.h" |
| @@ -280,7 +281,8 @@ ge::graphStatus GroupedMatmulAllToAllvTiling::CheckParamsAttrEpAndSetLocalParams | |||
| 280 | OP_TILING_CHECK(epWorldSizePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(opName_, "epWorldSize"), | 281 | OP_TILING_CHECK(epWorldSizePtr == nullptr, OP_LOGE_WITH_INVALID_INPUT(opName_, "epWorldSize"), |
| 281 | return ge::GRAPH_FAILED); | 282 | return ge::GRAPH_FAILED); |
| 282 | if (*epWorldSizePtr == RANK_DEFAULT_NUM) { | 283 | if (*epWorldSizePtr == RANK_DEFAULT_NUM) { |
| 283 | - OP_TILING_CHECK(!mc2tiling::GetRankSize(opName_, group, rankDim), OP_LOGE(opName_, "GetRankSize failed."), | 284 | + OP_TILING_CHECK(!mc2tiling::GetRankSize(opName_, group, rankDim), |
| 285 | + OP_LOGE_WITHOUT_REPORT(opName_, "GetRankSize failed; preserve the shared HCCL lookup report"), | ||
| 284 | return ge::GRAPH_FAILED); | 286 | return ge::GRAPH_FAILED); |
| 285 | } else { | 287 | } else { |
| 286 | rankDim = *epWorldSizePtr; | 288 | rankDim = *epWorldSizePtr; |
| @@ -320,17 +322,23 @@ ge::graphStatus GroupedMatmulAllToAllvTiling::GetPlatformInfo() | |||
| 320 | return status; | 322 | return status; |
| 321 | } | 323 | } |
| 322 | auto platformInfo = context_->GetPlatformInfo(); | 324 | auto platformInfo = context_->GetPlatformInfo(); |
| 323 | - OP_TILING_CHECK(platformInfo == nullptr, OP_LOGE(opName_, "Failed to get platform info."), return ge::GRAPH_FAILED); | 325 | + // The shared GetPlatformInfo above guarantees a non-null platform. |
| 326 | + | ||
| 324 | platform_ascendc::PlatformAscendC ascendcPlatform(platformInfo); | 327 | platform_ascendc::PlatformAscendC ascendcPlatform(platformInfo); |
| 325 | npuArch_ = ascendcPlatform.GetCurNpuArch(); | 328 | npuArch_ = ascendcPlatform.GetCurNpuArch(); |
| 326 | std::string socVersion; | 329 | std::string socVersion; |
| 327 | (void)platformInfo->GetPlatformResWithLock("version", "Short_SoC_version", socVersion); | 330 | (void)platformInfo->GetPlatformResWithLock("version", "Short_SoC_version", socVersion); |
| 328 | // AIV has its own MTE tiling and GetPlatformInfo override. Reject 910B in | 331 | // AIV has its own MTE tiling and GetPlatformInfo override. Reject 910B in |
| 329 | // this legacy candidate before GetTilingKey, whose failure is only a key. | 332 | // this legacy candidate before GetTilingKey, whose failure is only a key. |
| 330 | - OP_TILING_CHECK(socVersion == "Ascend910B", | 333 | + const auto* attrs = context_->GetAttrs(); |
| 331 | - OP_LOGE(opName_, "Ascend 910B only supports commMode 'aiv'; AICPU tiling is not supported."), | 334 | + const char* actualCommMode = attrs == nullptr ? nullptr : attrs->GetAttrPointer<char>(ATTR_COMM_MODE); |
| 335 | + OP_TILING_CHECK(socVersion == "Ascend910B" && actualCommMode != nullptr, | ||
| 336 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 337 | + opName_, "comm_mode", actualCommMode, | ||
| 338 | + "Ascend910B supports only the aiv MTE implementation; this legacy candidate cannot execute it"), | ||
| 332 | return ge::GRAPH_FAILED); | 339 | return ge::GRAPH_FAILED); |
| 333 | - return ge::GRAPH_SUCCESS; | 340 | + uint8_t commMode = 0; |
| 341 | + return GetAndConvertCommMode(context_, commMode); | ||
| 334 | } | 342 | } |
| 335 | 343 | ||
| 336 | uint32_t GroupedMatmulAllToAllvTiling::GetCommModeIndex() const | 344 | uint32_t GroupedMatmulAllToAllvTiling::GetCommModeIndex() const |
| @@ -342,11 +350,17 @@ ge::graphStatus GroupedMatmulAllToAllvTiling::GetAndConvertCommMode(gert::Tiling | |||
| 342 | uint8_t& commMode) const | 350 | uint8_t& commMode) const |
| 343 | { | 351 | { |
| 344 | const gert::RuntimeAttrs* attrs = context->GetAttrs(); | 352 | const gert::RuntimeAttrs* attrs = context->GetAttrs(); |
| 345 | - OP_TILING_CHECK(attrs == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "attrs"), | 353 | + OP_TILING_CHECK(attrs == nullptr, |
| 354 | + Mc2Error::ReportTilingFailure( | ||
| 355 | + context->GetNodeName(), | ||
| 356 | + "GetAndConvertCommMode: missing RuntimeAttrs; expected materialized optional comm_mode"), | ||
| 346 | return ge::GRAPH_FAILED); | 357 | return ge::GRAPH_FAILED); |
| 347 | const char* commModeStr = attrs->GetAttrPointer<char>(ATTR_COMM_MODE); | 358 | const char* commModeStr = attrs->GetAttrPointer<char>(ATTR_COMM_MODE); |
| 348 | - OP_TILING_CHECK(commModeStr == nullptr, OP_LOGE_WITH_INVALID_INPUT(context->GetNodeName(), "comm_mode"), | 359 | + OP_TILING_CHECK( |
| 349 | - return ge::GRAPH_FAILED); | 360 | + commModeStr == nullptr, |
| 361 | + Mc2Error::ReportTilingFailure(context->GetNodeName(), | ||
| 362 | + "GetAttrPointer(comm_mode) returned null; expected optional/default storage"), | ||
| 363 | + return ge::GRAPH_FAILED); | ||
| 350 | const size_t maxLength = 7UL; | 364 | const size_t maxLength = 7UL; |
| 351 | if (npuArch_ == Ops::Base::DAV_3510 || npuArch_ == Ops::Base::DAV_9201) { | 365 | if (npuArch_ == Ops::Base::DAV_3510 || npuArch_ == Ops::Base::DAV_9201) { |
| 352 | if (strncmp(commModeStr, "ai_cpu", maxLength) == 0) { | 366 | if (strncmp(commModeStr, "ai_cpu", maxLength) == 0) { |
| @@ -354,20 +368,22 @@ ge::graphStatus GroupedMatmulAllToAllvTiling::GetAndConvertCommMode(gert::Tiling | |||
| 354 | } else if (strncmp(commModeStr, "ccu", maxLength) == 0) { | 368 | } else if (strncmp(commModeStr, "ccu", maxLength) == 0) { |
| 355 | if (npuArch_ == Ops::Base::DAV_9201) { | 369 | if (npuArch_ == Ops::Base::DAV_9201) { |
| 356 | // A6(ascend960)无CCU引擎,显式ccu直接报错(默认ai_cpu不受影响) | 370 | // A6(ascend960)无CCU引擎,显式ccu直接报错(默认ai_cpu不受影响) |
| 357 | - OP_LOGE(context->GetNodeName(), "A6 has no CCU engine, commMode 'ccu' is not supported."); | 371 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "comm_mode", commModeStr, |
| 372 | + "Ascend960 has no CCU engine; use ai_cpu"); | ||
| 358 | return ge::GRAPH_FAILED; | 373 | return ge::GRAPH_FAILED; |
| 359 | } | 374 | } |
| 360 | commMode = Mc2Comm::COMM_MODE_CCU; | 375 | commMode = Mc2Comm::COMM_MODE_CCU; |
| 361 | } else { | 376 | } else { |
| 362 | - OP_LOGD(context->GetNodeName(), "Currently, commMode only support 'ccu', 'ai_cpu', but got %s.", | 377 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "comm_mode", commModeStr, |
| 363 | - commModeStr); | 378 | + "must be ccu or ai_cpu on Ascend950"); |
| 364 | return ge::GRAPH_FAILED; | 379 | return ge::GRAPH_FAILED; |
| 365 | } | 380 | } |
| 366 | } else { | 381 | } else { |
| 367 | if (strncmp(commModeStr, "ai_cpu", maxLength) == 0) { | 382 | if (strncmp(commModeStr, "ai_cpu", maxLength) == 0) { |
| 368 | commMode = Mc2Comm::COMM_MODE_AICPU; | 383 | commMode = Mc2Comm::COMM_MODE_AICPU; |
| 369 | } else { | 384 | } else { |
| 370 | - OP_LOGD(context->GetNodeName(), "Currently, commMode only support 'ai_cpu', but got %s.", commModeStr); | 385 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context->GetNodeName(), "comm_mode", commModeStr, |
| 386 | + "this legacy communication implementation supports ai_cpu"); | ||
| 371 | return ge::GRAPH_FAILED; | 387 | return ge::GRAPH_FAILED; |
| 372 | } | 388 | } |
| 373 | } | 389 | } |
Mmc2/grouped_mat_mul_allto_allv/tests/ut/op_host/arch22/test_grouped_mat_mul_allto_allv_tiling.cpp+21-4
| @@ -9,8 +9,10 @@ | |||
| 9 | */ | 9 | */ |
| 10 | #include <iostream> | 10 | #include <iostream> |
| 11 | #include <gtest/gtest.h> | 11 | #include <gtest/gtest.h> |
| 12 | +#include "mc2/common/tests/ut/internal_fallback_assertions.h" | ||
| 12 | #include "../../../../op_host/op_tiling/grouped_mat_mul_allto_allv_tiling.h" | 13 | #include "../../../../op_host/op_tiling/grouped_mat_mul_allto_allv_tiling.h" |
| 13 | #include "mc2_tiling_case_executor.h" | 14 | #include "mc2_tiling_case_executor.h" |
| 15 | +#include "mc2/common/tests/ut/formal_error_assertions.h" | ||
| 14 | 16 | ||
| 15 | namespace GroupedMatMulAlltoAllvUT { | 17 | namespace GroupedMatMulAlltoAllvUT { |
| 16 | 18 | ||
| @@ -101,6 +103,7 @@ protected: | |||
| 101 | TEST_P(GroupedMatMulAlltoAllvArch22TilingTest, ShapeSize) | 103 | TEST_P(GroupedMatMulAlltoAllvArch22TilingTest, ShapeSize) |
| 102 | { | 104 | { |
| 103 | auto testParam = GetParam(); | 105 | auto testParam = GetParam(); |
| 106 | + Mc2ErrorCodeUT::ExcelErrorReportScope errors; | ||
| 104 | struct GroupedMatMulAlltoAllvCompileInfo {}; | 107 | struct GroupedMatMulAlltoAllvCompileInfo {}; |
| 105 | GroupedMatMulAlltoAllvCompileInfo compileInfo; | 108 | GroupedMatMulAlltoAllvCompileInfo compileInfo; |
| 106 | std::string socVersion = testParam.socVersion; | 109 | std::string socVersion = testParam.socVersion; |
| @@ -153,15 +156,27 @@ TEST_P(GroupedMatMulAlltoAllvArch22TilingTest, ShapeSize) | |||
| 153 | if (testParam.omitCommMode) { | 156 | if (testParam.omitCommMode) { |
| 154 | tilingContextPara.attrs_.pop_back(); | 157 | tilingContextPara.attrs_.pop_back(); |
| 155 | } | 158 | } |
| 159 | + // attrs_ is already RuntimeAttrs storage: removing its last entry simulates | ||
| 160 | + // a missing materialized default slot, not legal omission at the public IR. | ||
| 161 | + (void)ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 156 | if (testParam.status == ge::GRAPH_FAILED) { | 162 | if (testParam.status == ge::GRAPH_FAILED) { |
| 157 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; | 163 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", 8}}; |
| 158 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); | 164 | Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues); |
| 159 | } else { | 165 | } else { |
| 160 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", tilingParams.epWorldSize}}; | 166 | Mc2Hcom::MockValues hcomTopologyMockValues{{"rankNum", tilingParams.epWorldSize}}; |
| 161 | - // Match master: conversion failure is returned as the key, not the outer status. | 167 | + Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_SUCCESS, 9UL); |
| 162 | - uint64_t expectTilingKey = testParam.omitCommMode ? static_cast<uint64_t>(ge::GRAPH_FAILED) : 9UL; | ||
| 163 | - Mc2ExecuteTestCase(tilingContextPara, hcomTopologyMockValues, ge::GRAPH_SUCCESS, expectTilingKey); | ||
| 164 | } | 168 | } |
| 169 | + if (testParam.testName == "Test_missing_comm_mode_retains_internal_fallback_a3") { | ||
| 170 | + Mc2ErrorCodeUT::ExpectInternalFallbackReport( | ||
| 171 | + "GetAttrPointer(comm_mode) returned null; expected default storage"); | ||
| 172 | + } else if (testParam.testName == "Test_default_comm_mode_materialized_a3" || | ||
| 173 | + testParam.testName == "Test_a3_aicpu_topk8") { | ||
| 174 | + EXPECT_TRUE(ErrorManager::GetInstance().GetRawErrorMessages().empty()); | ||
| 175 | + } else if (testParam.testName == "Test_a3_aicpu_topk9") { | ||
| 176 | + Mc2ErrorCodeUT::ExpectExcelFormalError("EZ0024", "K", "9", nullptr, nullptr, | ||
| 177 | + {{"correct_value", "[2, 8]"}, {"op_name", "GroupedMatMulAlltoAllv"}}); | ||
| 178 | + } | ||
| 179 | + (void)ErrorManager::GetInstance().GetRawErrorMessages(); | ||
| 165 | } | 180 | } |
| 166 | 181 | ||
| 167 | static TestParam g_testParams[] = { | 182 | static TestParam g_testParams[] = { |
| @@ -171,7 +186,9 @@ static TestParam g_testParams[] = { | |||
| 171 | {"Test_a2_default_rejected", {}, {}, {}, ge::GRAPH_FAILED, false, "Ascend910B", "default"}, | 186 | {"Test_a2_default_rejected", {}, {}, {}, ge::GRAPH_FAILED, false, "Ascend910B", "default"}, |
| 172 | {"Test_a2_ccu_rejected", {}, {}, {}, ge::GRAPH_FAILED, false, "Ascend910B", "ccu"}, | 187 | {"Test_a2_ccu_rejected", {}, {}, {}, ge::GRAPH_FAILED, false, "Ascend910B", "ccu"}, |
| 173 | {"Test_a5_aicpu_unchanged", {}, {}, {}, ge::GRAPH_SUCCESS, false, "Ascend950"}, | 188 | {"Test_a5_aicpu_unchanged", {}, {}, {}, ge::GRAPH_SUCCESS, false, "Ascend950"}, |
| 174 | - {"Test_missing_comm_mode_matches_master_a3", {}, {}, {}, ge::GRAPH_SUCCESS, true, "Ascend910_93"}, | 189 | + {"Test_missing_comm_mode_retains_internal_fallback_a3", {}, {}, {}, ge::GRAPH_FAILED, true, "Ascend910_93"}, |
| 190 | + // The explicit ai_cpu slot matches the OpDef default; this fixture does not materialize IR defaults. | ||
| 191 | + {"Test_default_comm_mode_materialized_a3", {}, {}, {}, ge::GRAPH_SUCCESS, false, "Ascend910_93", "ai_cpu"}, | ||
| 175 | // A5 validates commMode in SetHcclTiling, before the final key conversion. | 192 | // A5 validates commMode in SetHcclTiling, before the final key conversion. |
| 176 | {"Test_a5_missing_comm_mode_rejected", {}, {}, {}, ge::GRAPH_FAILED, true, "Ascend950"}, | 193 | {"Test_a5_missing_comm_mode_rejected", {}, {}, {}, ge::GRAPH_FAILED, true, "Ascend950"}, |
| 177 | {"Test_a3_aicpu_topk8", {{"BS", "512"}}, {}, {}, ge::GRAPH_SUCCESS}, | 194 | {"Test_a3_aicpu_topk8", {{"BS", "512"}}, {}, {}, ge::GRAPH_SUCCESS}, |
| @@ -12,6 +12,7 @@ | |||
| 12 | * \file matmul_allto_all_base.cpp | 12 | * \file matmul_allto_all_base.cpp |
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | +#include "mc2/common/op_api/mc2_api_error.h" | ||
| 15 | #include "matmul_allto_all_base.h" | 16 | #include "matmul_allto_all_base.h" |
| 16 | #include "matmul_allto_all_util.h" | 17 | #include "matmul_allto_all_util.h" |
| 17 | #include "securec.h" | 18 | #include "securec.h" |
| @@ -373,7 +374,7 @@ aclnnStatus aclnnMatmulAlltoAllBase(void* workspace, uint64_t workspaceSize, acl | |||
| 373 | aclrtStream stream) | 374 | aclrtStream stream) |
| 374 | { | 375 | { |
| 375 | if (executor == nullptr) { | 376 | if (executor == nullptr) { |
| 376 | - OP_LOGE_LIBOPAPI_REPORT("aclnnMatmulAlltoAllBase", "Param executor is nullptr."); | 377 | + Mc2Aclnn::ReportRequiredApiPointer(__func__, "executor"); |
| 377 | return ACLNN_ERR_INNER; | 378 | return ACLNN_ERR_INNER; |
| 378 | } | 379 | } |
| 379 | if (NnopbaseSetHcclServerType) { | 380 | if (NnopbaseSetHcclServerType) { |
| @@ -12,6 +12,7 @@ | |||
| 12 | * \file quant_matmul_allto_all_base.cpp | 12 | * \file quant_matmul_allto_all_base.cpp |
| 13 | * \brief | 13 | * \brief |
| 14 | */ | 14 | */ |
| 15 | +#include "mc2/common/op_api/mc2_api_error.h" | ||
| 15 | #include "quant_matmul_allto_all_base.h" | 16 | #include "quant_matmul_allto_all_base.h" |
| 16 | #include "securec.h" | 17 | #include "securec.h" |
| 17 | #include "matmul_allto_all_util.h" | 18 | #include "matmul_allto_all_util.h" |
| @@ -654,7 +655,7 @@ aclnnStatus aclnnQuantMatmulAlltoAllBase(void* workspace, uint64_t workspaceSize | |||
| 654 | aclrtStream stream) | 655 | aclrtStream stream) |
| 655 | { | 656 | { |
| 656 | if (executor == nullptr) { | 657 | if (executor == nullptr) { |
| 657 | - OP_LOGE_LIBOPAPI_REPORT("aclnnQuantMatmulAlltoAllBase", "Param executor is nullptr."); | 658 | + Mc2Aclnn::ReportRequiredApiPointer(__func__, "executor"); |
| 658 | return ACLNN_ERR_INNER; | 659 | return ACLNN_ERR_INNER; |
| 659 | } | 660 | } |
| 660 | if (NnopbaseSetHcclServerType) { | 661 | if (NnopbaseSetHcclServerType) { |
| @@ -242,14 +242,16 @@ static ge::graphStatus MatmulAlltoAllExecuteFunc(gert::OpExecuteContext* host_ap | |||
| 242 | 242 | ||
| 243 | CommonMatmulParas matmulParas; | 243 | CommonMatmulParas matmulParas; |
| 244 | ge::graphStatus retPara = GetCommonMatmulInputPara(host_api_ctx, matmulParas); | 244 | ge::graphStatus retPara = GetCommonMatmulInputPara(host_api_ctx, matmulParas); |
| 245 | - OPS_CHECK(retPara != ge::SUCCESS, OP_LOGE(host_api_ctx->GetNodeName(), "Failed to get common matmul input paras."), | 245 | + OPS_CHECK(retPara != ge::SUCCESS, |
| 246 | + OP_LOGE_WITHOUT_REPORT(host_api_ctx->GetNodeName(), "Failed to get common matmul input paras."), | ||
| 246 | return ge::GRAPH_FAILED); | 247 | return ge::GRAPH_FAILED); |
| 247 | const auto output = host_api_ctx->GetOutputTensor(INDEX_OUT); | 248 | const auto output = host_api_ctx->GetOutputTensor(INDEX_OUT); |
| 248 | OPS_CHECK(output == nullptr, OP_LOGE_WITH_INVALID_INPUT(host_api_ctx->GetNodeName(), "output"), | 249 | OPS_CHECK(output == nullptr, OP_LOGE_WITH_INVALID_INPUT(host_api_ctx->GetNodeName(), "output"), |
| 249 | return ge::GRAPH_FAILED); | 250 | return ge::GRAPH_FAILED); |
| 250 | AttrParas attrParas; | 251 | AttrParas attrParas; |
| 251 | OPS_CHECK(GetAttrPara(host_api_ctx, attrs, attrParas) != ge::SUCCESS, | 252 | OPS_CHECK(GetAttrPara(host_api_ctx, attrs, attrParas) != ge::SUCCESS, |
| 252 | - OP_LOGE(host_api_ctx->GetNodeName(), "Failed to get attr paras."), return ge::GRAPH_FAILED); | 253 | + OP_LOGE_WITHOUT_REPORT(host_api_ctx->GetNodeName(), "Failed to get attr paras."), |
| 254 | + return ge::GRAPH_FAILED); | ||
| 253 | 255 | ||
| 254 | const auto alltoAllAxesOptional = attrs->GetListInt(INDEX_ATTR_ALL2ALL_AXES); | 256 | const auto alltoAllAxesOptional = attrs->GetListInt(INDEX_ATTR_ALL2ALL_AXES); |
| 255 | std::vector<int64_t> actSeqArray; | 257 | std::vector<int64_t> actSeqArray; |
| @@ -276,7 +278,7 @@ static ge::graphStatus MatmulAlltoAllExecuteFunc(gert::OpExecuteContext* host_ap | |||
| 276 | QuantMatmulParas quantMatmulParas; | 278 | QuantMatmulParas quantMatmulParas; |
| 277 | retPara = GetQuantMatmulPara(host_api_ctx, quantMatmulParas); | 279 | retPara = GetQuantMatmulPara(host_api_ctx, quantMatmulParas); |
| 278 | OPS_CHECK(retPara != ge::SUCCESS, | 280 | OPS_CHECK(retPara != ge::SUCCESS, |
| 279 | - OP_LOGE(host_api_ctx->GetNodeName(), "Failed to get quant matmul input paras."), | 281 | + OP_LOGE_WITHOUT_REPORT(host_api_ctx->GetNodeName(), "Failed to get quant matmul input paras."), |
| 280 | return ge::GRAPH_FAILED); | 282 | return ge::GRAPH_FAILED); |
| 281 | const auto ret = EXEC_OPAPI_CMD(aclnnQuantMatmulAlltoAllV2, matmulParas.x1Acl, matmulParas.x2Acl, | 283 | const auto ret = EXEC_OPAPI_CMD(aclnnQuantMatmulAlltoAllV2, matmulParas.x1Acl, matmulParas.x2Acl, |
| 282 | matmulParas.bias, quantMatmulParas.x1ScaleAcl, quantMatmulParas.x2ScaleAcl, | 284 | matmulParas.bias, quantMatmulParas.x1ScaleAcl, quantMatmulParas.x2ScaleAcl, |