Merged
fix: truncation of repeatTimes in call of mul #13047
Yuan BinAdd on Sep 28
fix: truncation of repeatTimes in call of mul #13047
Merged
Total: 1 files changed+11-2
| @@ -50,6 +50,7 @@ private: | |||
| 50 | int64_t r1Num_ = 0; | 50 | int64_t r1Num_ = 0; |
| 51 | int64_t count_ = 0; | 51 | int64_t count_ = 0; |
| 52 | 52 | ||
| 53 | + static constexpr int32_t MAX_MUL_REPEAT_TIME = 128; // repeatTime uint8 类型 | ||
| 53 | static constexpr int32_t ONE_BLOCK_SIZE = 32; | 54 | static constexpr int32_t ONE_BLOCK_SIZE = 32; |
| 54 | int32_t perBlock32 = ONE_BLOCK_SIZE / sizeof(float); | 55 | int32_t perBlock32 = ONE_BLOCK_SIZE / sizeof(float); |
| 55 | 56 | ||
| @@ -192,8 +193,16 @@ __aicore__ inline void InplacePartialRotaryMulABA<T, isBrc>::ComputeMul(LocalTen | |||
| 192 | repeatParams_.src0RepStride = repStride; | 193 | repeatParams_.src0RepStride = repStride; |
| 193 | repeatParams_.src1RepStride = 0; | 194 | repeatParams_.src1RepStride = 0; |
| 194 | for (int64_t j = 0; j < onceA; j++) { | 195 | for (int64_t j = 0; j < onceA; j++) { |
| 195 | - Mul(dtsUb[j * count], src0Ub[j * count], src1Ub[j * headDim], mask, numHead, | 196 | + for (uint32_t done = 0; done < numHead;) { |
| 196 | - repeatParams_); // x*cos 非brc elewise乘 | 197 | + uint32_t remaining = numHead - done; |
| 198 | + uint8_t repeats = | ||
| 199 | + static_cast<uint8_t>(remaining > MAX_MUL_REPEAT_TIME ? MAX_MUL_REPEAT_TIME : remaining); | ||
| 200 | + | ||
| 201 | + Mul(dtsUb[j * count + done * mask], src0Ub[j * count + done * mask], src1Ub[j * headDim], mask, | ||
| 202 | + repeats, repeatParams_); | ||
| 203 | + | ||
| 204 | + done += repeats; | ||
| 205 | + } | ||
| 197 | } | 206 | } |
| 198 | } else { | 207 | } else { |
| 199 | for (int64_t j = 0; j < onceA; j++) { | 208 | for (int64_t j = 0; j < onceA; j++) { |