File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
mlir/lib/Dialect/Tosa/Utils Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -77,24 +77,21 @@ computeReshapeOutput(ArrayRef<int64_t> higherRankShape,
77
77
// Initialize new shapes with [1] * higherRank.
78
78
int64_t higherRank = higherRankShape.size ();
79
79
int64_t lowerRank = lowerRankShape.size ();
80
-
81
80
reshapeOutputShape.assign (higherRank, 1 );
82
81
83
82
int64_t higherRankDim;
84
83
int64_t lowerRankDim;
84
+ const int64_t rankDiff = higherRank - lowerRank;
85
+
86
+ for (int64_t i = lowerRank - 1 ; i >= 0 ; i--) {
87
+ higherRankDim = higherRankShape[i + rankDiff];
88
+ lowerRankDim = lowerRankShape[i];
85
89
86
- for (int64_t i = higherRank - 1 , j = lowerRank - 1 ; i >= 0 && j >= 0 ;
87
- i--, j--) {
88
- higherRankDim = higherRankShape[i];
89
- lowerRankDim = lowerRankShape[j];
90
-
91
- if (lowerRankDim == 1 && higherRankDim > 1 )
92
- reshapeOutputShape[i] = 1 ;
93
- else if ((lowerRankDim > 1 && higherRankDim == 1 ) ||
94
- (lowerRankDim == higherRankDim))
95
- reshapeOutputShape[i] = lowerRankDim;
96
- else if (higherRankDim != lowerRankDim)
90
+ if (lowerRankDim != 1 && higherRankDim != 1 &&
91
+ lowerRankDim != higherRankDim)
97
92
return failure ();
93
+
94
+ reshapeOutputShape[i + rankDiff] = lowerRankDim == 1 ? 1 : lowerRankDim;
98
95
}
99
96
return success ();
100
97
}
You can’t perform that action at this time.
0 commit comments