已合并
fix transpose 021 profiling #3705
jzj007创建于 7月2日
fix transpose 021 profiling #3705
已合并
共 2 个文件变更+188-166
| @@ -30,21 +30,19 @@ ge::graphStatus TransposeNddmaTiling::Init(const int64_t& coreNum, const int64_t | |||
| 30 | { | 30 | { |
| 31 | OP_LOGD(tilingContext_->GetNodeName(), "Start init TransposeNddmaTiling."); | 31 | OP_LOGD(tilingContext_->GetNodeName(), "Start init TransposeNddmaTiling."); |
| 32 | coreNum_ = coreNum; | 32 | coreNum_ = coreNum; |
| 33 | - OP_CHECK_IF( | 33 | + OP_CHECK_IF((coreNum_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get core num."), |
| 34 | - (coreNum_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get core num."), return ge::GRAPH_FAILED); | 34 | + return ge::GRAPH_FAILED); |
| 35 | ubSize_ = ubSize; | 35 | ubSize_ = ubSize; |
| 36 | - OP_CHECK_IF( | 36 | + OP_CHECK_IF((ubSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub size."), |
| 37 | - (ubSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub size."), return ge::GRAPH_FAILED); | 37 | + return ge::GRAPH_FAILED); |
| 38 | 38 | ||
| 39 | cacheLineSize_ = Ops::Base::GetCacheLineSize(tilingContext_); | 39 | cacheLineSize_ = Ops::Base::GetCacheLineSize(tilingContext_); |
| 40 | - OP_CHECK_IF( | 40 | + OP_CHECK_IF((cacheLineSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get cache line size."), |
| 41 | - (cacheLineSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get cache line size."), | 41 | + return ge::GRAPH_FAILED); |
| 42 | - return ge::GRAPH_FAILED); | ||
| 43 | 42 | ||
| 44 | ubBlockSize_ = Ops::Base::GetUbBlockSize(tilingContext_); | 43 | ubBlockSize_ = Ops::Base::GetUbBlockSize(tilingContext_); |
| 45 | - OP_CHECK_IF( | 44 | + OP_CHECK_IF((ubBlockSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub block size."), |
| 46 | - (ubBlockSize_ <= 0), OP_LOGE(tilingContext_->GetNodeName(), "Failed to get ub block size."), | 45 | + return ge::GRAPH_FAILED); |
| 47 | - return ge::GRAPH_FAILED); | ||
| 48 | return ge::GRAPH_SUCCESS; | 46 | return ge::GRAPH_SUCCESS; |
| 49 | } | 47 | } |
| 50 | 48 | ||
| @@ -52,9 +50,8 @@ ge::graphStatus TransposeNddmaTiling::RunTranposelTiling() | |||
| 52 | { | 50 | { |
| 53 | OP_LOGD(tilingContext_->GetNodeName(), "Start running Tiling4Transpose."); | 51 | OP_LOGD(tilingContext_->GetNodeName(), "Start running Tiling4Transpose."); |
| 54 | if (!isReleatedTranspsoe_) { | 52 | if (!isReleatedTranspsoe_) { |
| 55 | - OP_CHECK_IF( | 53 | + OP_CHECK_IF(GetShapeInfo() != ge::GRAPH_SUCCESS, |
| 56 | - GetShapeInfo() != ge::GRAPH_SUCCESS, OP_LOGE(tilingContext_->GetNodeName(), "Failed to get shape info!"), | 54 | + OP_LOGE(tilingContext_->GetNodeName(), "Failed to get shape info!"), return ge::GRAPH_FAILED); |
| 57 | - return ge::GRAPH_FAILED); | ||
| 58 | } | 55 | } |
| 59 | 56 | ||
| 60 | auto ret = CheckShapeInfo(); | 57 | auto ret = CheckShapeInfo(); |
| @@ -68,17 +65,15 @@ ge::graphStatus TransposeNddmaTiling::RunTranposelTiling() | |||
| 68 | CHECK_RET_SUCC(ret); | 65 | CHECK_RET_SUCC(ret); |
| 69 | 66 | ||
| 70 | CalcTotalVolumeActual(); | 67 | CalcTotalVolumeActual(); |
| 71 | - OP_CHECK_IF( | 68 | + OP_CHECK_IF(TryVCONVTiling() == ge::GRAPH_SUCCESS, OP_LOGD(tilingContext_->GetNodeName(), "Do convTiling success"), |
| 72 | - TryVCONVTiling() == ge::GRAPH_SUCCESS, OP_LOGD(tilingContext_->GetNodeName(), "Do convTiling success"), | 69 | + return ge::GRAPH_SUCCESS); |
| 73 | - return ge::GRAPH_SUCCESS); | ||
| 74 | 70 | ||
| 75 | SetIsLastAxisTranspose(); | 71 | SetIsLastAxisTranspose(); |
| 76 | if (!isReleatedTranspsoe_ && shapeInfo_.isLastAxisTranspose) { | 72 | if (!isReleatedTranspsoe_ && shapeInfo_.isLastAxisTranspose) { |
| 77 | TransWithGather::PlatInfo platInfo{coreNum_, ubSize_, cacheLineSize_, ubBlockSize_}; | 73 | TransWithGather::PlatInfo platInfo{coreNum_, ubSize_, cacheLineSize_, ubBlockSize_}; |
| 78 | TransWithGather::TransposeGatherTiling gatherTiling(tilingContext_, platInfo, shapeInfo_); | 74 | TransWithGather::TransposeGatherTiling gatherTiling(tilingContext_, platInfo, shapeInfo_); |
| 79 | - OP_CHECK_IF( | 75 | + OP_CHECK_IF(gatherTiling.DoTiling() == ge::GRAPH_SUCCESS, |
| 80 | - gatherTiling.DoTiling() == ge::GRAPH_SUCCESS, | 76 | + OP_LOGD(tilingContext_->GetNodeName(), "Do gather tiling done!"), return ge::GRAPH_SUCCESS); |
| 81 | - OP_LOGD(tilingContext_->GetNodeName(), "Do gather tiling done!"), return ge::GRAPH_SUCCESS); | ||
| 82 | } | 77 | } |
| 83 | 78 | ||
| 84 | // ensure tiling template | 79 | // ensure tiling template |
| @@ -119,29 +114,56 @@ ge::graphStatus TransposeNddmaTiling::TryVCONVTiling() | |||
| 119 | shapeInfo_.eleLenInBytes == VCONV_DSIZE && shapeInfo_.reducedInShape[0] > DIM_FIVE) { | 114 | shapeInfo_.eleLenInBytes == VCONV_DSIZE && shapeInfo_.reducedInShape[0] > DIM_FIVE) { |
| 120 | TransposeWithVCONV::PlatInfo platInfo{coreNum_, ubSize_}; | 115 | TransposeWithVCONV::PlatInfo platInfo{coreNum_, ubSize_}; |
| 121 | TransposeWithVCONV::TransposeVCONVTiling vconvTiling(tilingContext_, platInfo, shapeInfo_); | 116 | TransposeWithVCONV::TransposeVCONVTiling vconvTiling(tilingContext_, platInfo, shapeInfo_); |
| 122 | - OP_CHECK_IF( | 117 | + OP_CHECK_IF(vconvTiling.DoTiling() == ge::GRAPH_SUCCESS, |
| 123 | - vconvTiling.DoTiling() == ge::GRAPH_SUCCESS, | 118 | + OP_LOGD(tilingContext_->GetNodeName(), "Do convTiling done"), return ge::GRAPH_SUCCESS); |
| 124 | - OP_LOGD(tilingContext_->GetNodeName(), "Do convTiling done"), return ge::GRAPH_SUCCESS); | ||
| 125 | } | 119 | } |
| 126 | - if (shapeInfo_.reducedPerm[0] == 0 && shapeInfo_.reducedPerm[DIM_ONE] == VCONV_DIM_NUM && shapeInfo_.reducedPerm[DIM_TWO] == 1 && | 120 | + if (Is021VConvValid()) { |
| 127 | - shapeInfo_.dim == DIM_THREE // 021 transpose | ||
| 128 | - && (shapeInfo_.eleLenInBytes == B8_BYTES || shapeInfo_.eleLenInBytes == B16_BYTES || | ||
| 129 | - shapeInfo_.eleLenInBytes == B32_BYTES) // support B8、B16、B32 | ||
| 130 | - && shapeInfo_.reducedInShape[DIM_ONE] > DIM_EIGHT && | ||
| 131 | - shapeInfo_.reducedInShape[DIM_TWO] > DIM_EIGHT // not support very little W or H | ||
| 132 | - && shapeInfo_.totalVolumeActual * shapeInfo_.eleLenInBytes >= | ||
| 133 | - SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_021 // shape size bigger than 7w | ||
| 134 | - ) { | ||
| 135 | Transpose021WithVCONV::PlatInfo platInfo{coreNum_, ubSize_}; | 121 | Transpose021WithVCONV::PlatInfo platInfo{coreNum_, ubSize_}; |
| 136 | Transpose021WithVCONV::Transpose021VCONVTiling vconv021Tiling(tilingContext_, platInfo, shapeInfo_); | 122 | Transpose021WithVCONV::Transpose021VCONVTiling vconv021Tiling(tilingContext_, platInfo, shapeInfo_); |
| 137 | - OP_CHECK_IF( | 123 | + OP_CHECK_IF(vconv021Tiling.DoTiling() == ge::GRAPH_SUCCESS, |
| 138 | - vconv021Tiling.DoTiling() == ge::GRAPH_SUCCESS, | 124 | + OP_LOGD(tilingContext_->GetNodeName(), "Do 021 convTiling done"), return ge::GRAPH_SUCCESS); |
| 139 | - OP_LOGD(tilingContext_->GetNodeName(), "Do 021 convTiling done"), return ge::GRAPH_SUCCESS); | ||
| 140 | } | 125 | } |
| 141 | } | 126 | } |
| 142 | return ge::GRAPH_FAILED; | 127 | return ge::GRAPH_FAILED; |
| 143 | } | 128 | } |
| 144 | 129 | ||
| 130 | +bool TransposeNddmaTiling::Is021VConvValid() | ||
| 131 | +{ | ||
| 132 | + // check perm: 021 transpose | ||
| 133 | + if (!(shapeInfo_.reducedPerm[0] == 0 && shapeInfo_.reducedPerm[DIM_ONE] == VCONV_DIM_NUM && | ||
| 134 | + shapeInfo_.reducedPerm[DIM_TWO] == 1)) { | ||
| 135 | + return false; | ||
| 136 | + } | ||
| 137 | + // check dim | ||
| 138 | + if (shapeInfo_.dim != DIM_THREE) { | ||
| 139 | + return false; | ||
| 140 | + } | ||
| 141 | + // check dtype: support B8、B16、B32 | ||
| 142 | + if (!(shapeInfo_.eleLenInBytes == B8_BYTES || shapeInfo_.eleLenInBytes == B16_BYTES || | ||
| 143 | + shapeInfo_.eleLenInBytes == B32_BYTES)) { | ||
| 144 | + return false; | ||
| 145 | + } | ||
| 146 | + // check HW shape | ||
| 147 | + int64_t H = shapeInfo_.reducedInShape[DIM_ONE]; | ||
| 148 | + int64_t W = shapeInfo_.reducedInShape[DIM_TWO]; | ||
| 149 | + if (H <= DIM_EIGHT || W <= DIM_EIGHT) { | ||
| 150 | + return false; | ||
| 151 | + } | ||
| 152 | + if (H * W < HW_MIN_PRODUCT) { | ||
| 153 | + return false; | ||
| 154 | + } | ||
| 155 | + int64_t hAlign = Ops::Base::CeilDiv(H, HW_ALIGN) * HW_ALIGN; | ||
| 156 | + int64_t wAlign = Ops::Base::CeilDiv(W, HW_ALIGN) * HW_ALIGN; | ||
| 157 | + if (H * W <= hAlign * wAlign / DIM_TWO) { | ||
| 158 | + return false; | ||
| 159 | + } | ||
| 160 | + // check total volume | ||
| 161 | + if (shapeInfo_.totalVolumeActual * shapeInfo_.eleLenInBytes < SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_021) { | ||
| 162 | + return false; | ||
| 163 | + } | ||
| 164 | + return true; | ||
| 165 | +} | ||
| 166 | + | ||
| 145 | template <typename T> | 167 | template <typename T> |
| 146 | bool TransposeNddmaTiling::GetPerm(const gert::Tensor* permTensor) | 168 | bool TransposeNddmaTiling::GetPerm(const gert::Tensor* permTensor) |
| 147 | { | 169 | { |
| @@ -191,9 +213,8 @@ ge::graphStatus TransposeNddmaTiling::GetShapeInfo() | |||
| 191 | return ge::GRAPH_FAILED; | 213 | return ge::GRAPH_FAILED; |
| 192 | } | 214 | } |
| 193 | } else { | 215 | } else { |
| 194 | - OP_LOGE_FOR_INVALID_DTYPE( | 216 | + OP_LOGE_FOR_INVALID_DTYPE(tilingContext_->GetNodeName(), "perm", |
| 195 | - tilingContext_->GetNodeName(), "perm", ge::TypeUtils::DataTypeToSerialString(permDtype).c_str(), | 217 | + ge::TypeUtils::DataTypeToSerialString(permDtype).c_str(), "int32 or int64"); |
| 196 | - "int32 or int64"); | ||
| 197 | return ge::GRAPH_FAILED; | 218 | return ge::GRAPH_FAILED; |
| 198 | } | 219 | } |
| 199 | 220 | ||
| @@ -225,23 +246,20 @@ ge::graphStatus TransposeNddmaTiling::CheckShapeDims() | |||
| 225 | int64_t inDims = shapeInfo_.inShapeSize; | 246 | int64_t inDims = shapeInfo_.inShapeSize; |
| 226 | int64_t outDims = shapeInfo_.outShapeSize; | 247 | int64_t outDims = shapeInfo_.outShapeSize; |
| 227 | int64_t permDims = shapeInfo_.permSize; | 248 | int64_t permDims = shapeInfo_.permSize; |
| 228 | - OP_CHECK_IF( | 249 | + OP_CHECK_IF(inDims < 1, |
| 229 | - inDims < 1, | 250 | + OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON(tilingContext_->GetNodeName(), "x", |
| 230 | - OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON( | 251 | + std::to_string(inDims).c_str(), "positive"), |
| 231 | - tilingContext_->GetNodeName(), "x", std::to_string(inDims).c_str(), "positive"), | 252 | + return ge::GRAPH_FAILED); |
| 232 | - return ge::GRAPH_FAILED); | 253 | + OP_CHECK_IF(inDims != outDims, |
| 233 | - OP_CHECK_IF( | 254 | + OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON(tilingContext_->GetNodeName(), "x and y", |
| 234 | - inDims != outDims, | 255 | + Ops::Math::Join(inDims, outDims).c_str(), |
| 235 | - OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON( | 256 | + "The shape dims of x and y must be the same"), |
| 236 | - tilingContext_->GetNodeName(), "x and y", Ops::Math::Join(inDims, outDims).c_str(), | 257 | + return ge::GRAPH_FAILED); |
| 237 | - "The shape dims of x and y must be the same"), | 258 | + OP_CHECK_IF(inDims != permDims, |
| 238 | - return ge::GRAPH_FAILED); | 259 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( |
| 239 | - OP_CHECK_IF( | 260 | + tilingContext_->GetNodeName(), "perm", std::to_string(permDims).c_str(), |
| 240 | - inDims != permDims, | 261 | + "The total number of elements of perm must be equal to the shape dim of x"), |
| 241 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( | 262 | + return ge::GRAPH_FAILED); |
| 242 | - tilingContext_->GetNodeName(), "perm", std::to_string(permDims).c_str(), | ||
| 243 | - "The total number of elements of perm must be equal to the shape dim of x"), | ||
| 244 | - return ge::GRAPH_FAILED); | ||
| 245 | return ge::GRAPH_SUCCESS; | 263 | return ge::GRAPH_SUCCESS; |
| 246 | } | 264 | } |
| 247 | 265 | ||
| @@ -252,9 +270,9 @@ ge::graphStatus TransposeNddmaTiling::CheckShapeInfo() | |||
| 252 | 270 | ||
| 253 | for (int64_t i = 0; i < shapeInfo_.inShapeSize; i++) { | 271 | for (int64_t i = 0; i < shapeInfo_.inShapeSize; i++) { |
| 254 | if (shapeInfo_.perm[i] >= shapeInfo_.inShapeSize) { | 272 | if (shapeInfo_.perm[i] >= shapeInfo_.inShapeSize) { |
| 255 | - OP_LOGE_FOR_INVALID_VALUE_WITH_REASON( | 273 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(tilingContext_->GetNodeName(), "perm", |
| 256 | - tilingContext_->GetNodeName(), "perm", std::to_string(shapeInfo_.perm[i]).c_str(), | 274 | + std::to_string(shapeInfo_.perm[i]).c_str(), |
| 257 | - "The value of perm must be less than shape dim of x"); | 275 | + "The value of perm must be less than shape dim of x"); |
| 258 | return ge::GRAPH_FAILED; | 276 | return ge::GRAPH_FAILED; |
| 259 | } | 277 | } |
| 260 | if (shapeInfo_.inShape[shapeInfo_.perm[i]] != shapeInfo_.outShape[i]) { | 278 | if (shapeInfo_.inShape[shapeInfo_.perm[i]] != shapeInfo_.outShape[i]) { |
| @@ -273,15 +291,15 @@ ge::graphStatus TransposeNddmaTiling::CheckShapeInfo() | |||
| 273 | 291 | ||
| 274 | for (int64_t i = 0; i < shapeInfo_.inShapeSize; i++) { | 292 | for (int64_t i = 0; i < shapeInfo_.inShapeSize; i++) { |
| 275 | if (shapeInfo_.inShape[i] <= 0) { | 293 | if (shapeInfo_.inShape[i] <= 0) { |
| 276 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( | 294 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(tilingContext_->GetNodeName(), "x", |
| 277 | - tilingContext_->GetNodeName(), "x", std::to_string(shapeInfo_.inShape[i]).c_str(), | 295 | + std::to_string(shapeInfo_.inShape[i]).c_str(), |
| 278 | - "All axes of x must be positive numbers"); | 296 | + "All axes of x must be positive numbers"); |
| 279 | return ge::GRAPH_FAILED; | 297 | return ge::GRAPH_FAILED; |
| 280 | } | 298 | } |
| 281 | if (shapeInfo_.outShape[i] <= 0) { | 299 | if (shapeInfo_.outShape[i] <= 0) { |
| 282 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON( | 300 | + OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(tilingContext_->GetNodeName(), "y", |
| 283 | - tilingContext_->GetNodeName(), "y", std::to_string(shapeInfo_.outShape[i]).c_str(), | 301 | + std::to_string(shapeInfo_.outShape[i]).c_str(), |
| 284 | - "All axes of y must be positive numbers"); | 302 | + "All axes of y must be positive numbers"); |
| 285 | return ge::GRAPH_FAILED; | 303 | return ge::GRAPH_FAILED; |
| 286 | } | 304 | } |
| 287 | } | 305 | } |
| @@ -300,9 +318,8 @@ ge::graphStatus TransposeNddmaTiling::CheckReducedShapeInfo() | |||
| 300 | 318 | ||
| 301 | for (int64_t i = 0; i < dim; i++) { | 319 | for (int64_t i = 0; i < dim; i++) { |
| 302 | if (shapeInfo_.reducedInShape[i] <= 0 || shapeInfo_.reducedOutShape[i] <= 0) { | 320 | if (shapeInfo_.reducedInShape[i] <= 0 || shapeInfo_.reducedOutShape[i] <= 0) { |
| 303 | - OP_LOGE( | 321 | + OP_LOGE(tilingContext_->GetNodeName(), "Invalid shape, index is %ld, inShape is %ld, outShape is %ld", i, |
| 304 | - tilingContext_->GetNodeName(), "Invalid shape, index is %ld, inShape is %ld, outShape is %ld", i, | 322 | + shapeInfo_.reducedInShape[i], shapeInfo_.reducedOutShape[i]); |
| 305 | - shapeInfo_.reducedInShape[i], shapeInfo_.reducedOutShape[i]); | ||
| 306 | return ge::GRAPH_FAILED; | 323 | return ge::GRAPH_FAILED; |
| 307 | } | 324 | } |
| 308 | } | 325 | } |
| @@ -320,8 +337,8 @@ int64_t TransposeNddmaTiling::DoSplitUBInput() | |||
| 320 | splitInfo_.inUbFactor = splitInfo_.inUbElement; | 337 | splitInfo_.inUbFactor = splitInfo_.inUbElement; |
| 321 | splitInfo_.inTailFactor = currentShapeDim % splitInfo_.inUbFactor; | 338 | splitInfo_.inTailFactor = currentShapeDim % splitInfo_.inUbFactor; |
| 322 | splitInfo_.inUbActual *= splitInfo_.inUbElement; | 339 | splitInfo_.inUbActual *= splitInfo_.inUbElement; |
| 323 | - remainingTotalElment = | 340 | + remainingTotalElment = remainingTotalElment / currentShapeDim * |
| 324 | - remainingTotalElment / currentShapeDim * Ops::Base::CeilDiv(currentShapeDim, splitInfo_.inUbElement); | 341 | + Ops::Base::CeilDiv(currentShapeDim, splitInfo_.inUbElement); |
| 325 | break; | 342 | break; |
| 326 | } else { | 343 | } else { |
| 327 | splitInfo_.inUbElement /= currentShapeDim; | 344 | splitInfo_.inUbElement /= currentShapeDim; |
| @@ -354,8 +371,8 @@ bool TransposeNddmaTiling::UbOutOfBoundCheck(int64_t currentSplitIndex, int64_t | |||
| 354 | if (calcIn && shapeInfo_.reducedPerm[currentSplitIndex] == splitInfo_.inCutIndex) { | 371 | if (calcIn && shapeInfo_.reducedPerm[currentSplitIndex] == splitInfo_.inCutIndex) { |
| 355 | burstLenBlockAlign *= splitInfo_.inUbFactor; | 372 | burstLenBlockAlign *= splitInfo_.inUbFactor; |
| 356 | } | 373 | } |
| 357 | - burstLenBlockAlign = | 374 | + burstLenBlockAlign = Ops::Base::CeilAlign(burstLenBlockAlign * shapeInfo_.eleLenInBytes, ubBlockSize_) / |
| 358 | - Ops::Base::CeilAlign(burstLenBlockAlign * shapeInfo_.eleLenInBytes, ubBlockSize_) / shapeInfo_.eleLenInBytes; | 375 | + shapeInfo_.eleLenInBytes; |
| 359 | int64_t inUbElements = burstLenBlockAlign; | 376 | int64_t inUbElements = burstLenBlockAlign; |
| 360 | for (int64_t i = 0; i < currentSplitIndex; i++) { | 377 | for (int64_t i = 0; i < currentSplitIndex; i++) { |
| 361 | if (shapeInfo_.reducedPerm[i] > splitInfo_.inCutIndex) { | 378 | if (shapeInfo_.reducedPerm[i] > splitInfo_.inCutIndex) { |
| @@ -378,8 +395,8 @@ bool TransposeNddmaTiling::UbOutOfBoundCheckNLast(int64_t currentSplitIndex, int | |||
| 378 | } else { | 395 | } else { |
| 379 | burstLenBlockAlign = shapeInfo_.reducedInShape[shapeInfo_.dim - 1]; | 396 | burstLenBlockAlign = shapeInfo_.reducedInShape[shapeInfo_.dim - 1]; |
| 380 | } | 397 | } |
| 381 | - burstLenBlockAlign = | 398 | + burstLenBlockAlign = Ops::Base::CeilAlign(burstLenBlockAlign * shapeInfo_.eleLenInBytes, ubBlockSize_) / |
| 382 | - Ops::Base::CeilAlign(burstLenBlockAlign * shapeInfo_.eleLenInBytes, ubBlockSize_) / shapeInfo_.eleLenInBytes; | 399 | + shapeInfo_.eleLenInBytes; |
| 383 | int64_t inUbElements = burstLenBlockAlign; | 400 | int64_t inUbElements = burstLenBlockAlign; |
| 384 | for (int64_t i = currentSplitIndex; i < shapeInfo_.dim - 1; i++) { | 401 | for (int64_t i = currentSplitIndex; i < shapeInfo_.dim - 1; i++) { |
| 385 | if (i == currentSplitIndex) { | 402 | if (i == currentSplitIndex) { |
| @@ -394,8 +411,8 @@ bool TransposeNddmaTiling::UbOutOfBoundCheckNLast(int64_t currentSplitIndex, int | |||
| 394 | return false; | 411 | return false; |
| 395 | } | 412 | } |
| 396 | 413 | ||
| 397 | -void TransposeNddmaTiling::FindSplitFactorByRateNLast( | 414 | +void TransposeNddmaTiling::FindSplitFactorByRateNLast(int64_t currentSplitIndex, int64_t currentInShapeDim, |
| 398 | - int64_t currentSplitIndex, int64_t currentInShapeDim, int64_t remainingTotalElment) | 415 | + int64_t remainingTotalElment) |
| 399 | { | 416 | { |
| 400 | splitInfo_.inCutIndex = currentSplitIndex; | 417 | splitInfo_.inCutIndex = currentSplitIndex; |
| 401 | splitInfo_.inUbFactor = 1; | 418 | splitInfo_.inUbFactor = 1; |
| @@ -412,8 +429,8 @@ void TransposeNddmaTiling::FindSplitFactorByRateNLast( | |||
| 412 | } | 429 | } |
| 413 | } | 430 | } |
| 414 | 431 | ||
| 415 | -void TransposeNddmaTiling::FindSplitFactorByMultiplesLast( | 432 | +void TransposeNddmaTiling::FindSplitFactorByMultiplesLast(int64_t currentSplitIndex, int64_t currentShapeDim, |
| 416 | - int64_t currentSplitIndex, int64_t currentShapeDim, int64_t remainingTotalElment, int64_t coreNumMultiples) | 433 | + int64_t remainingTotalElment, int64_t coreNumMultiples) |
| 417 | { | 434 | { |
| 418 | splitInfo_.outCutIndex = currentSplitIndex; | 435 | splitInfo_.outCutIndex = currentSplitIndex; |
| 419 | int64_t bestI = 1; | 436 | int64_t bestI = 1; |
| @@ -435,8 +452,8 @@ void TransposeNddmaTiling::FindSplitFactorByMultiplesLast( | |||
| 435 | splitInfo_.outUbActual *= bestI; | 452 | splitInfo_.outUbActual *= bestI; |
| 436 | } | 453 | } |
| 437 | 454 | ||
| 438 | -void TransposeNddmaTiling::FindSplitFactorByMultiplesNLast( | 455 | +void TransposeNddmaTiling::FindSplitFactorByMultiplesNLast(int64_t currentSplitIndex, int64_t currentInShapeDim, |
| 439 | - int64_t currentSplitIndex, int64_t currentInShapeDim, int64_t remainingTotalElment, int64_t coreNumMultiples) | 456 | + int64_t remainingTotalElment, int64_t coreNumMultiples) |
| 440 | { | 457 | { |
| 441 | splitInfo_.inCutIndex = currentSplitIndex; | 458 | splitInfo_.inCutIndex = currentSplitIndex; |
| 442 | for (int64_t i = splitInfo_.inUbElement; i >= 1; i--) { | 459 | for (int64_t i = splitInfo_.inUbElement; i >= 1; i--) { |
| @@ -471,16 +488,16 @@ void TransposeNddmaTiling::DoSplitUB() | |||
| 471 | } | 488 | } |
| 472 | int64_t currentShapeDim = shapeInfo_.reducedOutShape[currentSplitIndex]; | 489 | int64_t currentShapeDim = shapeInfo_.reducedOutShape[currentSplitIndex]; |
| 473 | if (shapeInfo_.reducedPerm[currentSplitIndex] == splitInfo_.inCutIndex) { | 490 | if (shapeInfo_.reducedPerm[currentSplitIndex] == splitInfo_.inCutIndex) { |
| 474 | - currentShapeDim = | 491 | + currentShapeDim = Ops::Base::CeilDiv(shapeInfo_.reducedInShape[splitInfo_.inCutIndex], |
| 475 | - Ops::Base::CeilDiv(shapeInfo_.reducedInShape[splitInfo_.inCutIndex], splitInfo_.inUbFactor); | 492 | + splitInfo_.inUbFactor); |
| 476 | } | 493 | } |
| 477 | remainingTotalElment /= currentShapeDim; | 494 | remainingTotalElment /= currentShapeDim; |
| 478 | int64_t coreNumTmp = remainingTotalElment * Ops::Base::CeilDiv(currentShapeDim, splitInfo_.outUbElement); | 495 | int64_t coreNumTmp = remainingTotalElment * Ops::Base::CeilDiv(currentShapeDim, splitInfo_.outUbElement); |
| 479 | if (splitInfo_.outUbElement < currentShapeDim) { | 496 | if (splitInfo_.outUbElement < currentShapeDim) { |
| 480 | if (coreNumTmp > coreNum_) { // use full coreNum | 497 | if (coreNumTmp > coreNum_) { // use full coreNum |
| 481 | int64_t coreNumMultiples = Ops::Base::FloorDiv(coreNumTmp, coreNum_); | 498 | int64_t coreNumMultiples = Ops::Base::FloorDiv(coreNumTmp, coreNum_); |
| 482 | - FindSplitFactorByMultiplesLast( | 499 | + FindSplitFactorByMultiplesLast(currentSplitIndex, currentShapeDim, remainingTotalElment, |
| 483 | - currentSplitIndex, currentShapeDim, remainingTotalElment, coreNumMultiples); | 500 | + coreNumMultiples); |
| 484 | } else { | 501 | } else { |
| 485 | splitInfo_.outCutIndex = currentSplitIndex; | 502 | splitInfo_.outCutIndex = currentSplitIndex; |
| 486 | splitInfo_.outUbFactor = splitInfo_.outUbElement; | 503 | splitInfo_.outUbFactor = splitInfo_.outUbElement; |
| @@ -593,7 +610,8 @@ void TransposeNddmaTiling::EntryTilingTemplate() | |||
| 593 | auto platformInfo = tilingContext_->GetPlatformInfo(); | 610 | auto platformInfo = tilingContext_->GetPlatformInfo(); |
| 594 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); | 611 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); |
| 595 | auto arch = ascendcPlatform.GetCurNpuArch(); | 612 | auto arch = ascendcPlatform.GetCurNpuArch(); |
| 596 | - if (arch == NpuArch::DAV_5102 && !shapeInfo_.isLastAxisTranspose) { | 613 | + if (arch == NpuArch::DAV_5102 && !shapeInfo_.isLastAxisTranspose && |
| 614 | + shapeInfo_.reducedInShape[shapeInfo_.dim - 1] >= MOVEALIGN_LAST_MIN_ELE) { | ||
| 597 | SMALL_SHAPE_BYTES_THRES_HOLD = SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_NLAST; | 615 | SMALL_SHAPE_BYTES_THRES_HOLD = SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_NLAST; |
| 598 | } | 616 | } |
| 599 | if (shapeInfo_.totalVolumeActual * shapeInfo_.eleLenInBytes >= SMALL_SHAPE_BYTES_THRES_HOLD) { | 617 | if (shapeInfo_.totalVolumeActual * shapeInfo_.eleLenInBytes >= SMALL_SHAPE_BYTES_THRES_HOLD) { |
| @@ -653,8 +671,8 @@ void TransposeNddmaTiling::CalcBlockSplitInfoForTensorMove() | |||
| 653 | } | 671 | } |
| 654 | } | 672 | } |
| 655 | 673 | ||
| 656 | -int64_t TransposeNddmaTiling::CalcBlockSplitInfoForNoCutForMultiCore( | 674 | +int64_t TransposeNddmaTiling::CalcBlockSplitInfoForNoCutForMultiCore(int64_t i, int64_t shapeSizeByte, |
| 657 | - int64_t i, int64_t shapeSizeByte, int64_t& totalElment) | 675 | + int64_t& totalElment) |
| 658 | { | 676 | { |
| 659 | for (int64_t j = 2; j <= shapeInfo_.reducedOutShape[i]; j++) { | 677 | for (int64_t j = 2; j <= shapeInfo_.reducedOutShape[i]; j++) { |
| 660 | if ((shapeInfo_.reducedOutShape[i] % j == 0) && | 678 | if ((shapeInfo_.reducedOutShape[i] % j == 0) && |
| @@ -662,8 +680,8 @@ int64_t TransposeNddmaTiling::CalcBlockSplitInfoForNoCutForMultiCore( | |||
| 662 | if (j == shapeInfo_.reducedOutShape[i] && i == 0) { | 680 | if (j == shapeInfo_.reducedOutShape[i] && i == 0) { |
| 663 | // 素数且切到了最后,正常切 | 681 | // 素数且切到了最后,正常切 |
| 664 | splitInfo_.outCutIndex = i; | 682 | splitInfo_.outCutIndex = i; |
| 665 | - splitInfo_.outUbFactor = | 683 | + splitInfo_.outUbFactor = Ops::Base::CeilDiv(cacheLineSize_ + 1, |
| 666 | - Ops::Base::CeilDiv(cacheLineSize_ + 1, shapeSizeByte / shapeInfo_.reducedOutShape[i]); | 684 | + shapeSizeByte / shapeInfo_.reducedOutShape[i]); |
| 667 | splitInfo_.outTailFactor = shapeInfo_.reducedOutShape[i] % splitInfo_.outUbFactor; | 685 | splitInfo_.outTailFactor = shapeInfo_.reducedOutShape[i] % splitInfo_.outUbFactor; |
| 668 | totalElment *= Ops::Base::CeilDiv(shapeInfo_.reducedOutShape[i], splitInfo_.outUbFactor); | 686 | totalElment *= Ops::Base::CeilDiv(shapeInfo_.reducedOutShape[i], splitInfo_.outUbFactor); |
| 669 | break; | 687 | break; |
| @@ -698,12 +716,12 @@ void TransposeNddmaTiling::CalcBlockSplitInfoForSmallShape() | |||
| 698 | } | 716 | } |
| 699 | // simt every core elemets align to 128Byte | 717 | // simt every core elemets align to 128Byte |
| 700 | int64_t blkFactor = totalElements / coreNum_; | 718 | int64_t blkFactor = totalElements / coreNum_; |
| 701 | - int64_t ceilAlignFactor = | 719 | + int64_t ceilAlignFactor = Ops::Base::CeilDiv(blkFactor * shapeInfo_.eleLenInBytes, |
| 702 | - Ops::Base::CeilDiv(blkFactor * shapeInfo_.eleLenInBytes, SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE) * | 720 | + SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE) * |
| 703 | - SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE / shapeInfo_.eleLenInBytes; | 721 | + SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE / shapeInfo_.eleLenInBytes; |
| 704 | - int64_t floorAlignFactor = | 722 | + int64_t floorAlignFactor = Ops::Base::FloorDiv(blkFactor * shapeInfo_.eleLenInBytes, |
| 705 | - Ops::Base::FloorDiv(blkFactor * shapeInfo_.eleLenInBytes, SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE) * | 723 | + SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE) * |
| 706 | - SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE / shapeInfo_.eleLenInBytes; | 724 | + SMALL_SHAPE_SPLIT_BYTES_ALIGN_SIZE / shapeInfo_.eleLenInBytes; |
| 707 | if (totalElements - floorAlignFactor * (coreNum_ - 1) <= floorAlignFactor) { | 725 | if (totalElements - floorAlignFactor * (coreNum_ - 1) <= floorAlignFactor) { |
| 708 | realCoreNum_ = coreNum_; | 726 | realCoreNum_ = coreNum_; |
| 709 | blkFactor_ = floorAlignFactor; | 727 | blkFactor_ = floorAlignFactor; |
| @@ -735,11 +753,11 @@ void TransposeNddmaTiling::CalcBlockSplitInfoForNLastTranspose() | |||
| 735 | break; | 753 | break; |
| 736 | } else { // use full coreNum | 754 | } else { // use full coreNum |
| 737 | int64_t coreNumMultiples = Ops::Base::FloorDiv(coreNumTmp, coreNum_); | 755 | int64_t coreNumMultiples = Ops::Base::FloorDiv(coreNumTmp, coreNum_); |
| 738 | - FindSplitFactorByMultiplesNLast( | 756 | + FindSplitFactorByMultiplesNLast(currentSplitIndex, currentInShapeDim, remainingTotalElment, |
| 739 | - currentSplitIndex, currentInShapeDim, remainingTotalElment, coreNumMultiples); | 757 | + coreNumMultiples); |
| 740 | /* 检查inUbFactor是否合法,不合法则执行退轴逻辑 */ | 758 | /* 检查inUbFactor是否合法,不合法则执行退轴逻辑 */ |
| 741 | - CheckInUbFactorValid( | 759 | + CheckInUbFactorValid(currentSplitIndex, currentInShapeDim, remainingTotalElment, coreNumMultiples, |
| 742 | - currentSplitIndex, currentInShapeDim, remainingTotalElment, coreNumMultiples, solvedTotalElment); | 760 | + solvedTotalElment); |
| 743 | break; | 761 | break; |
| 744 | } | 762 | } |
| 745 | } else if (coreNumTmp < coreNum_) { // use at least VEC_CORE_USED_THRES_HOLD * coreNum | 763 | } else if (coreNumTmp < coreNum_) { // use at least VEC_CORE_USED_THRES_HOLD * coreNum |
| @@ -757,9 +775,9 @@ void TransposeNddmaTiling::CalcBlockSplitInfoForNLastTranspose() | |||
| 757 | SetRealCoreNumAndBlkFactor(coreNum); | 775 | SetRealCoreNumAndBlkFactor(coreNum); |
| 758 | } | 776 | } |
| 759 | 777 | ||
| 760 | -void TransposeNddmaTiling::CheckInUbFactorValid( | 778 | +void TransposeNddmaTiling::CheckInUbFactorValid(int64_t& currentSplitIndex, int64_t& currentInShapeDim, |
| 761 | - int64_t& currentSplitIndex, int64_t& currentInShapeDim, int64_t& remainingTotalElment, int64_t& coreNumMultiples, | 779 | + int64_t& remainingTotalElment, int64_t& coreNumMultiples, |
| 762 | - int64_t* solvedTotalElment) | 780 | + int64_t* solvedTotalElment) |
| 763 | { | 781 | { |
| 764 | if (splitInfo_.inUbFactor == 0 && currentSplitIndex < shapeInfo_.dim - 1) { | 782 | if (splitInfo_.inUbFactor == 0 && currentSplitIndex < shapeInfo_.dim - 1) { |
| 765 | while (currentSplitIndex < shapeInfo_.dim - 1) { | 783 | while (currentSplitIndex < shapeInfo_.dim - 1) { |
| @@ -768,8 +786,8 @@ void TransposeNddmaTiling::CheckInUbFactorValid( | |||
| 768 | splitInfo_.inUbElement = shapeInfo_.reducedInShape[currentSplitIndex]; | 786 | splitInfo_.inUbElement = shapeInfo_.reducedInShape[currentSplitIndex]; |
| 769 | remainingTotalElment = shapeInfo_.totalVolumeActual / solvedTotalElment[currentSplitIndex]; | 787 | remainingTotalElment = shapeInfo_.totalVolumeActual / solvedTotalElment[currentSplitIndex]; |
| 770 | coreNumMultiples = remainingTotalElment; | 788 | coreNumMultiples = remainingTotalElment; |
| 771 | - FindSplitFactorByMultiplesNLast( | 789 | + FindSplitFactorByMultiplesNLast(currentSplitIndex, currentInShapeDim, remainingTotalElment, |
| 772 | - currentSplitIndex, currentInShapeDim, remainingTotalElment, coreNumMultiples); | 790 | + coreNumMultiples); |
| 773 | if (splitInfo_.inUbFactor > 0) { | 791 | if (splitInfo_.inUbFactor > 0) { |
| 774 | break; | 792 | break; |
| 775 | } | 793 | } |
| @@ -851,8 +869,8 @@ void TransposeNddmaTiling::CalcBlockSplitInfoForCutTwice() | |||
| 851 | outAxiseExceptSplitInAxis *= shapeInfo_.reducedOutShape[i]; | 869 | outAxiseExceptSplitInAxis *= shapeInfo_.reducedOutShape[i]; |
| 852 | } | 870 | } |
| 853 | } | 871 | } |
| 854 | - outAxiseExceptSplitInAxis *= | 872 | + outAxiseExceptSplitInAxis *= Ops::Base::CeilDiv(shapeInfo_.reducedOutShape[splitInfo_.outCutIndex], |
| 855 | - Ops::Base::CeilDiv(shapeInfo_.reducedOutShape[splitInfo_.outCutIndex], splitInfo_.outUbFactor); | 873 | + splitInfo_.outUbFactor); |
| 856 | int64_t inUbAxis = Ops::Base::CeilDiv(shapeInfo_.reducedInShape[splitInfo_.inCutIndex], splitInfo_.inUbFactor); | 874 | int64_t inUbAxis = Ops::Base::CeilDiv(shapeInfo_.reducedInShape[splitInfo_.inCutIndex], splitInfo_.inUbFactor); |
| 857 | if (outAxiseExceptSplitInAxis * inUbAxis < coreNum_) { | 875 | if (outAxiseExceptSplitInAxis * inUbAxis < coreNum_) { |
| 858 | // use at least VEC_CORE_USED_THRES_HOLD * coreNum | 876 | // use at least VEC_CORE_USED_THRES_HOLD * coreNum |
| @@ -1064,14 +1082,14 @@ void TransposeNddmaTiling::CalcInUbShapeInfoForCutTwice() | |||
| 1064 | inUbOutputTailSrcShape_[idx] = inUbInputTailSrcShape_[idx]; | 1082 | inUbOutputTailSrcShape_[idx] = inUbInputTailSrcShape_[idx]; |
| 1065 | } | 1083 | } |
| 1066 | inUbOutputTailSrcShape_[splitInfo_.inCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim] = splitInfo_.inUbFactor; | 1084 | inUbOutputTailSrcShape_[splitInfo_.inCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim] = splitInfo_.inUbFactor; |
| 1067 | - inUbOutputTailSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim]] = | 1085 | + inUbOutputTailSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - |
| 1068 | - splitInfo_.outTailFactor; | 1086 | + shapeInfo_.dim]] = splitInfo_.outTailFactor; |
| 1069 | - inUbMainSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim]] = | 1087 | + inUbMainSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim]] = splitInfo_ |
| 1070 | - splitInfo_.outUbFactor; | 1088 | + .outUbFactor; |
| 1071 | - inUbInputTailSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim]] = | 1089 | + inUbInputTailSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - |
| 1072 | - splitInfo_.outUbFactor; | 1090 | + shapeInfo_.dim]] = splitInfo_.outUbFactor; |
| 1073 | - inUbTailSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim]] = | 1091 | + inUbTailSrcShape_[expandedPerm_[splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim]] = splitInfo_ |
| 1074 | - splitInfo_.outTailFactor; | 1092 | + .outTailFactor; |
| 1075 | for (int64_t idx = splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim + 1; idx < NDDMA_MAX_DIM_NUM; | 1093 | for (int64_t idx = splitInfo_.outCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim + 1; idx < NDDMA_MAX_DIM_NUM; |
| 1076 | idx++) { | 1094 | idx++) { |
| 1077 | if (expandedPerm_[idx] == splitInfo_.inCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim) { | 1095 | if (expandedPerm_[idx] == splitInfo_.inCutIndex + NDDMA_MAX_DIM_NUM - shapeInfo_.dim) { |
| @@ -1110,29 +1128,37 @@ void TransposeNddmaTiling::GetIntervalInfoForCutTwice() | |||
| 1110 | 1128 | ||
| 1111 | if (splitInfo_.inTailFactor != 0 && splitInfo_.outTailFactor != 0) { | 1129 | if (splitInfo_.inTailFactor != 0 && splitInfo_.outTailFactor != 0) { |
| 1112 | offsetRangeInputTail_.start = offsetRangeMain_.end + 1; | 1130 | offsetRangeInputTail_.start = offsetRangeMain_.end + 1; |
| 1113 | - offsetRangeInputTail_.end = | 1131 | + offsetRangeInputTail_.end = offsetRangeInputTail_.start + |
| 1114 | - offsetRangeInputTail_.start + | 1132 | + (expandedInputShape_[inputOutputCutIndex] / |
| 1115 | - (expandedInputShape_[inputOutputCutIndex] / inUbMainSrcShape_[inputOutputCutIndex]) * outUbLoop - 1; | 1133 | + inUbMainSrcShape_[inputOutputCutIndex]) * |
| 1134 | + outUbLoop - | ||
| 1135 | + 1; | ||
| 1116 | offsetRangeOutputTail_.start = offsetRangeInputTail_.end + 1; | 1136 | offsetRangeOutputTail_.start = offsetRangeInputTail_.end + 1; |
| 1117 | - offsetRangeOutputTail_.end = | 1137 | + offsetRangeOutputTail_.end = offsetRangeOutputTail_.start + |
| 1118 | - offsetRangeOutputTail_.start + | 1138 | + (expandedInputShape_[expandedInputCutIndex] / |
| 1119 | - (expandedInputShape_[expandedInputCutIndex] / inUbMainSrcShape_[expandedInputCutIndex]) * outUbLoop - 1; | 1139 | + inUbMainSrcShape_[expandedInputCutIndex]) * |
| 1140 | + outUbLoop - | ||
| 1141 | + 1; | ||
| 1120 | offsetRangeTail_.start = offsetRangeOutputTail_.end + 1; | 1142 | offsetRangeTail_.start = offsetRangeOutputTail_.end + 1; |
| 1121 | offsetRangeTail_.end = offsetRangeTail_.start + outUbLoop - 1; | 1143 | offsetRangeTail_.end = offsetRangeTail_.start + outUbLoop - 1; |
| 1122 | } | 1144 | } |
| 1123 | 1145 | ||
| 1124 | if (splitInfo_.inTailFactor != 0 && splitInfo_.outTailFactor == 0) { | 1146 | if (splitInfo_.inTailFactor != 0 && splitInfo_.outTailFactor == 0) { |
| 1125 | offsetRangeInputTail_.start = offsetRangeMain_.end + 1; | 1147 | offsetRangeInputTail_.start = offsetRangeMain_.end + 1; |
| 1126 | - offsetRangeInputTail_.end = | 1148 | + offsetRangeInputTail_.end = offsetRangeInputTail_.start + |
| 1127 | - offsetRangeInputTail_.start + | 1149 | + (expandedInputShape_[inputOutputCutIndex] / |
| 1128 | - (expandedInputShape_[inputOutputCutIndex] / inUbMainSrcShape_[inputOutputCutIndex]) * outUbLoop - 1; | 1150 | + inUbMainSrcShape_[inputOutputCutIndex]) * |
| 1151 | + outUbLoop - | ||
| 1152 | + 1; | ||
| 1129 | } | 1153 | } |
| 1130 | 1154 | ||
| 1131 | if (splitInfo_.inTailFactor == 0 && splitInfo_.outTailFactor != 0) { | 1155 | if (splitInfo_.inTailFactor == 0 && splitInfo_.outTailFactor != 0) { |
| 1132 | offsetRangeOutputTail_.start = offsetRangeMain_.end + 1; | 1156 | offsetRangeOutputTail_.start = offsetRangeMain_.end + 1; |
| 1133 | - offsetRangeOutputTail_.end = | 1157 | + offsetRangeOutputTail_.end = offsetRangeOutputTail_.start + |
| 1134 | - offsetRangeOutputTail_.start + | 1158 | + (expandedInputShape_[expandedInputCutIndex] / |
| 1135 | - (expandedInputShape_[expandedInputCutIndex] / inUbMainSrcShape_[expandedInputCutIndex]) * outUbLoop - 1; | 1159 | + inUbMainSrcShape_[expandedInputCutIndex]) * |
| 1160 | + outUbLoop - | ||
| 1161 | + 1; | ||
| 1136 | } | 1162 | } |
| 1137 | } | 1163 | } |
| 1138 | 1164 | ||
| @@ -1185,8 +1211,8 @@ void TransposeNddmaTiling::FillTilingData() | |||
| 1185 | tilingData_.transposeOpTiling.set_inUbTailDstShape(inUbTailDstShape_); | 1211 | tilingData_.transposeOpTiling.set_inUbTailDstShape(inUbTailDstShape_); |
| 1186 | 1212 | ||
| 1187 | if (!isReleatedTranspsoe_) { | 1213 | if (!isReleatedTranspsoe_) { |
| 1188 | - tilingData_.SaveToBuffer( | 1214 | + tilingData_.SaveToBuffer(tilingContext_->GetRawTilingData()->GetData(), |
| 1189 | - tilingContext_->GetRawTilingData()->GetData(), tilingContext_->GetRawTilingData()->GetCapacity()); | 1215 | + tilingContext_->GetRawTilingData()->GetCapacity()); |
| 1190 | tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize()); | 1216 | tilingContext_->GetRawTilingData()->SetDataSize(tilingData_.GetDataSize()); |
| 1191 | } | 1217 | } |
| 1192 | } | 1218 | } |
| @@ -1195,33 +1221,31 @@ void TransposeNddmaTiling::PrintTilingData() | |||
| 1195 | { | 1221 | { |
| 1196 | OP_LOGI(tilingContext_->GetNodeName(), "Entering PrintTilingData."); | 1222 | OP_LOGI(tilingContext_->GetNodeName(), "Entering PrintTilingData."); |
| 1197 | for (int64_t i = 0; i < shapeInfo_.dim; i++) { | 1223 | for (int64_t i = 0; i < shapeInfo_.dim; i++) { |
| 1198 | - OP_LOGI( | 1224 | + OP_LOGI(tilingContext_->GetNodeName(), |
| 1199 | - tilingContext_->GetNodeName(), | 1225 | + "reducedInShape[%ld] is:%ld, reducedOutShape[%ld]:%ld, reducedPerm[%ld]:%ld. \ |
| 1200 | - "reducedInShape[%ld] is:%ld, reducedOutShape[%ld]:%ld, reducedPerm[%ld]:%ld. \ | ||
| 1201 | baseInShape[%ld] is:%ld", | 1226 | baseInShape[%ld] is:%ld", |
| 1202 | - i, inputShape_[i], i, outputShape_[i], i, perm_[i], i, baseInShape_[i]); | 1227 | + i, inputShape_[i], i, outputShape_[i], i, perm_[i], i, baseInShape_[i]); |
| 1203 | } | 1228 | } |
| 1204 | for (int64_t i = 0; i < NDDMA_MAX_DIM_NUM; i++) { | 1229 | for (int64_t i = 0; i < NDDMA_MAX_DIM_NUM; i++) { |
| 1205 | - OP_LOGI( | 1230 | + OP_LOGI(tilingContext_->GetNodeName(), "baseNddmaShape_[%ld] is:%ld, nddmaIdx_[%ld]:%ld", i, baseNddmaShape_[i], |
| 1206 | - tilingContext_->GetNodeName(), "baseNddmaShape_[%ld] is:%ld, nddmaIdx_[%ld]:%ld", i, baseNddmaShape_[i], i, | 1231 | + i, nddmaIdx_[i]); |
| 1207 | - nddmaIdx_[i]); | ||
| 1208 | } | 1232 | } |
| 1209 | - OP_LOGI( | 1233 | + OP_LOGI(tilingContext_->GetNodeName(), |
| 1210 | - tilingContext_->GetNodeName(), | 1234 | + "tilingData is permSize:%ld, inCutIndex:%ld, outCutIndex:%ld, inUbFactor:%ld, outUbFactor:%ld, \ |
| 1211 | - "tilingData is permSize:%ld, inCutIndex:%ld, outCutIndex:%ld, inUbFactor:%ld, outUbFactor:%ld, \ | ||
| 1212 | inTailFactor:%ld, outTailFactor:%ld, realCoreNum:%ld, blkFactor:%ld, blkTailFactor:%ld, \ | 1235 | inTailFactor:%ld, outTailFactor:%ld, realCoreNum:%ld, blkFactor:%ld, blkTailFactor:%ld, \ |
| 1213 | ubSize:%ld, totalNddmaNum:%ld, Tiling4Transpose ends. ", | 1236 | ubSize:%ld, totalNddmaNum:%ld, Tiling4Transpose ends. ", |
| 1214 | - tilingData_.transposeOpTiling.get_permSize(), tilingData_.transposeOpTiling.get_inCutIndex(), | 1237 | + tilingData_.transposeOpTiling.get_permSize(), tilingData_.transposeOpTiling.get_inCutIndex(), |
| 1215 | - tilingData_.transposeOpTiling.get_outCutIndex(), tilingData_.transposeOpTiling.get_inUbFactor(), | 1238 | + tilingData_.transposeOpTiling.get_outCutIndex(), tilingData_.transposeOpTiling.get_inUbFactor(), |
| 1216 | - tilingData_.transposeOpTiling.get_outUbFactor(), tilingData_.transposeOpTiling.get_inTailFactor(), | 1239 | + tilingData_.transposeOpTiling.get_outUbFactor(), tilingData_.transposeOpTiling.get_inTailFactor(), |
| 1217 | - tilingData_.transposeOpTiling.get_outTailFactor(), tilingData_.transposeOpTiling.get_realCoreNum(), | 1240 | + tilingData_.transposeOpTiling.get_outTailFactor(), tilingData_.transposeOpTiling.get_realCoreNum(), |
| 1218 | - tilingData_.transposeOpTiling.get_blkFactor(), tilingData_.transposeOpTiling.get_blkTailFactor(), | 1241 | + tilingData_.transposeOpTiling.get_blkFactor(), tilingData_.transposeOpTiling.get_blkTailFactor(), |
| 1219 | - tilingData_.transposeOpTiling.get_ubSize(), tilingData_.transposeOpTiling.get_totalNddmaNum()); | 1242 | + tilingData_.transposeOpTiling.get_ubSize(), tilingData_.transposeOpTiling.get_totalNddmaNum()); |
| 1220 | } | 1243 | } |
| 1221 | 1244 | ||
| 1222 | -ge::graphStatus TransposeNddmaTiling::TilingForReleatedTranspose( | 1245 | +ge::graphStatus TransposeNddmaTiling::TilingForReleatedTranspose(gert::TilingContext* context, |
| 1223 | - gert::TilingContext* context, TransposeOpTilingData* tilingData, TransposeCompilerInfo* compilerInfo, | 1246 | + TransposeOpTilingData* tilingData, |
| 1224 | - ShapeInfo& opInput) | 1247 | + TransposeCompilerInfo* compilerInfo, |
| 1248 | + ShapeInfo& opInput) | ||
| 1225 | { | 1249 | { |
| 1226 | OP_LOGD(context->GetNodeName(), "Start TilingForReleatedTranspose."); | 1250 | OP_LOGD(context->GetNodeName(), "Start TilingForReleatedTranspose."); |
| 1227 | TransposeNddmaTiling tilingObject(context); | 1251 | TransposeNddmaTiling tilingObject(context); |
| @@ -1259,17 +1283,15 @@ ge::graphStatus TilingPrepareTransposeForAscendC(gert::TilingParseContext* conte | |||
| 1259 | OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo); | 1283 | OP_CHECK_NULL_WITH_CONTEXT(context, platformInfo); |
| 1260 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); | 1284 | auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); |
| 1261 | ci->coreNum = ascendcPlatform.GetCoreNumAiv(); | 1285 | ci->coreNum = ascendcPlatform.GetCoreNumAiv(); |
| 1262 | - OP_CHECK_IF( | 1286 | + OP_CHECK_IF((ci->coreNum <= 0), |
| 1263 | - (ci->coreNum <= 0), | 1287 | + OP_LOGE(context->GetNodeName(), "Transpose Op GetHardwareInfo Failed, coreNum:%ld.", ci->coreNum), |
| 1264 | - OP_LOGE(context->GetNodeName(), "Transpose Op GetHardwareInfo Failed, coreNum:%ld.", ci->coreNum), | 1288 | + return ge::GRAPH_FAILED); |
| 1265 | - return ge::GRAPH_FAILED); | ||
| 1266 | uint64_t ubSize; | 1289 | uint64_t ubSize; |
| 1267 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); | 1290 | ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize); |
| 1268 | ci->ubSize = static_cast<int64_t>(ubSize); | 1291 | ci->ubSize = static_cast<int64_t>(ubSize); |
| 1269 | - OP_CHECK_IF( | 1292 | + OP_CHECK_IF((ci->ubSize <= 0), |
| 1270 | - (ci->ubSize <= 0), | 1293 | + OP_LOGE(context->GetNodeName(), "Transpose Op GetHardwareInfo Failed, ubSize:%ld.", ci->ubSize), |
| 1271 | - OP_LOGE(context->GetNodeName(), "Transpose Op GetHardwareInfo Failed, ubSize:%ld.", ci->ubSize), | 1294 | + return ge::GRAPH_FAILED); |
| 1272 | - return ge::GRAPH_FAILED); | ||
| 1273 | 1295 | ||
| 1274 | OP_LOGD(context->GetNodeName(), "Transpose Op get coreNum:%ld, ubSize:%ld.", ci->coreNum, ci->ubSize); | 1296 | OP_LOGD(context->GetNodeName(), "Transpose Op get coreNum:%ld, ubSize:%ld.", ci->coreNum, ci->ubSize); |
| 1275 | return ge::GRAPH_SUCCESS; | 1297 | return ge::GRAPH_SUCCESS; |
| @@ -59,6 +59,8 @@ constexpr int64_t DIM_FOUR = 4; | |||
| 59 | constexpr int64_t DIM_FIVE = 5; | 59 | constexpr int64_t DIM_FIVE = 5; |
| 60 | constexpr int64_t DIM_SIX = 6; | 60 | constexpr int64_t DIM_SIX = 6; |
| 61 | constexpr int64_t DIM_EIGHT = 8; | 61 | constexpr int64_t DIM_EIGHT = 8; |
| 62 | +constexpr int64_t HW_ALIGN = 16; | ||
| 63 | +constexpr int64_t HW_MIN_PRODUCT = 448; | ||
| 62 | constexpr int64_t SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102 = 1000000; | 64 | constexpr int64_t SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102 = 1000000; |
| 63 | constexpr int64_t SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_NLAST = 400000; | 65 | constexpr int64_t SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_NLAST = 400000; |
| 64 | constexpr int64_t SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_021 = 70000; | 66 | constexpr int64_t SMALL_SHAPE_BYTES_THRES_HOLD_DAV_5102_021 = 70000; |
| @@ -107,8 +109,7 @@ TILING_DATA_FIELD_DEF_STRUCT(TransposeOpTilingData, transposeOpTiling); | |||
| 107 | END_TILING_DATA_DEF; | 109 | END_TILING_DATA_DEF; |
| 108 | REGISTER_TILING_DATA_CLASS(Transpose, TransposeTilingData); | 110 | REGISTER_TILING_DATA_CLASS(Transpose, TransposeTilingData); |
| 109 | 111 | ||
| 110 | -enum class SplitMode : int64_t | 112 | +enum class SplitMode : int64_t { |
| 111 | -{ | ||
| 112 | TENSOR_MOVE = 10000, // only one axis after fuse | 113 | TENSOR_MOVE = 10000, // only one axis after fuse |
| 113 | SMALL_SHAPE = 10001, // UB is enough | 114 | SMALL_SHAPE = 10001, // UB is enough |
| 114 | CUT_ONCE = 10002, // cut one axis and last transpose | 115 | CUT_ONCE = 10002, // cut one axis and last transpose |
| @@ -158,12 +159,11 @@ ge::graphStatus TilingPrepareTransposeForAscendC(gert::TilingParseContext* conte | |||
| 158 | 159 | ||
| 159 | class TransposeNddmaTiling { | 160 | class TransposeNddmaTiling { |
| 160 | public: | 161 | public: |
| 161 | - explicit TransposeNddmaTiling(gert::TilingContext* context) : tilingContext_(context) {}; | 162 | + explicit TransposeNddmaTiling(gert::TilingContext* context) : tilingContext_(context){}; |
| 162 | ge::graphStatus Init(const int64_t& coreNum, const int64_t& ubSize); | 163 | ge::graphStatus Init(const int64_t& coreNum, const int64_t& ubSize); |
| 163 | ge::graphStatus RunTranposelTiling(); | 164 | ge::graphStatus RunTranposelTiling(); |
| 164 | - ge::graphStatus TilingForReleatedTranspose( | 165 | + ge::graphStatus TilingForReleatedTranspose(gert::TilingContext* context, TransposeOpTilingData* tilingData, |
| 165 | - gert::TilingContext* context, TransposeOpTilingData* tilingData, TransposeCompilerInfo* compilerInfo, | 166 | + TransposeCompilerInfo* compilerInfo, ShapeInfo& opInput); |
| 166 | - ShapeInfo& opInput); | ||
| 167 | 167 | ||
| 168 | private: | 168 | private: |
| 169 | template <typename T> | 169 | template <typename T> |
| @@ -175,6 +175,7 @@ private: | |||
| 175 | ge::graphStatus CheckShapeInfo(); | 175 | ge::graphStatus CheckShapeInfo(); |
| 176 | ge::graphStatus CheckReducedShapeInfo(); | 176 | ge::graphStatus CheckReducedShapeInfo(); |
| 177 | ge::graphStatus TryVCONVTiling(); | 177 | ge::graphStatus TryVCONVTiling(); |
| 178 | + bool Is021VConvValid(); | ||
| 178 | void FlushBaseNumForBigDim(); | 179 | void FlushBaseNumForBigDim(); |
| 179 | void EntryTilingTemplate(); | 180 | void EntryTilingTemplate(); |
| 180 | void CalcUBSplitInfo(); | 181 | void CalcUBSplitInfo(); |
| @@ -194,14 +195,13 @@ private: | |||
| 194 | int64_t FindOutIndex(int64_t index); | 195 | int64_t FindOutIndex(int64_t index); |
| 195 | bool UbOutOfBoundCheck(int64_t currentSplitIndex, int64_t currentSplitValue, bool calcIn); | 196 | bool UbOutOfBoundCheck(int64_t currentSplitIndex, int64_t currentSplitValue, bool calcIn); |
| 196 | bool UbOutOfBoundCheckNLast(int64_t currentSplitIndex, int64_t currentSplitValue); | 197 | bool UbOutOfBoundCheckNLast(int64_t currentSplitIndex, int64_t currentSplitValue); |
| 197 | - void FindSplitFactorByMultiplesLast( | 198 | + void FindSplitFactorByMultiplesLast(int64_t currentSplitIndex, int64_t currentInShapeDim, |
| 198 | - int64_t currentSplitIndex, int64_t currentInShapeDim, int64_t remainingTotalElment, int64_t coreNumMultiples); | 199 | + int64_t remainingTotalElment, int64_t coreNumMultiples); |
| 199 | void FindSplitFactorByRateNLast(int64_t currentSplitIndex, int64_t currentInShapeDim, int64_t remainingTotalElment); | 200 | void FindSplitFactorByRateNLast(int64_t currentSplitIndex, int64_t currentInShapeDim, int64_t remainingTotalElment); |
| 200 | - void FindSplitFactorByMultiplesNLast( | 201 | + void FindSplitFactorByMultiplesNLast(int64_t currentSplitIndex, int64_t currentInShapeDim, |
| 201 | - int64_t currentSplitIndex, int64_t currentInShapeDim, int64_t remainingTotalElment, int64_t coreNumMultiples); | 202 | + int64_t remainingTotalElment, int64_t coreNumMultiples); |
| 202 | - void CheckInUbFactorValid( | 203 | + void CheckInUbFactorValid(int64_t& currentSplitIndex, int64_t& currentInShapeDim, int64_t& remainingTotalElment, |
| 203 | - int64_t& currentSplitIndex, int64_t& currentInShapeDim, int64_t& remainingTotalElment, | 204 | + int64_t& coreNumMultiples, int64_t* solvedTotalElment); |
| 204 | - int64_t& coreNumMultiples, int64_t* solvedTotalElment); | ||
| 205 | void DoSplitUBBigDim(); | 205 | void DoSplitUBBigDim(); |
| 206 | void NDDMADimExpand(); | 206 | void NDDMADimExpand(); |
| 207 | void GetInUbShapeInfo(); | 207 | void GetInUbShapeInfo(); |