@@ -217,8 +217,7 @@ findReassociationRangesForCollapse(ArrayRef<int64_t> sourceShape,
217
217
int64_t targetSize = targetShape[targetDimIdx];
218
218
// Simply check if there are any subsequent target dimensions left - if not,
219
219
// the match must be made greedily.
220
- bool isLastTargetDim = targetDimIdx == numTargetDims - 1 ;
221
- bool shouldMatchGreedily = isLastTargetDim;
220
+ bool shouldMatchGreedily = targetDimIdx == numTargetDims - 1 ;
222
221
FailureOr<ReassociationIndexRange> sourceRange;
223
222
if (targetSize == ShapedType::kDynamic ) {
224
223
sourceRange = findReassociationRangeForDynamicDim (
@@ -263,14 +262,15 @@ findReassociationRangesForCollapse(ArrayRef<int64_t> sourceShape,
263
262
return findReassociationRangesForCollapse (sourceShape, targetShape);
264
263
// FIXME: It would be preferable to avoid the expensive copies. At the moment,
265
264
// this approach is chosen for readability of the main implementation.
266
- auto sourceToReverse = sourceShape.vec (), targetToReverse = targetShape.vec ();
265
+ std::vector<int64_t > sourceToReverse = sourceShape.vec (),
266
+ targetToReverse = targetShape.vec ();
267
267
std::reverse (sourceToReverse.begin (), sourceToReverse.end ());
268
268
std::reverse (targetToReverse.begin (), targetToReverse.end ());
269
269
auto invertedRanges =
270
270
findReassociationRangesForCollapse (sourceToReverse, targetToReverse);
271
271
if (failed (invertedRanges))
272
272
return failure ();
273
- auto rangesToInvert = *invertedRanges;
273
+ SmallVector<ReassociationIndexRange> & rangesToInvert = *invertedRanges;
274
274
unsigned numSourceDims = sourceShape.size ();
275
275
// We have received the ranges for inverted shapes. Now we have to invert
276
276
// the ranges back to correspond with the original source shape.
@@ -312,7 +312,7 @@ mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
312
312
findReassociationRangesForCollapse (sourceShape, targetShape);
313
313
if (failed (maybeForwardRanges))
314
314
return std::nullopt;
315
- auto &ranges = *maybeForwardRanges;
315
+ SmallVector<ReassociationIndexRange> &ranges = *maybeForwardRanges;
316
316
// Now do the same in reverse. We need to get another valid reassociation
317
317
// through some other strategy, and then compare the results in order to
318
318
// disambiguate mixed subshapes, such as:
@@ -328,7 +328,7 @@ mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
328
328
sourceShape, targetShape, /* iterateRightToLeft=*/ true );
329
329
if (failed (maybeReverseRanges))
330
330
return std::nullopt;
331
- auto &reverseRanges = *maybeReverseRanges;
331
+ SmallVector<ReassociationIndexRange> &reverseRanges = *maybeReverseRanges;
332
332
333
333
if (ranges.size () != numTargetDims || reverseRanges.size () != numTargetDims)
334
334
return std::nullopt;
@@ -338,8 +338,8 @@ mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
338
338
SmallVector<ReassociationIndices> reassociationMap (numTargetDims);
339
339
for (unsigned targetDimIdx = 0 ; targetDimIdx < numTargetDims;
340
340
++targetDimIdx) {
341
- auto &range = ranges[targetDimIdx];
342
- auto &reverseRange = reverseRanges[targetDimIdx];
341
+ ReassociationIndexRange &range = ranges[targetDimIdx];
342
+ ReassociationIndexRange &reverseRange = reverseRanges[targetDimIdx];
343
343
// Get non-overlapping indices between the ranges
344
344
ReassociationIndices nonMatchingIndices =
345
345
range.getNonOverlappingIndicesWith (reverseRange);
0 commit comments