已合并
foreach_asin arch35 tiling 添加 GetPlatformInfoFallback逻辑,解决 GetCompileInfo 返回空指针导致 PTA 调用失败问题 #7358
surezz创建于 7月10日
foreach_asin arch35 tiling 添加 GetPlatformInfoFallback逻辑,解决 GetCompileInfo 返回空指针导致 PTA 调用失败问题 #7358
已合并
surezz创建于 7月10日
1 个文件变更+27-6
@@ -36,18 +36,39 @@ struct ForeachAsinCompileInfo {
36 int64_t ubSize;36 int64_t ubSize;
37};37};
38 38 
39+static ge::graphStatus GetPlatformInfoFallback(gert::TilingContext* context, int64_t& coreNum, int64_t& ubSize)
40+{
41+ auto compileInfo = reinterpret_cast<const ForeachAsinCompileInfo*>(context->GetCompileInfo());
42+ if (compileInfo != nullptr && compileInfo->coreNum > 0 && compileInfo->ubSize > 0) {
43+ coreNum = compileInfo->coreNum;
44+ ubSize = compileInfo->ubSize;
45+ return ge::GRAPH_SUCCESS;
46+ }
47+ fe::PlatFormInfos* platformInfoPtr = context->GetPlatformInfo();
48+ if (platformInfoPtr != nullptr) {
49+ auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfoPtr);
50+ coreNum = ascendcPlatform.GetCoreNumAiv();
51+ uint64_t ub = 0;
52+ ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ub);
53+ ubSize = static_cast<int64_t>(ub);
54+ if (coreNum > 0 && ubSize > 0) {
55+ return ge::GRAPH_SUCCESS;
56+ }
57+ }
58+ return ge::GRAPH_FAILED;
59+}
60+ 
39/**61/**
40 * @brief Tiling 主函数:计算切分参数并设置 tiling data62 * @brief Tiling 主函数:计算切分参数并设置 tiling data
41 */63 */
42static ge::graphStatus ForeachAsinTilingFunc(gert::TilingContext* context)64static ge::graphStatus ForeachAsinTilingFunc(gert::TilingContext* context)
43{65{
44 // 1. 获取平台信息66 // 1. 获取平台信息
45- auto compileInfo = reinterpret_cast<const ForeachAsinCompileInfo*>(context->GetCompileInfo());67+ int64_t maxCoreNum = 0;
46- OP_CHECK_NULL_WITH_CONTEXT(context, compileInfo);68+ int64_t ubSize = 0;
47- int64_t maxCoreNum = compileInfo->coreNum;69+ OP_CHECK_IF(GetPlatformInfoFallback(context, maxCoreNum, ubSize) != ge::GRAPH_SUCCESS,
48- int64_t ubSize = compileInfo->ubSize;70+ OP_LOGE(context, "Failed to get platform info"), return ge::GRAPH_FAILED);
49- OP_CHECK_IF((ubSize <= DCACHE_SIZE),71+ OP_CHECK_IF((ubSize <= DCACHE_SIZE), OP_LOGE(context, "ub size less than DCache Size"), return ge::GRAPH_FAILED);
50- OP_LOGE(context, "ub size less than DCache Size"), return ge::GRAPH_FAILED);
51 int64_t ubSizeActual = ubSize - DCACHE_SIZE;72 int64_t ubSizeActual = ubSize - DCACHE_SIZE;
52 73 
53 // 2. 获取输入 tensor 列表信息74 // 2. 获取输入 tensor 列表信息