已合并
解决stft超大shape int32溢出问题 #2096
east_yang创建于 4月7日
解决stft超大shape int32溢出问题 #2096
已合并
east_yang创建于 4月7日
1 个文件变更+17-17
@@ -214,9 +214,9 @@ uint32_t STFTGeneralizedTiling::SplitCoresOnN(uint32_t coresNum)
214 return INVALID_CORES_NUM);214 return INVALID_CORES_NUM);
215 215 
216 std::vector<int> factors = iter->second;216 std::vector<int> factors = iter->second;
217- int32_t typeSize = ge::GetSizeByDataType(dtype);217+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
218 OP_CHECK_IF(218 OP_CHECK_IF(
219- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),219+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
220 return ge::GRAPH_FAILED);220 return ge::GRAPH_FAILED);
221 nCoreNum = 0;221 nCoreNum = 0;
222 for (size_t i = 0; i < factors.size(); i++) {222 for (size_t i = 0; i < factors.size(); i++) {
@@ -416,9 +416,9 @@ bool STFTGeneralizedTiling::SplitCores()
416 return true;416 return true;
417 }417 }
418 418 
419- int32_t typeSize = ge::GetSizeByDataType(dtype);419+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
420 OP_CHECK_IF(420 OP_CHECK_IF(
421- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),421+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
422 return ge::GRAPH_FAILED);422 return ge::GRAPH_FAILED);
423 bCoreNum = 1;423 bCoreNum = 1;
424 mCoreNum = 1;424 mCoreNum = 1;
@@ -464,9 +464,9 @@ bool STFTGeneralizedTiling::IsCapable()
464 464 
465uint32_t STFTGeneralizedTiling::CalcMaskUBSize(uint32_t memHasUsed) const465uint32_t STFTGeneralizedTiling::CalcMaskUBSize(uint32_t memHasUsed) const
466{466{
467- int32_t typeSize = ge::GetSizeByDataType(dtype);467+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
468 OP_CHECK_IF(468 OP_CHECK_IF(
469- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),469+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
470 return ge::GRAPH_FAILED);470 return ge::GRAPH_FAILED);
471 uint32_t ubLeft = ubSize - memHasUsed;471 uint32_t ubLeft = ubSize - memHasUsed;
472 uint32_t count = ubLeft / (4 * typeSize + DWORD_SIZE * 2);472 uint32_t count = ubLeft / (4 * typeSize + DWORD_SIZE * 2);
@@ -476,9 +476,9 @@ uint32_t STFTGeneralizedTiling::CalcMaskUBSize(uint32_t memHasUsed) const
476 476 
477uint32_t STFTGeneralizedTiling::CalcCopyUBSize() const477uint32_t STFTGeneralizedTiling::CalcCopyUBSize() const
478{478{
479- int32_t typeSize = ge::GetSizeByDataType(dtype);479+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
480 OP_CHECK_IF(480 OP_CHECK_IF(
481- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),481+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
482 return ge::GRAPH_FAILED);482 return ge::GRAPH_FAILED);
483 uint32_t ubLeft = ubSize - GATHER_MASK_UB_SIZE;483 uint32_t ubLeft = ubSize - GATHER_MASK_UB_SIZE;
484 uint32_t count = GATHER_MASK_UB_SIZE / DWORD_SIZE;484 uint32_t count = GATHER_MASK_UB_SIZE / DWORD_SIZE;
@@ -488,9 +488,9 @@ uint32_t STFTGeneralizedTiling::CalcCopyUBSize() const
488 488 
489uint32_t STFTGeneralizedTiling::CalcComplexCopyUBSize() const489uint32_t STFTGeneralizedTiling::CalcComplexCopyUBSize() const
490{490{
491- int32_t typeSize = ge::GetSizeByDataType(dtype);491+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
492 OP_CHECK_IF(492 OP_CHECK_IF(
493- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),493+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
494 return ge::GRAPH_FAILED);494 return ge::GRAPH_FAILED);
495 uint32_t ubLeft = ubSize - GATHER_MASK_COMPLEX_UB_SIZE;495 uint32_t ubLeft = ubSize - GATHER_MASK_COMPLEX_UB_SIZE;
496 uint32_t count = GATHER_MASK_COMPLEX_UB_SIZE / DWORD_SIZE;496 uint32_t count = GATHER_MASK_COMPLEX_UB_SIZE / DWORD_SIZE;
@@ -500,9 +500,9 @@ uint32_t STFTGeneralizedTiling::CalcComplexCopyUBSize() const
500 500 
501uint32_t STFTGeneralizedTiling::CalcComplexUBLoop() const501uint32_t STFTGeneralizedTiling::CalcComplexUBLoop() const
502{502{
503- int32_t typeSize = ge::GetSizeByDataType(dtype);503+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
504 OP_CHECK_IF(504 OP_CHECK_IF(
505- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),505+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
506 return ge::GRAPH_FAILED);506 return ge::GRAPH_FAILED);
507 uint32_t copyUBSize = CalcComplexCopyUBSize() / 2;507 uint32_t copyUBSize = CalcComplexCopyUBSize() / 2;
508 uint32_t ubLoop = 1;508 uint32_t ubLoop = 1;
@@ -521,7 +521,7 @@ uint32_t STFTGeneralizedTiling::CalcComplexUBLoop() const
521 521 
522void STFTGeneralizedTiling::SplitWindowTiling()522void STFTGeneralizedTiling::SplitWindowTiling()
523{523{
524- int32_t typeSize = ge::GetSizeByDataType(dtype);524+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
525 if (typeSize <= 0) {525 if (typeSize <= 0) {
526 typeSize = 1;526 typeSize = 1;
527 }527 }
@@ -588,9 +588,9 @@ ge::graphStatus STFTGeneralizedTiling::DoOpTiling()
588 tilingData.set_batch(batch);588 tilingData.set_batch(batch);
589 tilingData.set_inputSize(inputSize);589 tilingData.set_inputSize(inputSize);
590 tilingData.set_nfft(nfft);590 tilingData.set_nfft(nfft);
591- int32_t typeSize = ge::GetSizeByDataType(dtype);591+ uint32_t typeSize = ge::GetSizeByDataType(dtype);
592 OP_CHECK_IF(592 OP_CHECK_IF(
593- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),593+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %u, please check.", typeSize),
594 return ge::GRAPH_FAILED);594 return ge::GRAPH_FAILED);
595 nfftAlign = (nfft * typeSize + PACKAGE_SIZE - 1) / PACKAGE_SIZE * PACKAGE_SIZE / typeSize;595 nfftAlign = (nfft * typeSize + PACKAGE_SIZE - 1) / PACKAGE_SIZE * PACKAGE_SIZE / typeSize;
596 tilingData.set_nfftAlign(nfftAlign);596 tilingData.set_nfftAlign(nfftAlign);
@@ -725,9 +725,9 @@ ge::graphStatus STFTGeneralizedTiling::GetWorkspaceSize()
725 // 每块workspace地址需要512B对齐725 // 每块workspace地址需要512B对齐
726 // 第0块workspace用于存储按照窗口拆分之后的input data726 // 第0块workspace用于存储按照窗口拆分之后的input data
727 // 按照nfft block对齐之后的大小727 // 按照nfft block对齐之后的大小
728- int32_t typeSize = ge::GetSizeByDataType(dtype);728+ uint64_t typeSize = ge::GetSizeByDataType(dtype);
729 OP_CHECK_IF(729 OP_CHECK_IF(
730- (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %d, please check.", typeSize),730+ (typeSize <= 0), OP_LOGE(context_->GetNodeName(), "typeSize is invalid %lu, please check.", typeSize),
731 return ge::GRAPH_FAILED);731 return ge::GRAPH_FAILED);
732 732 
733 size_t splitWindowWorkspaceSize =733 size_t splitWindowWorkspaceSize =