已合并
small kernel a16w8 support for partload/parallelism 精度问题回退 #9530
檩+创建于 3 天前
small kernel a16w8 support for partload/parallelism 精度问题回退 #9530
已合并
共 3 个文件变更+14-16
| @@ -411,7 +411,7 @@ __aicore__ inline void Conv2dSmallKernel<FmapType, weightType, biasType, out0Typ | |||
| 411 | uint32_t curK = tiling_->kL0; | 411 | uint32_t curK = tiling_->kL0; |
| 412 | uint32_t curKAL0 = tiling_->kL0; | 412 | uint32_t curKAL0 = tiling_->kL0; |
| 413 | if (kl0Iter == kL0MaxIter - 1) { | 413 | if (kl0Iter == kL0MaxIter - 1) { |
| 414 | - curKAL0 = kTotalFmap_ % tiling_->kL0; | 414 | + curKAL0 = kTotalFmap_ * tiling_->kh * tiling_->kw % tiling_->kL0; |
| 415 | curKAL0 = curKAL0 == 0 ? tiling_->kL0 : curKAL0; | 415 | curKAL0 = curKAL0 == 0 ? tiling_->kL0 : curKAL0; |
| 416 | curK = AlignB(curKAL0, GK0); | 416 | curK = AlignB(curKAL0, GK0); |
| 417 | } | 417 | } |
| @@ -122,7 +122,7 @@ __aicore__ inline void Conv2dSmallKernelFmPartload<FmapType, weightType, biasTyp | |||
| 122 | // cinL1_ derived from kAL1: kAL1 = cinL1 * kernelHxkernelW. | 122 | // cinL1_ derived from kAL1: kAL1 = cinL1 * kernelHxkernelW. |
| 123 | // hoL0_/woL0_ are already set by InitCommon from tiling_->hoL0/woL0. | 123 | // hoL0_/woL0_ are already set by InitCommon from tiling_->hoL0/woL0. |
| 124 | this->cinL1_ = AlignB(this->tiling_->kAL1 / this->tiling_->kernelHxkernelW, this->GK0); | 124 | this->cinL1_ = AlignB(this->tiling_->kAL1 / this->tiling_->kernelHxkernelW, this->GK0); |
| 125 | - this->cinL1Blocks_ = CeilDiv(AlignB(this->tiling_->singleCoreCi, this->GK0Fmap), this->cinL1_); | 125 | + this->cinL1Blocks_ = CeilDiv(this->cinAligned_, this->cinL1_); |
| 126 | 126 | ||
| 127 | this->al1BufBytes_ = this->tiling_->aL1SpaceSize; | 127 | this->al1BufBytes_ = this->tiling_->aL1SpaceSize; |
| 128 | this->al1ElemPerBuf_ = this->tiling_->aL1SpaceSize / sizeof(FmapType); | 128 | this->al1ElemPerBuf_ = this->tiling_->aL1SpaceSize / sizeof(FmapType); |
| @@ -173,7 +173,7 @@ __aicore__ inline void Conv2dSmallKernelFmPartload<FmapType, weightType, biasTyp | |||
| 173 | 173 | ||
| 174 | // kL0 from tiling directly (N axis fullload L0: nl0 = nbl1, no per-chunk recomputation). | 174 | // kL0 from tiling directly (N axis fullload L0: nl0 = nbl1, no per-chunk recomputation). |
| 175 | uint32_t kL0 = this->tiling_->kL0; | 175 | uint32_t kL0 = this->tiling_->kL0; |
| 176 | - uint32_t kL0Iters = CeilDiv(this->kTotalFmap_, kL0); | 176 | + uint32_t kL0Iters = CeilDiv(this->kTotal_, kL0); |
| 177 | uint32_t kernelHxW = this->tiling_->kh * this->tiling_->kw; | 177 | uint32_t kernelHxW = this->tiling_->kh * this->tiling_->kw; |
| 178 | 178 | ||
| 179 | LocalTensor<weightType> bl1Full(TPosition::B1, this->bl1OffBytes_, this->bl1ElemCount_); | 179 | LocalTensor<weightType> bl1Full(TPosition::B1, this->bl1OffBytes_, this->bl1ElemCount_); |
| @@ -455,15 +455,15 @@ Conv2dSmallKernelFmPartload<FmapType, weightType, biasType, out0Type, out1Type, | |||
| 455 | SetFlag<HardEvent::MTE2_MTE1>(kl1Ev); | 455 | SetFlag<HardEvent::MTE2_MTE1>(kl1Ev); |
| 456 | WaitFlag<HardEvent::MTE2_MTE1>(kl1Ev); | 456 | WaitFlag<HardEvent::MTE2_MTE1>(kl1Ev); |
| 457 | } | 457 | } |
| 458 | - uint32_t curCinOriFmap = AlignB(curCinOri, this->GK0Fmap); | ||
| 459 | - this->SetupLoad3DForChunk(curHi, setupMOff, curM, padTop, padBottom, setupWoOff, padLeft, padRight, curWi, | ||
| 460 | - curCinOriFmap); | ||
| 461 | 458 | ||
| 462 | - uint32_t al1ElemCount = curHi * curWi * curCinOriFmap; | 459 | + this->SetupLoad3DForChunk(curHi, setupMOff, curM, padTop, padBottom, setupWoOff, padLeft, padRight, curWi, |
| 460 | + curCin); | ||
| 461 | + | ||
| 462 | + uint32_t al1ElemCount = curHi * curWi * curCin; | ||
| 463 | uint32_t al1BufOff = kl1Buf * this->al1BufBytes_; | 463 | uint32_t al1BufOff = kl1Buf * this->al1BufBytes_; |
| 464 | LocalTensor<FmapType> al1(TPosition::A1, al1BufOff, al1ElemCount); | 464 | LocalTensor<FmapType> al1(TPosition::A1, al1BufOff, al1ElemCount); |
| 465 | - uint32_t curKL1Fmap = curCinOriFmap * kernelHxW; | 465 | + |
| 466 | - this->RunKL0Loop(al1, bl1Full, cl0, mp, kOff, curKL1Fmap, kl1, kL0, kL0Iters); | 466 | + this->RunKL0Loop(al1, bl1Full, cl0, mp, kOff, curKL1, kl1, kL0, kL0Iters); |
| 467 | 467 | ||
| 468 | SetFlag<HardEvent::MTE1_MTE2>(kl1Ev); | 468 | SetFlag<HardEvent::MTE1_MTE2>(kl1Ev); |
| 469 | } | 469 | } |
| @@ -159,7 +159,7 @@ __aicore__ inline void Conv2dSmallKernelParallelism<FmapType, weightType, biasTy | |||
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | - cinL1Blocks_ = CeilDiv(this->AlignB(this->tiling_->singleCoreCi, this->GK0Fmap), cinL1_); | 162 | + cinL1Blocks_ = CeilDiv(this->cinAligned_, cinL1_); |
| 163 | 163 | ||
| 164 | uint32_t maxHoRelEnd; | 164 | uint32_t maxHoRelEnd; |
| 165 | if constexpr (IsHwMode) { | 165 | if constexpr (IsHwMode) { |
| @@ -708,15 +708,13 @@ Conv2dSmallKernelParallelism<FmapType, weightType, biasType, out0Type, out1Type, | |||
| 708 | } else { | 708 | } else { |
| 709 | WaitFlag<HardEvent::MTE2_MTE1>(kl1Ev); | 709 | WaitFlag<HardEvent::MTE2_MTE1>(kl1Ev); |
| 710 | } | 710 | } |
| 711 | - uint32_t curCinOriFmap = AlignB(curCinOri, this->GK0Fmap); | 711 | + SetupLoad3DForChunk(curHi, setupMOff, curM, padTop, padBottom, setupWoOff, padLeft, padRight, curWi, curCin); |
| 712 | - SetupLoad3DForChunk(curHi, setupMOff, curM, padTop, padBottom, setupWoOff, padLeft, padRight, curWi, | ||
| 713 | - curCinOriFmap); | ||
| 714 | 712 | ||
| 715 | - uint32_t al1ElemCount = curHi * curWi * curCinOriFmap; | 713 | + uint32_t al1ElemCount = curHi * curWi * curCin; |
| 716 | uint32_t al1BufOff = kl1Buf * al1BufBytes_; | 714 | uint32_t al1BufOff = kl1Buf * al1BufBytes_; |
| 717 | LocalTensor<FmapType> al1(TPosition::A1, al1BufOff, al1ElemCount); | 715 | LocalTensor<FmapType> al1(TPosition::A1, al1BufOff, al1ElemCount); |
| 718 | - uint32_t curKL1Fmap = curCinOriFmap * kernelHxW; | 716 | + |
| 719 | - RunKL0Loop(al1, bl1Full, cl0, mp, kOff, curKL1Fmap, kl1, kL0, kL0Iters, this->enableBatchDoubleBuffer_, kl1Ev); | 717 | + RunKL0Loop(al1, bl1Full, cl0, mp, kOff, curKL1, kl1, kL0, kL0Iters, this->enableBatchDoubleBuffer_, kl1Ev); |
| 720 | if (!this->enableBatchDoubleBuffer_) { | 718 | if (!this->enableBatchDoubleBuffer_) { |
| 721 | SetFlag<HardEvent::MTE1_MTE2>(kl1Ev); | 719 | SetFlag<HardEvent::MTE1_MTE2>(kl1Ev); |
| 722 | } | 720 | } |