已合并
errorMsg整改 #3136
pengyiming7创建于 6月4日
errorMsg整改 #3136
已合并
共 6 个文件变更+269-35
| @@ -330,13 +330,17 @@ ge::graphStatus MatrixDiagTiling::GetInputShapeAndType() | |||
| 330 | xDtypeSize_ = ge::GetSizeByDataType(xDtype); | 330 | xDtypeSize_ = ge::GetSizeByDataType(xDtype); |
| 331 | const gert::Shape& xInputShape = xInput->GetStorageShape(); | 331 | const gert::Shape& xInputShape = xInput->GetStorageShape(); |
| 332 | OP_CHECK_IF( | 332 | OP_CHECK_IF( |
| 333 | - xInputShape.GetDimNum() == 0, OP_LOGE(context_->GetNodeName(), "The input is scalar."), | 333 | + xInputShape.GetDimNum() == 0, |
| 334 | + OP_LOGE_FOR_INVALID_SHAPEDIM( | ||
| 335 | + context_->GetNodeName(), "x", std::to_string(xInputShape.GetDimNum()).c_str(), "greater than 0"), | ||
| 334 | return ge::GRAPH_FAILED); | 336 | return ge::GRAPH_FAILED); |
| 335 | inputShape_ = xInputShape; | 337 | inputShape_ = xInputShape; |
| 336 | FuseInputShape(); | 338 | FuseInputShape(); |
| 337 | OP_CHECK_IF( | 339 | OP_CHECK_IF( |
| 338 | fusedShape_[0] == 0 || fusedShape_[1] == 0, | 340 | fusedShape_[0] == 0 || fusedShape_[1] == 0, |
| 339 | - OP_LOGE(context_->GetNodeName(), "The shape is invalid, %ld, %ld.", fusedShape_[0], fusedShape_[1]), | 341 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( |
| 342 | + context_->GetNodeName(), "x", Ops::Base::ToString(inputShape_).c_str(), | ||
| 343 | + "fused batch size and n size must both be non-zero"), | ||
| 340 | return ge::GRAPH_FAILED); | 344 | return ge::GRAPH_FAILED); |
| 341 | return ge::GRAPH_SUCCESS; | 345 | return ge::GRAPH_SUCCESS; |
| 342 | } | 346 | } |
| @@ -356,7 +360,10 @@ ge::graphStatus MatrixDiagTiling::DoTiling() | |||
| 356 | 360 | ||
| 357 | static ge::graphStatus Tiling4MatrixDiag(gert::TilingContext* context) | 361 | static ge::graphStatus Tiling4MatrixDiag(gert::TilingContext* context) |
| 358 | { | 362 | { |
| 359 | - OP_CHECK_IF(context == nullptr, OP_LOGE("Tiling4MatrixDiag", "The context is nullptr!"), return ge::GRAPH_FAILED); | 363 | + OP_CHECK_IF( |
| 364 | + context == nullptr, | ||
| 365 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON("Tiling4MatrixDiag", "context", "nullptr", "must not be null"), | ||
| 366 | + return ge::GRAPH_FAILED); | ||
| 360 | 367 | ||
| 361 | MatrixDiagAsc::MatrixDiagTiling op(context); | 368 | MatrixDiagAsc::MatrixDiagTiling op(context); |
| 362 | return op.DoTiling(); | 369 | return op.DoTiling(); |
| @@ -375,25 +382,35 @@ static ge::graphStatus TilingPrepare4MatrixDiagAscendC(gert::TilingParseContext* | |||
| 375 | compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv(); | 382 | compileInfo->coreNum = ascendcPlatform.GetCoreNumAiv(); |
| 376 | OP_CHECK_IF( | 383 | OP_CHECK_IF( |
| 377 | (compileInfo->coreNum < 1), | 384 | (compileInfo->coreNum < 1), |
| 378 | - OP_LOGE(context->GetNodeName(), "The core num is invalid, %u.", compileInfo->coreNum), return ge::GRAPH_FAILED); | 385 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 386 | + context->GetNodeName(), "core num", std::to_string(compileInfo->coreNum).c_str(), | ||
| 387 | + "must be greater than or equal to 1"), | ||
| 388 | + return ge::GRAPH_FAILED); | ||
| 379 | 389 | ||
| 380 | uint64_t ubSize = 0; | 390 | uint64_t ubSize = 0; |
| 381 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); | 391 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); |
| 382 | compileInfo->ubSize = static_cast<uint32_t>(ubSize); | 392 | compileInfo->ubSize = static_cast<uint32_t>(ubSize); |
| 383 | OP_CHECK_IF( | 393 | OP_CHECK_IF( |
| 384 | - (compileInfo->ubSize < 1), OP_LOGE(context->GetNodeName(), "The ub size is invalid, %u.", compileInfo->ubSize), | 394 | + (compileInfo->ubSize < 1), |
| 395 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 396 | + context->GetNodeName(), "ub size", std::to_string(compileInfo->ubSize).c_str(), | ||
| 397 | + "must be greater than or equal to 1"), | ||
| 385 | return ge::GRAPH_FAILED); | 398 | return ge::GRAPH_FAILED); |
| 386 | 399 | ||
| 387 | compileInfo->clSize = Ops::Base::GetCacheLineSize(context); | 400 | compileInfo->clSize = Ops::Base::GetCacheLineSize(context); |
| 388 | OP_CHECK_IF( | 401 | OP_CHECK_IF( |
| 389 | (compileInfo->clSize < 1), | 402 | (compileInfo->clSize < 1), |
| 390 | - OP_LOGE(context->GetNodeName(), "The cache line size is invalid, %u.", compileInfo->clSize), | 403 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 404 | + context->GetNodeName(), "cache line size", std::to_string(compileInfo->clSize).c_str(), | ||
| 405 | + "must be greater than or equal to 1"), | ||
| 391 | return ge::GRAPH_FAILED); | 406 | return ge::GRAPH_FAILED); |
| 392 | 407 | ||
| 393 | compileInfo->blockSize = Ops::Base::GetUbBlockSize(context); | 408 | compileInfo->blockSize = Ops::Base::GetUbBlockSize(context); |
| 394 | OP_CHECK_IF( | 409 | OP_CHECK_IF( |
| 395 | (compileInfo->blockSize < 1), | 410 | (compileInfo->blockSize < 1), |
| 396 | - OP_LOGE(context->GetNodeName(), "The block size is invalid, %u.", compileInfo->blockSize), | 411 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( |
| 412 | + context->GetNodeName(), "block size", std::to_string(compileInfo->blockSize).c_str(), | ||
| 413 | + "must be greater than or equal to 1"), | ||
| 397 | return ge::GRAPH_FAILED); | 414 | return ge::GRAPH_FAILED); |
| 398 | 415 | ||
| 399 | OP_LOGD(context->GetNodeName(), "Exit TilingPrepare4MatrixDiagAscendC."); | 416 | OP_LOGD(context->GetNodeName(), "Exit TilingPrepare4MatrixDiagAscendC."); |
| @@ -403,7 +420,9 @@ static ge::graphStatus TilingPrepare4MatrixDiagAscendC(gert::TilingParseContext* | |||
| 403 | static ge::graphStatus TilingPrepare4MatrixDiag(gert::TilingParseContext* context) | 420 | static ge::graphStatus TilingPrepare4MatrixDiag(gert::TilingParseContext* context) |
| 404 | { | 421 | { |
| 405 | OP_CHECK_IF( | 422 | OP_CHECK_IF( |
| 406 | - context == nullptr, OP_LOGE("TilingPrepare4MatrixDiag", "The context is nullptr!"), return ge::GRAPH_FAILED); | 423 | + context == nullptr, |
| 424 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON("TilingPrepare4MatrixDiag", "context", "nullptr", "must not be null"), | ||
| 425 | + return ge::GRAPH_FAILED); | ||
| 407 | auto compileInfo = context->GetCompiledInfo<MatrixDiagAsc::MatrixDiagCompileInfo>(); | 426 | auto compileInfo = context->GetCompiledInfo<MatrixDiagAsc::MatrixDiagCompileInfo>(); |
| 408 | OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo); | 427 | OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo); |
| 409 | compileInfo->isAscendC = Ops::Base::IsRegbaseSocVersion(context); | 428 | compileInfo->isAscendC = Ops::Base::IsRegbaseSocVersion(context); |
| @@ -141,4 +141,13 @@ TEST_F(MatrixDiagTiling, ascend910D1_test_tiling_failed_scalar) { | |||
| 141 | {{{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},}, | 141 | {{{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},}, |
| 142 | &compileInfo); | 142 | &compileInfo); |
| 143 | ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | 143 | ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); |
| 144 | +} | ||
| 145 | + | ||
| 146 | +TEST_F(MatrixDiagTiling, ascend910D1_test_tiling_failed_zero_last_dim) { | ||
| 147 | + optiling::MatrixDiagAsc::MatrixDiagCompileInfo compileInfo = {64, 253952, 128, 32, true}; | ||
| 148 | + gert::TilingContextPara tilingContextPara("MatrixDiag", | ||
| 149 | + {{{{64, 0}, {64, 0}}, ge::DT_FLOAT, ge::FORMAT_ND},}, | ||
| 150 | + {{{{64, 0, 0}, {64, 0, 0}}, ge::DT_FLOAT, ge::FORMAT_ND},}, | ||
| 151 | + &compileInfo); | ||
| 152 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 144 | } | 153 | } |
| @@ -16,6 +16,8 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 20 | + | ||
| 19 | 21 | ||
| 20 | 22 | ||
| 21 | namespace optiling { | 23 | namespace optiling { |
| @@ -148,7 +150,11 @@ ge::graphStatus MatrixSetDiagTiling::ParamCheck() | |||
| 148 | 150 | ||
| 149 | auto inputDataType = inputValueDesc->GetDataType(); | 151 | auto inputDataType = inputValueDesc->GetDataType(); |
| 150 | dSize_ = ge::GetSizeByDataType(inputDataType); | 152 | dSize_ = ge::GetSizeByDataType(inputDataType); |
| 151 | - OP_CHECK_IF(dSize_ <= 0, OP_LOGE(context_, "data size should be positive"), return ge::GRAPH_FAILED); | 153 | + OP_CHECK_IF( |
| 154 | + dSize_ <= 0, | ||
| 155 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 156 | + context_->GetNodeName(), "x dtype size", std::to_string(dSize_).c_str(), "must be positive"), | ||
| 157 | + return ge::GRAPH_FAILED); | ||
| 152 | 158 | ||
| 153 | // 校验输入shape | 159 | // 校验输入shape |
| 154 | auto inputShape = context_->GetInputShape(0); | 160 | auto inputShape = context_->GetInputShape(0); |
| @@ -157,7 +163,9 @@ ge::graphStatus MatrixSetDiagTiling::ParamCheck() | |||
| 157 | auto inputShapeVal = inputShape->GetStorageShape(); | 163 | auto inputShapeVal = inputShape->GetStorageShape(); |
| 158 | dimNum_ = inputShapeVal.GetDimNum(); | 164 | dimNum_ = inputShapeVal.GetDimNum(); |
| 159 | OP_CHECK_IF( | 165 | OP_CHECK_IF( |
| 160 | - dimNum_ < MIN_INPUT_DIMNUM || dimNum_ > MAX_INPUT_DIMNUM, OP_LOGE(context_, "input dim must be between [2,8]"), | 166 | + dimNum_ < MIN_INPUT_DIMNUM || dimNum_ > MAX_INPUT_DIMNUM, |
| 167 | + OP_LOGE_FOR_INVALID_SHAPEDIM( | ||
| 168 | + context_->GetNodeName(), "input", std::to_string(dimNum_).c_str(), "between [2, 8]"), | ||
| 161 | return ge::GRAPH_FAILED); | 169 | return ge::GRAPH_FAILED); |
| 162 | 170 | ||
| 163 | auto diagValueDesc = context_->GetInputDesc(1); | 171 | auto diagValueDesc = context_->GetInputDesc(1); |
| @@ -165,7 +173,11 @@ ge::graphStatus MatrixSetDiagTiling::ParamCheck() | |||
| 165 | 173 | ||
| 166 | auto diagDataType = diagValueDesc->GetDataType(); | 174 | auto diagDataType = diagValueDesc->GetDataType(); |
| 167 | OP_CHECK_IF( | 175 | OP_CHECK_IF( |
| 168 | - inputDataType != diagDataType, OP_LOGE(context_, "input and diag should have same type"), | 176 | + inputDataType != diagDataType, |
| 177 | + OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON( | ||
| 178 | + context_->GetNodeName(), "input and diagonal", | ||
| 179 | + (Ops::Base::ToString(inputDataType) + " and " + Ops::Base::ToString(diagDataType)).c_str(), | ||
| 180 | + "dtypes of input and diagonal must be the same"), | ||
| 169 | return ge::GRAPH_FAILED); | 181 | return ge::GRAPH_FAILED); |
| 170 | 182 | ||
| 171 | // 校验输入shape | 183 | // 校验输入shape |
| @@ -174,20 +186,38 @@ ge::graphStatus MatrixSetDiagTiling::ParamCheck() | |||
| 174 | 186 | ||
| 175 | auto diagShapeVal = diagShape->GetStorageShape(); | 187 | auto diagShapeVal = diagShape->GetStorageShape(); |
| 176 | diagDimNum_ = diagShapeVal.GetDimNum(); | 188 | diagDimNum_ = diagShapeVal.GetDimNum(); |
| 177 | - OP_CHECK_IF(diagDimNum_ < 1, OP_LOGE(context_, "diag dim must >=1"), return ge::GRAPH_FAILED); | ||
| 178 | OP_CHECK_IF( | 189 | OP_CHECK_IF( |
| 179 | - dimNum_ != diagDimNum_ + 1, OP_LOGE(context_, "diag dim must equal input dim - 1"), return ge::GRAPH_FAILED); | 190 | + diagDimNum_ < 1, |
| 191 | + OP_LOGE_FOR_INVALID_SHAPEDIM( | ||
| 192 | + context_->GetNodeName(), "diagonal", std::to_string(diagDimNum_).c_str(), | ||
| 193 | + "greater than or equal to 1"), | ||
| 194 | + return ge::GRAPH_FAILED); | ||
| 195 | + OP_CHECK_IF( | ||
| 196 | + dimNum_ != diagDimNum_ + 1, | ||
| 197 | + OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( | ||
| 198 | + context_->GetNodeName(), "input and diagonal", | ||
| 199 | + (std::to_string(dimNum_) + " and " + std::to_string(diagDimNum_)).c_str(), | ||
| 200 | + "diagonal dim num must equal input dim num minus 1"), | ||
| 201 | + return ge::GRAPH_FAILED); | ||
| 180 | 202 | ||
| 181 | xColNum_ = inputShapeVal.GetDim(dimNum_ - 1); | 203 | xColNum_ = inputShapeVal.GetDim(dimNum_ - 1); |
| 182 | xRowNum_ = inputShapeVal.GetDim(dimNum_ - 2); | 204 | xRowNum_ = inputShapeVal.GetDim(dimNum_ - 2); |
| 183 | tailAxisDataSize_ = xColNum_ * xRowNum_; | 205 | tailAxisDataSize_ = xColNum_ * xRowNum_; |
| 184 | diagLen_ = diagShapeVal.GetDim(diagDimNum_ - 1); | 206 | diagLen_ = diagShapeVal.GetDim(diagDimNum_ - 1); |
| 185 | OP_CHECK_IF( | 207 | OP_CHECK_IF( |
| 186 | - diagLen_ != std::min(xColNum_, xRowNum_), OP_LOGE(context_, "diagLen is invalid"), return ge::GRAPH_FAILED); | 208 | + diagLen_ != std::min(xColNum_, xRowNum_), |
| 209 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( | ||
| 210 | + context_->GetNodeName(), "diagonal", Ops::Base::ToString(diagShapeVal).c_str(), | ||
| 211 | + "diagonal length must equal min(row, col) of input"), | ||
| 212 | + return ge::GRAPH_FAILED); | ||
| 187 | if (diagDimNum_ > 1) { | 213 | if (diagDimNum_ > 1) { |
| 188 | for (int32_t i = diagDimNum_ - 2; i >= 0; i--) { | 214 | for (int32_t i = diagDimNum_ - 2; i >= 0; i--) { |
| 189 | OP_CHECK_IF( | 215 | OP_CHECK_IF( |
| 190 | - diagShapeVal.GetDim(i) != inputShapeVal.GetDim(i), OP_LOGE(context_, "diagDim is invalid"), | 216 | + diagShapeVal.GetDim(i) != inputShapeVal.GetDim(i), |
| 217 | + OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( | ||
| 218 | + context_->GetNodeName(), "input and diagonal", | ||
| 219 | + (Ops::Base::ToString(inputShapeVal) + " and " + Ops::Base::ToString(diagShapeVal)).c_str(), | ||
| 220 | + ("dim " + std::to_string(i) + " of diagonal must match input").c_str()), | ||
| 191 | return ge::GRAPH_FAILED); | 221 | return ge::GRAPH_FAILED); |
| 192 | mergeDimSize_ = mergeDimSize_ * static_cast<uint64_t>(diagShapeVal.GetDim(i)); | 222 | mergeDimSize_ = mergeDimSize_ * static_cast<uint64_t>(diagShapeVal.GetDim(i)); |
| 193 | } | 223 | } |
| @@ -367,13 +397,31 @@ ge::graphStatus MatrixSetDiagTiling::GetSocInfo() | |||
| 367 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr); | 397 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr); |
| 368 | coreNum_ = ascendcPlatform.GetCoreNumAiv(); | 398 | coreNum_ = ascendcPlatform.GetCoreNumAiv(); |
| 369 | realCoreNum_ = coreNum_; | 399 | realCoreNum_ = coreNum_; |
| 370 | - OP_CHECK_IF((coreNum_ == 0U), OP_LOGE(context_, "coreNum is 0"), return ge::GRAPH_FAILED); | 400 | + OP_CHECK_IF( |
| 401 | + (coreNum_ == 0U), | ||
| 402 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 403 | + context_->GetNodeName(), "core num", std::to_string(coreNum_).c_str(), "must be greater than 0"), | ||
| 404 | + return ge::GRAPH_FAILED); | ||
| 371 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize_); | 405 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize_); |
| 372 | - OP_CHECK_IF((ubSize_ == 0U), OP_LOGE(context_, "ubSize is 0"), return ge::GRAPH_FAILED); | 406 | + OP_CHECK_IF( |
| 407 | + (ubSize_ == 0U), | ||
| 408 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 409 | + context_->GetNodeName(), "ub size", std::to_string(ubSize_).c_str(), "must be greater than 0"), | ||
| 410 | + return ge::GRAPH_FAILED); | ||
| 373 | ubBlockSize_ = Ops::Base::GetUbBlockSize(context_); | 411 | ubBlockSize_ = Ops::Base::GetUbBlockSize(context_); |
| 374 | - OP_CHECK_IF((ubBlockSize_ == 0U), OP_LOGE(context_, "Failed to get ub block size."), return ge::GRAPH_FAILED); | 412 | + OP_CHECK_IF( |
| 413 | + (ubBlockSize_ == 0U), | ||
| 414 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 415 | + context_->GetNodeName(), "ub block size", std::to_string(ubBlockSize_).c_str(), | ||
| 416 | + "must be greater than 0"), | ||
| 417 | + return ge::GRAPH_FAILED); | ||
| 375 | vectorSize_ = static_cast<uint64_t>(Ops::Base::GetVRegSize(context_)); | 418 | vectorSize_ = static_cast<uint64_t>(Ops::Base::GetVRegSize(context_)); |
| 376 | - OP_CHECK_IF(vectorSize_ == 0U, OP_LOGE(context_, "Failed to vector size."), return ge::GRAPH_FAILED); | 419 | + OP_CHECK_IF( |
| 420 | + vectorSize_ == 0U, | ||
| 421 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 422 | + context_->GetNodeName(), "vector size", std::to_string(vectorSize_).c_str(), | ||
| 423 | + "must be greater than 0"), | ||
| 424 | + return ge::GRAPH_FAILED); | ||
| 377 | OP_LOGI(context_, "soc info: ubSize %lu, coreNum %u, ubBlockSize %lu ", ubSize_, coreNum_, ubBlockSize_); | 425 | OP_LOGI(context_, "soc info: ubSize %lu, coreNum %u, ubBlockSize %lu ", ubSize_, coreNum_, ubBlockSize_); |
| 378 | return ge::GRAPH_SUCCESS; | 426 | return ge::GRAPH_SUCCESS; |
| 379 | } | 427 | } |
| @@ -148,4 +148,36 @@ TEST_F(MatrixSetDiagTilingTest, test_tiling_failed_input_dim_from_2) | |||
| 148 | }, | 148 | }, |
| 149 | &compileInfo); | 149 | &compileInfo); |
| 150 | ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | 150 | ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); |
| 151 | +} | ||
| 152 | + | ||
| 153 | +TEST_F(MatrixSetDiagTilingTest, test_tiling_failed_diag_len_invalid) | ||
| 154 | +{ | ||
| 155 | + MatrixSetDiagCompileInfo compileInfo = {}; | ||
| 156 | + gert::TilingContextPara tilingContextPara( | ||
| 157 | + "MatrixSetDiag", | ||
| 158 | + { | ||
| 159 | + {{{2, 3, 3}, {2, 3, 3}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 160 | + {{{2, 2}, {2, 2}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 161 | + }, | ||
| 162 | + { | ||
| 163 | + {{{2, 3, 3}, {2, 3, 3}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 164 | + }, | ||
| 165 | + &compileInfo); | ||
| 166 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 167 | +} | ||
| 168 | + | ||
| 169 | +TEST_F(MatrixSetDiagTilingTest, test_tiling_failed_batch_dim_invalid) | ||
| 170 | +{ | ||
| 171 | + MatrixSetDiagCompileInfo compileInfo = {}; | ||
| 172 | + gert::TilingContextPara tilingContextPara( | ||
| 173 | + "MatrixSetDiag", | ||
| 174 | + { | ||
| 175 | + {{{2, 3, 3}, {2, 3, 3}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 176 | + {{{3, 3}, {3, 3}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 177 | + }, | ||
| 178 | + { | ||
| 179 | + {{{2, 3, 3}, {2, 3, 3}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 180 | + }, | ||
| 181 | + &compileInfo); | ||
| 182 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 151 | } | 183 | } |
| @@ -14,6 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | + | ||
| 17 | 18 | ||
| 18 | namespace optiling { | 19 | namespace optiling { |
| 19 | ge::graphStatus DiagPartTiling::Init() | 20 | ge::graphStatus DiagPartTiling::Init() |
| @@ -23,10 +24,16 @@ ge::graphStatus DiagPartTiling::Init() | |||
| 23 | OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo); | 24 | OP_CHECK_NULL_WITH_CONTEXT(tilingContext_, compileInfo); |
| 24 | coreNum_ = compileInfo->core_num; | 25 | coreNum_ = compileInfo->core_num; |
| 25 | OP_CHECK_IF( | 26 | OP_CHECK_IF( |
| 26 | - (coreNum_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get core num."), return ge::GRAPH_FAILED); | 27 | + (coreNum_ <= 0), |
| 28 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 29 | + tilingContext_->GetNodeName(), "core num", std::to_string(coreNum_).c_str(), "must be greater than 0"), | ||
| 30 | + return ge::GRAPH_FAILED); | ||
| 27 | ubSize_ = compileInfo->ub_size; | 31 | ubSize_ = compileInfo->ub_size; |
| 28 | OP_CHECK_IF( | 32 | OP_CHECK_IF( |
| 29 | - (ubSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub size."), return ge::GRAPH_FAILED); | 33 | + (ubSize_ <= 0), |
| 34 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | ||
| 35 | + tilingContext_->GetNodeName(), "ub size", std::to_string(ubSize_).c_str(), "must be greater than 0"), | ||
| 36 | + return ge::GRAPH_FAILED); | ||
| 30 | auto res = tilingContext_->SetLocalMemorySize(static_cast<uint32_t>(ubSize_ - DCACHE_SIZE)); | 37 | auto res = tilingContext_->SetLocalMemorySize(static_cast<uint32_t>(ubSize_ - DCACHE_SIZE)); |
| 31 | OP_CHECK_IF( | 38 | OP_CHECK_IF( |
| 32 | (res != ge::GRAPH_SUCCESS), | 39 | (res != ge::GRAPH_SUCCESS), |
| @@ -58,19 +65,18 @@ ge::graphStatus DiagPartTiling::DiagPartVerifying() | |||
| 58 | // limit input dim > 0 and dim % 2 == 0 | 65 | // limit input dim > 0 and dim % 2 == 0 |
| 59 | OP_CHECK_IF( | 66 | OP_CHECK_IF( |
| 60 | (xDimNum <= 0 || (xDimNum % TWO) != 0), | 67 | (xDimNum <= 0 || (xDimNum % TWO) != 0), |
| 61 | - OP_LOGE( | 68 | + OP_LOGE_FOR_INVALID_SHAPEDIM( |
| 62 | - tilingContext_->GetNodeName(), | 69 | + tilingContext_->GetNodeName(), "x", std::to_string(xDimNum).c_str(), |
| 63 | - "Invalid x shape dim num, it should be an even number and greater than 0, but dim num is %lu.", xDimNum), | 70 | + "an even number and greater than 0"), |
| 64 | return ge::GRAPH_FAILED); | 71 | return ge::GRAPH_FAILED); |
| 65 | 72 | ||
| 66 | // limit the dimensions corresponding to the half and half of the input shape are the same | 73 | // limit the dimensions corresponding to the half and half of the input shape are the same |
| 67 | for (uint64_t i = 0; i < xDimNum / TWO; i++) { | 74 | for (uint64_t i = 0; i < xDimNum / TWO; i++) { |
| 68 | OP_CHECK_IF( | 75 | OP_CHECK_IF( |
| 69 | (xShape.GetDim(i) != xShape.GetDim(i + xDimNum / TWO)), | 76 | (xShape.GetDim(i) != xShape.GetDim(i + xDimNum / TWO)), |
| 70 | - OP_LOGE( | 77 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( |
| 71 | - tilingContext_->GetNodeName(), | 78 | + tilingContext_->GetNodeName(), "x", Ops::Base::ToString(xShape).c_str(), |
| 72 | - "Invalid x shape, dimension:%lu and dimension:%lu should be equal, but got %ld and %ld.", i, | 79 | + "the front half and back half dims of x must be equal"), |
| 73 | - i + xDimNum / TWO, xShape.GetDim(i), xShape.GetDim(xDimNum / TWO)), | ||
| 74 | return ge::GRAPH_FAILED); | 80 | return ge::GRAPH_FAILED); |
| 75 | sideLength_ *= xShape.GetDim(i); | 81 | sideLength_ *= xShape.GetDim(i); |
| 76 | } | 82 | } |
| @@ -82,17 +88,17 @@ ge::graphStatus DiagPartTiling::DiagPartVerifying() | |||
| 82 | auto yDimNum = yShape.GetDimNum(); | 88 | auto yDimNum = yShape.GetDimNum(); |
| 83 | OP_CHECK_IF( | 89 | OP_CHECK_IF( |
| 84 | (yDimNum != xDimNum / TWO), | 90 | (yDimNum != xDimNum / TWO), |
| 85 | - OP_LOGE( | 91 | + OP_LOGE_FOR_INVALID_SHAPEDIM( |
| 86 | - tilingContext_->GetNodeName(), | 92 | + tilingContext_->GetNodeName(), "y", std::to_string(yDimNum).c_str(), |
| 87 | - "Invalid y shape dim num, it should be equal to half of the dim num of the x shape, but got %lu.", yDimNum), | 93 | + "equal to half of the dim num of x"), |
| 88 | return ge::GRAPH_FAILED); | 94 | return ge::GRAPH_FAILED); |
| 89 | for (uint64_t i = 0; i < yDimNum; i++) { | 95 | for (uint64_t i = 0; i < yDimNum; i++) { |
| 90 | OP_CHECK_IF( | 96 | OP_CHECK_IF( |
| 91 | (xShape.GetDim(i) != yShape.GetDim(i)), | 97 | (xShape.GetDim(i) != yShape.GetDim(i)), |
| 92 | - OP_LOGE( | 98 | + OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON( |
| 93 | - tilingContext_->GetNodeName(), | 99 | + tilingContext_->GetNodeName(), "x and y", |
| 94 | - "Invalid y shape, x and y dimension:%lu should be equal, but got %ld and %ld.", i, xShape.GetDim(i), | 100 | + (Ops::Base::ToString(xShape) + " and " + Ops::Base::ToString(yShape)).c_str(), |
| 95 | - yShape.GetDim(i)), | 101 | + "the front dims of x and y must be equal"), |
| 96 | return ge::GRAPH_FAILED); | 102 | return ge::GRAPH_FAILED); |
| 97 | } | 103 | } |
| 98 | OP_LOGD(tilingContext_->GetNodeName(), "DiagPartVerifying sucess."); | 104 | OP_LOGD(tilingContext_->GetNodeName(), "DiagPartVerifying sucess."); |
| @@ -51,4 +51,124 @@ TEST_F(DiagPartTiling, neg_test_tiling_001) | |||
| 51 | string expectTilingData = "16 1 32 16 253952 "; | 51 | string expectTilingData = "16 1 32 16 253952 "; |
| 52 | std::vector<size_t> expectWorkspaces = {16777216}; | 52 | std::vector<size_t> expectWorkspaces = {16777216}; |
| 53 | ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces); | 53 | ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces); |
| 54 | +} | ||
| 55 | + | ||
| 56 | +TEST_F(DiagPartTiling, neg_test_invalid_core_num) | ||
| 57 | +{ | ||
| 58 | + struct DiagPartCompileInfo { | ||
| 59 | + int64_t coreNum = 0; | ||
| 60 | + int64_t ubSize = 253952; | ||
| 61 | + }; | ||
| 62 | + | ||
| 63 | + DiagPartCompileInfo compileInfo = {0, 253952}; | ||
| 64 | + gert::TilingContextPara tilingContextPara( | ||
| 65 | + "DiagPart", | ||
| 66 | + { | ||
| 67 | + {{{16, 16}, {16, 16}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 68 | + }, | ||
| 69 | + { | ||
| 70 | + {{{16}, {16}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 71 | + }, | ||
| 72 | + &compileInfo); | ||
| 73 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +TEST_F(DiagPartTiling, neg_test_invalid_ub_size) | ||
| 77 | +{ | ||
| 78 | + struct DiagPartCompileInfo { | ||
| 79 | + int64_t coreNum = 64; | ||
| 80 | + int64_t ubSize = 0; | ||
| 81 | + }; | ||
| 82 | + | ||
| 83 | + DiagPartCompileInfo compileInfo = {64, 0}; | ||
| 84 | + gert::TilingContextPara tilingContextPara( | ||
| 85 | + "DiagPart", | ||
| 86 | + { | ||
| 87 | + {{{16, 16}, {16, 16}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 88 | + }, | ||
| 89 | + { | ||
| 90 | + {{{16}, {16}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 91 | + }, | ||
| 92 | + &compileInfo); | ||
| 93 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +TEST_F(DiagPartTiling, neg_test_x_dim_odd) | ||
| 97 | +{ | ||
| 98 | + struct DiagPartCompileInfo { | ||
| 99 | + int64_t coreNum = 64; | ||
| 100 | + int64_t ubSize = 253952; | ||
| 101 | + }; | ||
| 102 | + | ||
| 103 | + DiagPartCompileInfo compileInfo = {64, 253952}; | ||
| 104 | + gert::TilingContextPara tilingContextPara( | ||
| 105 | + "DiagPart", | ||
| 106 | + { | ||
| 107 | + {{{16}, {16}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 108 | + }, | ||
| 109 | + { | ||
| 110 | + {{{16}, {16}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 111 | + }, | ||
| 112 | + &compileInfo); | ||
| 113 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +TEST_F(DiagPartTiling, neg_test_x_front_back_half_mismatch) | ||
| 117 | +{ | ||
| 118 | + struct DiagPartCompileInfo { | ||
| 119 | + int64_t coreNum = 64; | ||
| 120 | + int64_t ubSize = 253952; | ||
| 121 | + }; | ||
| 122 | + | ||
| 123 | + DiagPartCompileInfo compileInfo = {64, 253952}; | ||
| 124 | + gert::TilingContextPara tilingContextPara( | ||
| 125 | + "DiagPart", | ||
| 126 | + { | ||
| 127 | + {{{4, 8}, {4, 8}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 128 | + }, | ||
| 129 | + { | ||
| 130 | + {{{4}, {4}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 131 | + }, | ||
| 132 | + &compileInfo); | ||
| 133 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 134 | +} | ||
| 135 | + | ||
| 136 | +TEST_F(DiagPartTiling, neg_test_y_dim_mismatch) | ||
| 137 | +{ | ||
| 138 | + struct DiagPartCompileInfo { | ||
| 139 | + int64_t coreNum = 64; | ||
| 140 | + int64_t ubSize = 253952; | ||
| 141 | + }; | ||
| 142 | + | ||
| 143 | + DiagPartCompileInfo compileInfo = {64, 253952}; | ||
| 144 | + gert::TilingContextPara tilingContextPara( | ||
| 145 | + "DiagPart", | ||
| 146 | + { | ||
| 147 | + {{{4, 4}, {4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 148 | + }, | ||
| 149 | + { | ||
| 150 | + {{{4, 4}, {4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 151 | + }, | ||
| 152 | + &compileInfo); | ||
| 153 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +TEST_F(DiagPartTiling, neg_test_xy_front_dim_mismatch) | ||
| 157 | +{ | ||
| 158 | + struct DiagPartCompileInfo { | ||
| 159 | + int64_t coreNum = 64; | ||
| 160 | + int64_t ubSize = 253952; | ||
| 161 | + }; | ||
| 162 | + | ||
| 163 | + DiagPartCompileInfo compileInfo = {64, 253952}; | ||
| 164 | + gert::TilingContextPara tilingContextPara( | ||
| 165 | + "DiagPart", | ||
| 166 | + { | ||
| 167 | + {{{4, 4}, {4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 168 | + }, | ||
| 169 | + { | ||
| 170 | + {{{8}, {8}}, ge::DT_FLOAT, ge::FORMAT_ND}, | ||
| 171 | + }, | ||
| 172 | + &compileInfo); | ||
| 173 | + ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED); | ||
| 54 | } | 174 | } |