Skip to content

Commit da46b10

Browse files
committed
[fixup] for self-induced unit dims problem
Signed-off-by: Artem Gindinson <[email protected]>
1 parent 4dd5cc0 commit da46b10

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ findReassociationRangesForCollapse(ArrayRef<int64_t> sourceShape,
208208
for (unsigned targetDimIdx = 0, sourceDimIdx = 0;
209209
targetDimIdx < numTargetDims; ++targetDimIdx) {
210210
int64_t targetSize = targetShape[targetDimIdx];
211-
std::optional<int64_t> nextTargetSize = std::nullopt;
212-
213211
// Simply check if there are any subsequent target dimensions left - if not,
214212
// the match must be made greedily.
215213
bool isLastTargetDim = targetDimIdx == numTargetDims - 1;
@@ -340,9 +338,6 @@ mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
340338
auto &reverseRange = reverseRanges[targetDimIdx];
341339
// Get non-overlapping indices between the ranges
342340
ReassociationIndices nonMatchingIndices = range ^ reverseRange;
343-
// The ranges should overlap, at the very least
344-
if (nonMatchingIndices.size() == range.size() + reverseRange.size())
345-
return std::nullopt;
346341
// Unit dimensions can be collapsed wherever - this is the only ambiguity
347342
// that we allow.
348343
for (int64_t sourceDimIdx : nonMatchingIndices) {

mlir/unittests/Dialect/Utils/ReshapeOpsUtilsTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ TEST(ReassociationIndicesForCollapse, StaticTestUnitDims) {
7070
makeOptionalIndices({{0, 1, 2}}));
7171
EXPECT_EQ(getReassociationIndicesForCollapse({1, 1, 1}, {1}),
7272
makeOptionalIndices({{0, 1, 2}}));
73-
EXPECT_EQ(getReassociationIndicesForCollapse({1, 1, 1}, {1, 1}),
74-
makeOptionalIndices({{0}, {1, 2}}));
73+
EXPECT_EQ(getReassociationIndicesForCollapse({1, 1, 1, 1}, {1, 1, 1}),
74+
makeOptionalIndices({{0}, {1}, {2, 3}}));
7575
}
7676

7777
TEST(ReassociationIndicesForCollapse, DynamicTest) {

0 commit comments

Comments
 (0)