Merged
constantpadnd性能优化 #4629
constantpadnd性能优化 #4629
Merged
onanfieldAdd on Aug 14
Total: 3 files changed+93-37
@@ -247,7 +247,7 @@ static aclnnStatus HandleSelfEmpty(const aclScalar* value, aclTensor* out, aclOp
247 247 
248 // 将value转换为tensor,并且数据类型转换为self的数据类型248 // 将value转换为tensor,并且数据类型转换为self的数据类型
249 const aclTensor* valueTensor = nullptr;249 const aclTensor* valueTensor = nullptr;
250- if (out->GetDataType() == DataType::DT_BOOL) {250+ if (out->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
251 auto valueTensorBool = executor->ConvertToTensor(value, DataType::DT_BOOL);251 auto valueTensorBool = executor->ConvertToTensor(value, DataType::DT_BOOL);
252 CHECK_RET(valueTensorBool != nullptr, ACLNN_ERR_INNER_NULLPTR);252 CHECK_RET(valueTensorBool != nullptr, ACLNN_ERR_INNER_NULLPTR);
253 valueTensor = l0op::Cast(valueTensorBool, DataType::DT_INT8, executor);253 valueTensor = l0op::Cast(valueTensorBool, DataType::DT_INT8, executor);
@@ -264,7 +264,7 @@ static aclnnStatus HandleSelfEmpty(const aclScalar* value, aclTensor* out, aclOp
264 CHECK_RET(fillOut != nullptr, ACLNN_ERR_INNER_NULLPTR);264 CHECK_RET(fillOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
265 265 
266 const aclTensor* fillOutCasted = fillOut;266 const aclTensor* fillOutCasted = fillOut;
267- if (out->GetDataType() == DataType::DT_BOOL) {267+ if (out->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
268 fillOutCasted = l0op::Cast(fillOut, DataType::DT_BOOL, executor);268 fillOutCasted = l0op::Cast(fillOut, DataType::DT_BOOL, executor);
269 CHECK_RET(fillOutCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);269 CHECK_RET(fillOutCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
270 }270 }
@@ -282,7 +282,7 @@ static aclnnStatus DoPadV3(const aclTensor* self, const aclIntArray* noneNegPad,
282 auto padTensor = executor->ConvertToTensor(noneNegPad, DataType::DT_INT32);282 auto padTensor = executor->ConvertToTensor(noneNegPad, DataType::DT_INT32);
283 CHECK_RET(padTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);283 CHECK_RET(padTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);
284 DataType dataType = self->GetDataType();284 DataType dataType = self->GetDataType();
285- if (dataType == DataType::DT_BOOL) {285+ if (dataType == DataType::DT_BOOL && !IsRegBase()) {
286 dataType = DataType::DT_INT8;286 dataType = DataType::DT_INT8;
287 }287 }
288 288 
@@ -291,7 +291,7 @@ static aclnnStatus DoPadV3(const aclTensor* self, const aclIntArray* noneNegPad,
291 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);291 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
292 292 
293 auto selfCasted = selfContiguous;293 auto selfCasted = selfContiguous;
294- if (self->GetDataType() == DataType::DT_BOOL) {294+ if (self->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
295 // 将bool类型承输入self的转换成int8的数据类型295 // 将bool类型承输入self的转换成int8的数据类型
296 selfCasted = l0op::Cast(selfContiguous, dataType, executor);296 selfCasted = l0op::Cast(selfContiguous, dataType, executor);
297 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);297 CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -317,7 +317,7 @@ static aclnnStatus DoPadV3(const aclTensor* self, const aclIntArray* noneNegPad,
317 CHECK_RET(valueTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);317 CHECK_RET(valueTensor != nullptr, ACLNN_ERR_INNER_NULLPTR);
318 318 
319 auto valueCasted = valueTensor;319 auto valueCasted = valueTensor;
320- if (self->GetDataType() == DataType::DT_BOOL) {320+ if (self->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
321 // 将bool类型的value转换成int8的数据类型321 // 将bool类型的value转换成int8的数据类型
322 valueCasted = l0op::Cast(valueTensor, dataType, executor);322 valueCasted = l0op::Cast(valueTensor, dataType, executor);
323 CHECK_RET(valueCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);323 CHECK_RET(valueCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -337,7 +337,7 @@ static aclnnStatus DoStridedSlice(const aclTensor* padV3Result, const aclIntArra
337 op::Shape curShape = padV3Result->GetViewShape();337 op::Shape curShape = padV3Result->GetViewShape();
338 size_t outDim = out->GetViewShape().GetDimNum();338 size_t outDim = out->GetViewShape().GetDimNum();
339 DataType dataType = out->GetDataType();339 DataType dataType = out->GetDataType();
340- if (dataType == DataType::DT_BOOL) {340+ if (dataType == DataType::DT_BOOL && !IsRegBase()) {
341 dataType = DataType::DT_INT8;341 dataType = DataType::DT_INT8;
342 }342 }
343 FVector<int64_t> beginFV;343 FVector<int64_t> beginFV;
@@ -373,7 +373,7 @@ static aclnnStatus DoStridedSlice(const aclTensor* padV3Result, const aclIntArra
373 (*end)[i] = stridedResult->GetViewShape().GetDim(i);373 (*end)[i] = stridedResult->GetViewShape().GetDim(i);
374 }374 }
375 auto stridedResultCasted = stridedResult;375 auto stridedResultCasted = stridedResult;
376- if (out->GetDataType() == DataType::DT_BOOL) {376+ if (out->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
377 stridedResultCasted = l0op::Cast(stridedResult, DataType::DT_BOOL, executor);377 stridedResultCasted = l0op::Cast(stridedResult, DataType::DT_BOOL, executor);
378 CHECK_RET(stridedResultCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);378 CHECK_RET(stridedResultCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
379 }379 }
@@ -447,7 +447,7 @@ aclnnStatus aclnnConstantPadNdGetWorkspaceSize(const aclTensor* self, const aclI
447 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);447 CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
448 448 
449 padV3Result = selfContiguous;449 padV3Result = selfContiguous;
450- if (self->GetDataType() == DataType::DT_BOOL) {450+ if (self->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
451 // 将bool类型承输入self的转换成int8的数据类型451 // 将bool类型承输入self的转换成int8的数据类型
452 padV3Result = l0op::Cast(selfContiguous, DataType::DT_INT8, uniqueExecutor.get());452 padV3Result = l0op::Cast(selfContiguous, DataType::DT_INT8, uniqueExecutor.get());
453 CHECK_RET(padV3Result != nullptr, ACLNN_ERR_INNER_NULLPTR);453 CHECK_RET(padV3Result != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -456,7 +456,7 @@ aclnnStatus aclnnConstantPadNdGetWorkspaceSize(const aclTensor* self, const aclI
456 456 
457 if ((signSymbol & NEGETIVE) == 0) {457 if ((signSymbol & NEGETIVE) == 0) {
458 auto padV3ResultCasted = padV3Result;458 auto padV3ResultCasted = padV3Result;
459- if (out->GetDataType() == DataType::DT_BOOL) {459+ if (out->GetDataType() == DataType::DT_BOOL && !IsRegBase()) {
460 padV3ResultCasted = l0op::Cast(padV3Result, DataType::DT_BOOL, uniqueExecutor.get());460 padV3ResultCasted = l0op::Cast(padV3Result, DataType::DT_BOOL, uniqueExecutor.get());
461 CHECK_RET(padV3ResultCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);461 CHECK_RET(padV3ResultCasted != nullptr, ACLNN_ERR_INNER_NULLPTR);
462 }462 }
@@ -38,13 +38,15 @@ private:
38 GlobalTensor<T> input_;38 GlobalTensor<T> input_;
39 GlobalTensor<T> output_;39 GlobalTensor<T> output_;
40 GlobalTensor<T> constPad_;40 GlobalTensor<T> constPad_;
41- TQueBind<QuePosition::VECIN, QuePosition::VECOUT, BUFFER_NUM> inQueue_;41+ TBuf<TPosition::VECCALC> inQueue_;
42 42 
43 TPipe* pipe_ = nullptr;43 TPipe* pipe_ = nullptr;
44 int64_t blockIdx_;44 int64_t blockIdx_;
45 uint32_t additionOffset_{0};45 uint32_t additionOffset_{0};
46 T constValue_{0};46 T constValue_{0};
47 const PadACTilingData* tilingData_ = nullptr;47 const PadACTilingData* tilingData_ = nullptr;
48+ bool firstOut_{true};
49+ bool lastOut_{true};
48 uint64_t inIndex_[PAD_MAX_DIMS_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};50 uint64_t inIndex_[PAD_MAX_DIMS_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};
49 uint32_t inCopyLen_[PAD_MAX_DIMS_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};51 uint32_t inCopyLen_[PAD_MAX_DIMS_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};
50 uint64_t outIndex_[PAD_MAX_DIMS_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};52 uint64_t outIndex_[PAD_MAX_DIMS_NUM] = {0, 0, 0, 0, 0, 0, 0, 0};
@@ -72,7 +74,7 @@ public:
72 }74 }
73 }75 }
74 76 
75- pipe_->InitBuffer(inQueue_, BUFFER_NUM, tilingData_->outTileSize + tilingData_->additionTileSize);77+ pipe_->InitBuffer(inQueue_, BUFFER_NUM * (tilingData_->outTileSize + tilingData_->additionTileSize));
76 for (uint32_t i = tilingData_->ubAxis + 1U; i < tilingData_->dimNum; i++) {78 for (uint32_t i = tilingData_->ubAxis + 1U; i < tilingData_->dimNum; i++) {
77 inCopyLen_[i] = tilingData_->inShape[i];79 inCopyLen_[i] = tilingData_->inShape[i];
78 }80 }
@@ -84,6 +86,10 @@ public:
84 if (startIdxHuge >= tilingData_->ubTotalCount) {86 if (startIdxHuge >= tilingData_->ubTotalCount) {
85 return;87 return;
86 }88 }
89+ LocalTensor<T> in = inQueue_.Get<T>();
90+ Duplicate(in, constValue_, BUFFER_NUM * (tilingData_->outTileSize + tilingData_->additionTileSize) / sizeof(T));
91+ SetFlag<HardEvent::V_MTE2>(EVENT_ID0);
92+ SetFlag<HardEvent::V_MTE2>(EVENT_ID1);
87 uint32_t endIdxHuge = (blockIdx_ + 1L) * tilingData_->ubPerCount;93 uint32_t endIdxHuge = (blockIdx_ + 1L) * tilingData_->ubPerCount;
88 endIdxHuge = (endIdxHuge < tilingData_->ubTotalCount ? endIdxHuge : tilingData_->ubTotalCount);94 endIdxHuge = (endIdxHuge < tilingData_->ubTotalCount ? endIdxHuge : tilingData_->ubTotalCount);
89 95 
@@ -92,6 +98,8 @@ public:
92 for (uint32_t idx = startIdxHuge; idx < endIdxHuge; idx++) {98 for (uint32_t idx = startIdxHuge; idx < endIdxHuge; idx++) {
93 bool isAllPadding = false;99 bool isAllPadding = false;
94 uint32_t curIdxHuge = idx;100 uint32_t curIdxHuge = idx;
101+ firstOut_ = (idx == startIdxHuge);
102+ lastOut_ = (idx == endIdxHuge - 1);
95 for (int32_t i = ubAxis; i >= 0; i--) {103 for (int32_t i = ubAxis; i >= 0; i--) {
96 uint64_t factorHuge = tilingData_->outShape[i];104 uint64_t factorHuge = tilingData_->outShape[i];
97 if (i == ubAxis) {105 if (i == ubAxis) {
@@ -131,32 +139,58 @@ public:
131 inCopyLen_[ubAxis] = 0;139 inCopyLen_[ubAxis] = 0;
132 }140 }
133 }141 }
134- ProcessOneStep();142+ ProcessOneStep(idx - startIdxHuge);
135 }143 }
136 }144 }
137 145 
138private:146private:
139- __aicore__ inline void ProcessOneStep()147+ __aicore__ inline void ProcessOneStep(int32_t idx)
140 {148 {
141- // Copy IN149+ LocalTensor<T> input = inQueue_.Get<T>();
142- LocalTensor<T> srcLocal = inQueue_.AllocTensor<T>();150+ LocalTensor<T>
151+ srcLocal = input[(idx & 1) * (tilingData_->outTileSize + tilingData_->additionTileSize) / sizeof(T)];
143 PadHugeParam padParam;152 PadHugeParam padParam;
144 padParam.padH = 1;153 padParam.padH = 1;
145 padParam.padW = CeilAlign(tilingData_->ubFactor, BLK_ELEMS);154 padParam.padW = CeilAlign(tilingData_->ubFactor, BLK_ELEMS);
146 padParam.padHLOffset = 0;155 padParam.padHLOffset = 0;
147 padParam.padHROffset = 1;156 padParam.padHROffset = 1;
148 157 
149- CopyIn(srcLocal, padParam);158+ bool hasMTE2 = false;
159+ bool hasPadding = false;
160+ CopyIn(srcLocal, padParam, hasMTE2, idx);
150 161 
151- PadOneLine(srcLocal[additionOffset_], padParam, srcLocal, VL_SIZE / sizeof(T));162+ PadOneLine(srcLocal[additionOffset_], padParam, srcLocal, VL_SIZE / sizeof(T), hasMTE2, hasPadding);
152 163 
153- CopyOut(srcLocal, padParam);164+ CopyOut(srcLocal, padParam, hasMTE2, hasPadding, idx);
154- 
155- inQueue_.FreeTensor(srcLocal);
156 }165 }
157 166 
158- __aicore__ inline void CopyIn(const LocalTensor<T>& src, PadHugeParam& padParam)167+ __aicore__ inline void CopyIn(const LocalTensor<T>& src, PadHugeParam& padParam, bool& hasMTE2, int32_t idx)
159 {168 {
169+ if (idx >= 1) {
170+ int32_t nextIdx = idx + 1;
171+ if ((nextIdx & 1) == 0) {
172+ WaitFlag<HardEvent::MTE3_V>(EVENT_ID0);
173+ } else {
174+ WaitFlag<HardEvent::MTE3_V>(EVENT_ID1);
175+ }
176+ LocalTensor<T> input = inQueue_.Get<T>();
177+ LocalTensor<T> nextLocal = input[(nextIdx & 1) *
178+ (tilingData_->outTileSize + tilingData_->additionTileSize) / sizeof(T)];
179+ Duplicate(nextLocal, constValue_, (tilingData_->outTileSize + tilingData_->additionTileSize) / sizeof(T));
180+ if (!lastOut_) {
181+ if ((nextIdx & 1) == 0) {
182+ SetFlag<HardEvent::V_MTE2>(EVENT_ID0);
183+ } else {
184+ SetFlag<HardEvent::V_MTE2>(EVENT_ID1);
185+ }
186+ }
187+ }
188+ 
189+ if ((idx & 1) == 0) {
190+ WaitFlag<HardEvent::V_MTE2>(EVENT_ID0);
191+ } else {
192+ WaitFlag<HardEvent::V_MTE2>(EVENT_ID1);
193+ }
160 const int8_t ubAxis = tilingData_->ubAxis;194 const int8_t ubAxis = tilingData_->ubAxis;
161 const uint32_t ubFactor = tilingData_->ubFactor;195 const uint32_t ubFactor = tilingData_->ubFactor;
162 uint64_t inAddr = 0;196 uint64_t inAddr = 0;
@@ -173,14 +207,11 @@ private:
173 padParam.padWROffset = ubFactor;207 padParam.padWROffset = ubFactor;
174 copyInParams.blockLen = ubFactor * sizeof(T);208 copyInParams.blockLen = ubFactor * sizeof(T);
175 DataCopyPad(src[additionOffset_], input_[inAddr], copyInParams, padParams);209 DataCopyPad(src[additionOffset_], input_[inAddr], copyInParams, padParams);
176- SetEvent<HardEvent::MTE2_V>(HardEvent::MTE2_V);210+ hasMTE2 = true;
177 } else if (inCopyLen_[ubAxis] == 0) {211 } else if (inCopyLen_[ubAxis] == 0) {
178- SetEvent<HardEvent::MTE3_V>(HardEvent::MTE3_V);
179 padParam.padWLOffset = 0;212 padParam.padWLOffset = 0;
180 padParam.padWROffset = 0;213 padParam.padWROffset = 0;
181- Duplicate(src[additionOffset_], constValue_, tilingData_->outTileSize / sizeof(T));
182 } else {214 } else {
183- SetEvent<HardEvent::MTE3_V>(HardEvent::MTE3_V);
184 padParam.padWLOffset = (outIndex_[ubAxis] < tilingData_->leftPad[ubAxis]) ?215 padParam.padWLOffset = (outIndex_[ubAxis] < tilingData_->leftPad[ubAxis]) ?
185 tilingData_->leftPad[ubAxis] % ubFactor :216 tilingData_->leftPad[ubAxis] % ubFactor :
186 0;217 0;
@@ -191,8 +222,6 @@ private:
191 tilingData_->inShape[tilingData_->ubAxis]) %222 tilingData_->inShape[tilingData_->ubAxis]) %
192 ubFactor;223 ubFactor;
193 uint32_t ubOffset = CeilAlign(padParam.padWLOffset, BLK_ELEMS);224 uint32_t ubOffset = CeilAlign(padParam.padWLOffset, BLK_ELEMS);
194- Duplicate(src, constValue_, additionOffset_ + tilingData_->outTileSize / sizeof(T));
195- SetEvent<HardEvent::V_MTE2>(HardEvent::V_MTE2);
196 uint32_t copyLen = inCopyLen_[ubAxis];225 uint32_t copyLen = inCopyLen_[ubAxis];
197 uint32_t remainderLen = 0;226 uint32_t remainderLen = 0;
198 if (ubOffset != padParam.padWLOffset) {227 if (ubOffset != padParam.padWLOffset) {
@@ -210,12 +239,12 @@ private:
210 copyInParams.blockLen = copyLen * sizeof(T);239 copyInParams.blockLen = copyLen * sizeof(T);
211 DataCopyPad(src[additionOffset_ + ubOffset], input_[inAddr + remainderLen], copyInParams, padParams);240 DataCopyPad(src[additionOffset_ + ubOffset], input_[inAddr + remainderLen], copyInParams, padParams);
212 }241 }
213- 242+ hasMTE2 = true;
214- SetEvent<HardEvent::MTE2_V>(HardEvent::MTE2_V);
215 }243 }
216 }244 }
217 245 
218- __aicore__ inline void CopyOut(const LocalTensor<T>& src, PadHugeParam& padParam)246+ __aicore__ inline void CopyOut(const LocalTensor<T>& src, PadHugeParam& padParam, bool hasMTE2, bool hasPadding,
247+ int32_t idx)
219 {248 {
220 const int8_t ubAxis = tilingData_->ubAxis;249 const int8_t ubAxis = tilingData_->ubAxis;
221 const uint32_t ubFactor = tilingData_->ubFactor;250 const uint32_t ubFactor = tilingData_->ubFactor;
@@ -232,24 +261,37 @@ private:
232 copyOutParams.srcStride = 0;261 copyOutParams.srcStride = 0;
233 copyOutParams.dstStride = 0;262 copyOutParams.dstStride = 0;
234 263 
235- SetEvent<HardEvent::MTE2_MTE3>(HardEvent::MTE2_MTE3);264+ if (hasMTE2 && !hasPadding) {
zhanw_coding

建议改用 Mutex load/unload 接口,不需要判断前面是 MTE2 还是 V,可以简化代码编写

likedislike
265+ SetEvent<HardEvent::MTE2_MTE3>(HardEvent::MTE2_MTE3);
266+ } else {
267+ SetEvent<HardEvent::V_MTE3>(HardEvent::V_MTE3);
268+ }
236 DataCopyPad(output_[outAddr], src[additionOffset_], copyOutParams);269 DataCopyPad(output_[outAddr], src[additionOffset_], copyOutParams);
270+ if (!lastOut_) {
271+ if ((idx & 1) == 0) {
272+ SetFlag<HardEvent::MTE3_V>(EVENT_ID0);
273+ } else {
274+ SetFlag<HardEvent::MTE3_V>(EVENT_ID1);
275+ }
276+ }
237 }277 }
238 278 
239 __aicore__ inline void PadOneLine(LocalTensor<T> src, PadHugeParam& padParam, LocalTensor<T> addition,279 __aicore__ inline void PadOneLine(LocalTensor<T> src, PadHugeParam& padParam, LocalTensor<T> addition,
240- uint32_t additionLen)280+ uint32_t additionLen, bool hasMTE2, bool& hasPadding)
241 {281 {
242 if (padParam.padW % BLK_ELEMS == 0 && padParam.padWLOffset % BLK_ELEMS == 0 &&282 if (padParam.padW % BLK_ELEMS == 0 && padParam.padWLOffset % BLK_ELEMS == 0 &&
243 padParam.padWROffset % BLK_ELEMS == 0) {283 padParam.padWROffset % BLK_ELEMS == 0) {
244- SetEvent<HardEvent::V_MTE3>(HardEvent::V_MTE3);
245 return;284 return;
246 }285 }
286+ if (hasMTE2) {
287+ SetEvent<HardEvent::MTE2_V>(HardEvent::MTE2_V);
288+ }
247 if constexpr (sizeof(T) == B64_BYTES) {289 if constexpr (sizeof(T) == B64_BYTES) {
248 PadBothSide<AscendC::Reg::RegTraitNumTwo>(src, padParam, addition, additionLen);290 PadBothSide<AscendC::Reg::RegTraitNumTwo>(src, padParam, addition, additionLen);
249 } else {291 } else {
250 PadBothSide<AscendC::Reg::RegTraitNumOne>(src, padParam, addition, additionLen);292 PadBothSide<AscendC::Reg::RegTraitNumOne>(src, padParam, addition, additionLen);
251 }293 }
252- SetEvent<HardEvent::V_MTE3>(HardEvent::V_MTE3);294+ hasPadding = true;
253 }295 }
254 296 
255 template <const AscendC::Reg::RegTrait& Trait>297 template <const AscendC::Reg::RegTrait& Trait>
@@ -388,12 +388,26 @@ private:
388 AscendC::Reg::MaskNot(pMask, pMask, maskAll);388 AscendC::Reg::MaskNot(pMask, pMask, maskAll);
389 outMask = AscendC::Reg::UpdateMask<T, Trait>(outLen);389 outMask = AscendC::Reg::UpdateMask<T, Trait>(outLen);
390 if constexpr (UB_AXES == 2) {390 if constexpr (UB_AXES == 2) {
391- for (uint16_t n = 0; n < dimNNum; n++) {391+ for (uint16_t n = 0; n < dimNNum / 2; n++) {
392- AscendC::Reg::DataCopy(vReg, dstAddr + ubInOffset + padRigthFloorAlign + n * padCHW);392+ AscendC::Reg::DataCopy(vReg, dstAddr + ubInOffset + padRigthFloorAlign + 2 * n * padCHW);
393 vRegTmp = vReg;393 vRegTmp = vReg;
394 Duplicate<T, AscendC::Reg::MaskMergeMode::ZEROING, T>(vRegTmp, value, pMask);394 Duplicate<T, AscendC::Reg::MaskMergeMode::ZEROING, T>(vRegTmp, value, pMask);
395 Copy(vReg, vRegTmp, pMask);395 Copy(vReg, vRegTmp, pMask);
396- AscendC::Reg::DataCopy(dstAddr + ubInOffset + padRigthFloorAlign + n * padCHW, vReg, outMask);396+ AscendC::Reg::DataCopy(dstAddr + ubInOffset + padRigthFloorAlign + 2 * n * padCHW, vReg, outMask);
397+ AscendC::Reg::DataCopy(vReg, dstAddr + ubInOffset + padRigthFloorAlign + (2 * n + 1) * padCHW);
398+ vRegTmp = vReg;
399+ Duplicate<T, AscendC::Reg::MaskMergeMode::ZEROING, T>(vRegTmp, value, pMask);
400+ Copy(vReg, vRegTmp, pMask);
401+ AscendC::Reg::DataCopy(dstAddr + ubInOffset + padRigthFloorAlign + (2 * n + 1) * padCHW, vReg,
402+ outMask);
403+ }
404+ for (uint16_t i = 0; i < dimNNum % 2; i++) {
405+ AscendC::Reg::DataCopy(vReg, dstAddr + ubInOffset + padRigthFloorAlign + (dimNNum - 1) * padCHW);
406+ vRegTmp = vReg;
407+ Duplicate<T, AscendC::Reg::MaskMergeMode::ZEROING, T>(vRegTmp, value, pMask);
408+ Copy(vReg, vRegTmp, pMask);
409+ AscendC::Reg::DataCopy(dstAddr + ubInOffset + padRigthFloorAlign + (dimNNum - 1) * padCHW, vReg,
410+ outMask);
397 }411 }
398 } else if constexpr (UB_AXES == 3) {412 } else if constexpr (UB_AXES == 3) {
399 for (uint16_t n = 0; n < dimNNum; n++) {413 for (uint16_t n = 0; n < dimNNum; n++) {