Merged
fix: Reduce非连续A/R轴切分sliceShape对齐修改 #884
SuneeAdd on Sep 18
fix: Reduce非连续A/R轴切分sliceShape对齐修改 #884
Merged
SuneeAdd on Sep 18
Total: 1 files changed+9-6
@@ -757,10 +757,11 @@ void ReduceOpTiling::ComputeUnitA(const uint64_t* shape)
757 bool splitHere = false;757 bool splitHere = false;
758 double maxRate = 0.0f;758 double maxRate = 0.0f;
759 for (; step <= axisLen; step = step + stepLen) {759 for (; step <= axisLen; step = step + stepLen) {
760- uint64_t s = step > sliceShape_[iA] ? FloorAlign(step, sliceShape_[iA]) : step; // 非连续与sliceShape对齐760+ uint64_t s = step;
761 if (iA == Pattern::Dim - 1 && s <= sliceShape_[iA]) {761 if (iA == Pattern::Dim - 1 && s <= sliceShape_[iA]) {
762 s = FloorAlign(s, ubBlockSize);762 s = FloorAlign(s, ubBlockSize);
763 }763 }
764+ s = s > sliceShape_[iA] ? FloorAlign(s, sliceShape_[iA]) : s; // 非连续与sliceShape对齐
764 uint64_t tmpInnerA = innerA * s;765 uint64_t tmpInnerA = innerA * s;
765 uint64_t tmpOuterA = (s >= sliceShape_[iA] ?766 uint64_t tmpOuterA = (s >= sliceShape_[iA] ?
766 outerA / axisLen * CeilDiv(axisLen, s) :767 outerA / axisLen * CeilDiv(axisLen, s) :
@@ -825,19 +826,20 @@ void ReduceOpTiling::ComputeUnitR(const uint64_t* shape)
825 826 
826 // maybe bBlockNum not full827 // maybe bBlockNum not full
827 step = std::min(bBlockNum / (innerA * innerR * cBlock_.aSize * cBlock_.rSize), axisLen);828 step = std::min(bBlockNum / (innerA * innerR * cBlock_.aSize * cBlock_.rSize), axisLen);
828- if (step > sliceShape_[iR]) {
829- step = FloorAlign(step, sliceShape_[iR]);
830- }
831 if (iR == Pattern::Dim - 1) {829 if (iR == Pattern::Dim - 1) {
832 step = FloorAlign(step, ubBlockSize);830 step = FloorAlign(step, ubBlockSize);
833 }831 }
832+ if (step > sliceShape_[iR]) {
833+ step = FloorAlign(step, sliceShape_[iR]);
834+ }
834 uint64_t minStep = (iR == axisInCacheLine ? cBlock_.cacheLineStep : 1UL);835 uint64_t minStep = (iR == axisInCacheLine ? cBlock_.cacheLineStep : 1UL);
835 for (uint64_t s = step; s > minStep; s--) {836 for (uint64_t s = step; s > minStep; s--) {
836- uint64_t tmpS = (s > sliceShape_[iR] ? FloorAlign(s, sliceShape_[iR]) : s); // 非连续与sliceShape对齐837+ uint64_t tmpS = s;
837 if (iR == Pattern::Dim - 1 && tmpS != sliceShape_[iR]) {838 if (iR == Pattern::Dim - 1 && tmpS != sliceShape_[iR]) {
838 // 尾轴R场景,尽可能保证尾轴切分block对齐,减少kernel侧补pad839 // 尾轴R场景,尽可能保证尾轴切分block对齐,减少kernel侧补pad
839 tmpS = FloorAlign(tmpS, ubBlockSize);840 tmpS = FloorAlign(tmpS, ubBlockSize);
840 }841 }
842+ tmpS = (tmpS > sliceShape_[iR] ? FloorAlign(tmpS, sliceShape_[iR]) : tmpS); // 非连续与sliceShape对齐
841 auto tmpOuterR = (tmpS >= sliceShape_[iR] ?843 auto tmpOuterR = (tmpS >= sliceShape_[iR] ?
842 outerR / axisLen * CeilDiv(axisLen, tmpS) :844 outerR / axisLen * CeilDiv(axisLen, tmpS) :
843 outerR / axisLen * sliceNum_[iR] * CeilDiv(sliceShape_[iR], tmpS));845 outerR / axisLen * sliceNum_[iR] * CeilDiv(sliceShape_[iR], tmpS));
@@ -889,10 +891,11 @@ void ReduceOpTiling::ComputeProgressUnitA(const uint64_t* shape)
889 uint64_t s = (iA == unitA_.idx ? unitA_.step + 1UL : 1UL);891 uint64_t s = (iA == unitA_.idx ? unitA_.step + 1UL : 1UL);
890 uint64_t maxStep = (iA == unitA_.idx ? unitA_.step : 1UL);892 uint64_t maxStep = (iA == unitA_.idx ? unitA_.step : 1UL);
891 for (; s <= axisLen; s++) {893 for (; s <= axisLen; s++) {
892- uint64_t tmpS = s > sliceShape_[iA] ? FloorAlign(s, sliceShape_[iA]) : s; // 非连续与sliceShape对齐894+ uint64_t tmpS = s;
893 if (iA == Pattern::Dim - 1) {895 if (iA == Pattern::Dim - 1) {
894 tmpS = CeilAlign(tmpS, ubBlockSize);896 tmpS = CeilAlign(tmpS, ubBlockSize);
895 }897 }
898+ tmpS = tmpS > sliceShape_[iA] ? FloorAlign(tmpS, sliceShape_[iA]) : tmpS; // 非连续与sliceShape对齐
896 uint64_t tmpInnerA = innerA * tmpS;899 uint64_t tmpInnerA = innerA * tmpS;
897 uint64_t tmpOuterA = (tmpS >= sliceShape_[iA] ?900 uint64_t tmpOuterA = (tmpS >= sliceShape_[iA] ?
898 outerA / axisLen * CeilDiv(axisLen, tmpS) :901 outerA / axisLen * CeilDiv(axisLen, tmpS) :